diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-07-17 23:53:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 23:53:43 +0000 |
| commit | 447d73f8c2245d061b0e84890fb994a77816a736 (patch) | |
| tree | 1361e7d1a28c225f46a7e2c5ad86a7ffcea0897b /tests/diagnostics | |
| parent | 094d1ba7cd1eb5f09be05b2e57b5fbd3041cca38 (diff) | |
Fix GLSL global const diagnostic regression (#7808)
* Initial plan
* Fix GLSL global const diagnostic regression - add test exclusion for GLSL module
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
Diffstat (limited to 'tests/diagnostics')
| -rw-r--r-- | tests/diagnostics/glsl-global-const-with-init.slang | 26 | ||||
| -rw-r--r-- | tests/diagnostics/hlsl-global-const-with-init-still-errors.slang | 18 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/diagnostics/glsl-global-const-with-init.slang b/tests/diagnostics/glsl-global-const-with-init.slang new file mode 100644 index 000000000..ff5b35b75 --- /dev/null +++ b/tests/diagnostics/glsl-global-const-with-init.slang @@ -0,0 +1,26 @@ +//TEST:SIMPLE(filecheck=CHK): -target glsl -stage fragment -entry main -allow-glsl + +// Test for GLSL mode: global const variables with initializers should be allowed +// In GLSL mode, global const variables are real constants, not uniform parameters +// This should NOT produce the error 31224 that would trigger in HLSL mode + +#version 450 + +// These should NOT trigger error 31224 in GLSL mode (they would in HLSL) +const float globalConstWithInit = 1.0; // OK in GLSL - real constant +const vec3 globalVecConst = vec3(1.0, 2.0, 3.0); // OK in GLSL - real constant +const int globalIntConst = 42; // OK in GLSL - real constant + +// Regular uniforms without const should still be allowed +uniform float uniformFloat; // OK - uniform without const +uniform vec4 uniformVec; // OK - uniform without const + +// CHK-NOT: error 31224 +// CHK: void main() + +out vec4 fragColor; + +void main() +{ + fragColor = vec4(globalConstWithInit, globalVecConst.x, globalIntConst, 1.0); +}
\ No newline at end of file diff --git a/tests/diagnostics/hlsl-global-const-with-init-still-errors.slang b/tests/diagnostics/hlsl-global-const-with-init-still-errors.slang new file mode 100644 index 000000000..71471a6b3 --- /dev/null +++ b/tests/diagnostics/hlsl-global-const-with-init-still-errors.slang @@ -0,0 +1,18 @@ +//TEST:SIMPLE(filecheck=CHK): -target hlsl -entry main + +// Test to ensure HLSL mode still produces the diagnostic for global const with initializers +// This verifies our fix doesn't break existing HLSL behavior + +// This should trigger error 31224 in HLSL mode +//CHK: ([[# @LINE + 1]]): error 31224: global const variable with initializer must be declared static: 'globalConstWithInit' +const float globalConstWithInit = 1.0f; + +// This should also trigger error 31224 in HLSL mode +//CHK: ([[# @LINE + 1]]): error 31224: global const variable with initializer must be declared static: 'uniformWithInit' +uniform float uniformWithInit = 2.0f; + +[shader("vertex")] +float4 main() : SV_Position +{ + return float4(1, 0, 0, 1); +}
\ No newline at end of file |
