summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-05-08 10:41:52 -0700
committerGitHub <noreply@github.com>2024-05-08 10:41:52 -0700
commit6d917a02bb307300ac14c8b028c47fcdcc07100b (patch)
tree1eefd2e6249fe73d7164de5d2aca6bd1c3b6da73 /tests/bugs
parent7514d0b608eeebf5e5fa81ad0ff1961643120ad0 (diff)
Fix NonUniformResourceIndex legalization for SPIRV. (#4133)
* Fix NonUniformResourceIndex legalization for SPIRV. * Update gh-4131.slang
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/gh-4131.slang31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/bugs/gh-4131.slang b/tests/bugs/gh-4131.slang
new file mode 100644
index 000000000..d72bc5d0d
--- /dev/null
+++ b/tests/bugs/gh-4131.slang
@@ -0,0 +1,31 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+//CHECK: OpEntryPoint
+
+struct TypeA {
+ float4 placeholder;
+};
+struct TypeB {
+ float4 placeholder;
+};
+
+[[vk::binding(0, 0)]]
+StructuredBuffer<TypeA> a_buffers[] : register(t0, space0);
+[[vk::binding(0, 1)]]
+StructuredBuffer<TypeB> b_buffer : register(t0, space0);
+
+struct VertexIn {
+ int32_t vert_idx : SV_VertexID;
+ [[KnownBuiltin("DrawIndex")]]
+ uint32_t draw_idx : POSITION0;
+};
+
+[shader("vertex")]
+float4 vert(VertexIn i) : SV_POSITION {
+ // Proper usage of NonUniformResourceIndex works fine
+ float4 a =
+ a_buffers[NonUniformResourceIndex(i.draw_idx)][i.vert_idx].placeholder;
+ // Incorrect usage but dxc compiles this with no warning
+ float4 b = b_buffer[NonUniformResourceIndex(i.draw_idx)].placeholder;
+ return a + b;
+}