summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-03-31 21:17:49 -0400
committerGitHub <noreply@github.com>2025-04-01 01:17:49 +0000
commit1fa4e486f598c5a7eed0db65f187ab95f890133c (patch)
tree7a817f09503a53cb8caec419db144722c4684971 /tests
parentbc9dc6557fc0cc3a4c0c2ff27e636940e361cf5d (diff)
Fix compilation of global builtin variables inside generics (#6701)
* Include generics' operands in call graph construction * add test
Diffstat (limited to 'tests')
-rw-r--r--tests/glsl/builtin-inside-generics.slang41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/glsl/builtin-inside-generics.slang b/tests/glsl/builtin-inside-generics.slang
new file mode 100644
index 000000000..fc5caeb6a
--- /dev/null
+++ b/tests/glsl/builtin-inside-generics.slang
@@ -0,0 +1,41 @@
+//TEST:SIMPLE(filecheck=CHECK_SPIRV): -entry main -stage compute -target spirv -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_GLSL): -entry main -stage compute -target glsl -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_HLSL): -entry main -stage compute -target hlsl -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_METAL): -entry main -stage compute -target metal -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_WGSL): -entry main -stage compute -target wgsl -allow-glsl
+
+RWStructuredBuffer<uint> outputBuffer;
+
+T getGlobalInvocationID<T: IInteger>(T value)
+{
+ return T(gl_GlobalInvocationID.x) + value;
+}
+
+T getWaveLaneIndex<T: IInteger>(T value)
+{
+ return T(WaveGetLaneIndex()) + value;
+}
+
+// CHECK_SPIRV: GlobalInvocationId
+// CHECK_SPIRV: SubgroupLocalInvocationId
+
+// CHECK_GLSL: gl_GlobalInvocationID
+// CHECK_GLSL: gl_SubgroupInvocationID
+
+// CHECK_HLSL: WaveGetLaneIndex()
+// CHECK_HLSL: SV_DispatchThreadID
+
+// CHECK_METAL: thread_position_in_grid
+// CHECK_METAL: thread_index_in_simdgroup
+
+// CHECK_WGSL: global_invocation_id
+// CHECK_WGSL: subgroup_invocation_id
+
+[shader("compute")]
+void main()
+{
+ outputBuffer[0U] = getGlobalInvocationID(0U);
+ outputBuffer[1U] = getWaveLaneIndex(0U);
+}
+
+