From 67af8c718ce5e3f95a25e5188840f63b41a33ecc Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:15:48 -0700 Subject: 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> --- tests/spirv/device-index-glsl-syntax.slang | 16 ++++++++++++++++ tests/spirv/device-index-hlsl-syntax.slang | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/spirv/device-index-glsl-syntax.slang create mode 100644 tests/spirv/device-index-hlsl-syntax.slang (limited to 'tests/spirv') 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); +} -- cgit v1.2.3