summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2025-06-28 21:15:48 -0700
committerGitHub <noreply@github.com>2025-06-29 04:15:48 +0000
commit67af8c718ce5e3f95a25e5188840f63b41a33ecc (patch)
treebf5d1c7309e136223f1c62a5ec7d215274445b0c /tests/spirv
parent7349dc5cff49cf22c82eb912813e47f30cd7a757 (diff)
Support the GLSL/SPIR-V Built-in variable `DeviceIndex` (#7552)
* Support DeviceIndex * format code * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/device-index-glsl-syntax.slang16
-rw-r--r--tests/spirv/device-index-hlsl-syntax.slang17
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/spirv/device-index-glsl-syntax.slang b/tests/spirv/device-index-glsl-syntax.slang
new file mode 100644
index 000000000..3a374f038
--- /dev/null
+++ b/tests/spirv/device-index-glsl-syntax.slang
@@ -0,0 +1,16 @@
+//TEST:SIMPLE(filecheck=SPIRV): -target spirv -entry main -stage fragment -allow-glsl
+//TEST:SIMPLE(filecheck=GLSL): -target glsl -entry main -stage fragment -allow-glsl
+
+// SPIRV: OpDecorate %{{.*}} BuiltIn DeviceIndex
+// GLSL: gl_DeviceIndex
+
+struct PSIn
+{
+ float3 color;
+}
+
+[shader("fragment")]
+float4 main(PSIn pin)
+{
+ return float4(pin.color, (float)gl_DeviceIndex);
+}
diff --git a/tests/spirv/device-index-hlsl-syntax.slang b/tests/spirv/device-index-hlsl-syntax.slang
new file mode 100644
index 000000000..756f1bf80
--- /dev/null
+++ b/tests/spirv/device-index-hlsl-syntax.slang
@@ -0,0 +1,17 @@
+//TEST:SIMPLE(filecheck=SPIRV): -target spirv -entry main
+//TEST:SIMPLE(filecheck=GLSL): -target glsl -entry main
+
+// SPIRV: OpDecorate %{{.*}} BuiltIn DeviceIndex
+// GLSL: gl_DeviceIndex
+
+struct PSIn
+{
+ float3 color;
+ int deviceIndex : SV_DeviceIndex;
+}
+
+[shader("fragment")]
+float4 main(PSIn pin)
+{
+ return float4(pin.color, (float)pin.deviceIndex);
+}