summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 46876131a..1dc230dae 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -240,13 +240,19 @@ struct SemanticsDeclModifiersVisitor : public SemanticsDeclVisitorBase,
// In HLSL, const global variables without static are uniform parameters
// that cannot have default values
// Exception: specialization constants are allowed to have initializers
+ // Exception: In GLSL mode, global const variables are real constants, not uniform
+ // parameters
if (isGlobalDecl(decl) && (hasConst || hasUniform) && !hasStatic &&
!hasSpecializationConstant && decl->initExpr)
{
- getSink()->diagnose(
- decl,
- Diagnostics::constGlobalVarWithInitRequiresStatic,
- decl->getName());
+ auto moduleDecl = getModuleDecl(decl);
+ if (!moduleDecl || !moduleDecl->hasModifier<GLSLModuleModifier>())
+ {
+ getSink()->diagnose(
+ decl,
+ Diagnostics::constGlobalVarWithInitRequiresStatic,
+ decl->getName());
+ }
}
}