summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-02-27 16:57:52 -0800
committerGitHub <noreply@github.com>2025-02-27 16:57:52 -0800
commit6f2ce72b038b34e84819ddfc5d658166ed879eaa (patch)
tree486a85523114a428ccf4deee05bcbab0d4b9528b /tests
parent90b3817498d9cf664346f04dcea71f48ce81993e (diff)
Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` (#6468)
* Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` * Fix ci.
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/gh-3087-multi-entry-point.slang18
-rw-r--r--tests/hlsl-intrinsic/system-values-draw-parameters.slang2
-rw-r--r--tests/spirv/sv_instance.slang14
3 files changed, 27 insertions, 7 deletions
diff --git a/tests/bugs/gh-3087-multi-entry-point.slang b/tests/bugs/gh-3087-multi-entry-point.slang
index d3aa574c7..edfda08af 100644
--- a/tests/bugs/gh-3087-multi-entry-point.slang
+++ b/tests/bugs/gh-3087-multi-entry-point.slang
@@ -3,14 +3,20 @@
// CHECK-DAG: OpEntryPoint Vertex
// CHECK-DAG: OpEntryPoint Fragment
-// we should only have 1 'BuiltIn InstanceIndex' since the `Output` and `Input` semantic
-// for `InstanceIndex` should be converted to a non-builtin
-// CHECK-DAG: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex
-// CHECK-NOT: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex
-
// We require 1 `Flat` for the fragment input `uint`
// CHECK-DAG: OpDecorate %{{[1-9][0-9]*}} Flat
-// CHECK-NOT: OpDecorate %{{[1-9][0-9]*}} Flat
+
+// CHECK-DAG: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex
+
+// The vertex shader should be using the builtin InstanceIndex var.
+// CHECK: %vmain = OpFunction
+// CHECK: InstanceIndex
+// CHECK: OpFunctionEnd
+
+// The fragment shader should not be using the builtin InstanceIndex var.
+// CHECK: %pmain = OpFunction
+// CHECK-NOT: InstanceIndex
+// CHECK: OpFunctionEnd
struct VIn
{
diff --git a/tests/hlsl-intrinsic/system-values-draw-parameters.slang b/tests/hlsl-intrinsic/system-values-draw-parameters.slang
index e45366939..009efffa1 100644
--- a/tests/hlsl-intrinsic/system-values-draw-parameters.slang
+++ b/tests/hlsl-intrinsic/system-values-draw-parameters.slang
@@ -32,7 +32,7 @@ VSOutput main(VSInput input,
// CHECK_HLSL: SV_StartVertexLocation
// CHECK_METAL: base_vertex
- // CHECK_SPIRV: BuiltIn BaseInstance
+ // CHECK_SPIRV: BuiltIn InstanceIndex
// CHECK_GLSL: gl_BaseInstance
// CHECK_HLSL: SV_StartInstanceLocation
// CHECK_METAL: base_instance
diff --git a/tests/spirv/sv_instance.slang b/tests/spirv/sv_instance.slang
new file mode 100644
index 000000000..e71c6c7fa
--- /dev/null
+++ b/tests/spirv/sv_instance.slang
@@ -0,0 +1,14 @@
+//TEST:SIMPLE(filecheck=GLSL): -target glsl -entry vertMain -stage vertex
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK-DAG: %[[REG1:[0-9a-zA-Z_]+]] = OpLoad %int %gl_BaseInstance
+// CHECK-DAG: %[[REG2:[0-9a-zA-Z_]+]] = OpLoad %int %gl_InstanceIndex
+// CHECK-DAG: OpISub %int %[[REG2]] %[[REG1]]
+
+// GLSL: gl_InstanceIndex - gl_BaseInstance
+
+[shader("vertex")]
+float4 vertMain(int i : SV_InstanceID) : SV_Position
+{
+ return i;
+} \ No newline at end of file