Skip to content

Commit

Permalink
Make 'shared' keyword map to 'groupshared' in GLSL mode (#6003)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusikkala authored Jan 4, 2025
1 parent 114c976 commit 00e7542
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion source/slang/slang-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8335,6 +8335,26 @@ static NodeBase* parseCUDASMVersionModifier(Parser* parser, void* /*userData*/)
parser->sink->diagnose(token, Diagnostics::invalidCUDASMVersion);
return nullptr;
}

static NodeBase* parseSharedModifier(Parser* parser, void* /*userData*/)
{
Modifier* modifier = nullptr;

// While in GLSL compatibility mode, 'shared' = 'groupshared' and not the
// D3D11 effect syntax.
if (parser->options.allowGLSLInput)
{
modifier = parser->astBuilder->create<HLSLGroupSharedModifier>();
}
else
{
modifier = parser->astBuilder->create<HLSLEffectSharedModifier>();
}
modifier->keywordName = getName(parser, "shared");
modifier->loc = parser->tokenReader.peekLoc();
return modifier;
}

static NodeBase* parseVolatileModifier(Parser* parser, void* /*userData*/)
{
ModifierListBuilder listBuilder;
Expand Down Expand Up @@ -8762,7 +8782,7 @@ static const SyntaxParseInfo g_parseSyntaxEntries[] = {
_makeParseModifier("sample", HLSLSampleModifier::kReflectClassInfo),
_makeParseModifier("centroid", HLSLCentroidModifier::kReflectClassInfo),
_makeParseModifier("precise", PreciseModifier::kReflectClassInfo),
_makeParseModifier("shared", HLSLEffectSharedModifier::kReflectClassInfo),
_makeParseModifier("shared", parseSharedModifier),
_makeParseModifier("groupshared", HLSLGroupSharedModifier::kReflectClassInfo),
_makeParseModifier("static", HLSLStaticModifier::kReflectClassInfo),
_makeParseModifier("uniform", HLSLUniformModifier::kReflectClassInfo),
Expand Down

0 comments on commit 00e7542

Please sign in to comment.