From 00e7542894bec76054d0a4f74033b20064b58d4c Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Sun, 5 Jan 2025 00:24:44 +0200 Subject: [PATCH] Make 'shared' keyword map to 'groupshared' in GLSL mode (#6003) --- source/slang/slang-parser.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 1aa313fa8f..22491c848b 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -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(); + } + else + { + modifier = parser->astBuilder->create(); + } + modifier->keywordName = getName(parser, "shared"); + modifier->loc = parser->tokenReader.peekLoc(); + return modifier; +} + static NodeBase* parseVolatileModifier(Parser* parser, void* /*userData*/) { ModifierListBuilder listBuilder; @@ -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),