diff options
| author | Julius Ikkala <julius.ikkala@gmail.com> | 2024-12-30 01:28:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-29 23:28:11 +0000 |
| commit | 71cd967f7ec6e5b50daecfa628cc34f6d7016a6a (patch) | |
| tree | 8385be70341f6a26607c3e3594f6c347c2b8ae56 /source/slang/slang-check-expr.cpp | |
| parent | 7a6de4aea1973b379d9f3b7db248ad260d3ee024 (diff) | |
Prevent constant folding for specialization constants (#5953)
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 7972e2d81..7cb0ede2d 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -1944,6 +1944,13 @@ IntVal* SemanticsVisitor::tryConstantFoldDeclRef( // In HLSL, `const` is used to mark compile-time constant expressions. if (!decl->hasModifier<ConstModifier>()) return nullptr; + + // The values of specialization constants aren't known at compile time even + // if they're marked `const`. + if (decl->hasModifier<SpecializationConstantAttribute>() || + decl->hasModifier<VkConstantIdAttribute>()) + return nullptr; + if (decl->hasModifier<ExternModifier>()) { // Extern const is not considered compile-time constant by the front-end. |
