summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-07-30 23:04:08 -0400
committerGitHub <noreply@github.com>2024-07-30 20:04:08 -0700
commit04e7327a2067c82db3eaef51955f211e148ac933 (patch)
tree8a8320db5165e280efb2fdb9aa4ecd078d380c72 /tests/bugs
parentfef0a87ddee9c0f252a6625395b684b1cb5d85e0 (diff)
Move SPIRV global variables into a context variable (#4741)
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/spirv-opt-SROA-of-globals.slang37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/spirv-opt-SROA-of-globals.slang b/tests/bugs/spirv-opt-SROA-of-globals.slang
new file mode 100644
index 000000000..140559b4f
--- /dev/null
+++ b/tests/bugs/spirv-opt-SROA-of-globals.slang
@@ -0,0 +1,37 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -fvk-use-entrypoint-name -enable-experimental-passes
+
+// This test checks that spirv-opt is running SROA (scalar replacement of aggregates) to
+// hoist out all member variables of a struct. If this sucsessfully runs, we should not see
+// any `OpCompositeConstruct` of our `%Data` struct.
+// Note: SROA will only run for 100 elements if spirv-opt does not manually set the spirv-opt `scalar-replacement` option
+
+//CHECK-NOT: OpCompositeConstruct %Data
+struct Data
+{
+ uint data0;
+ uint data1;
+ uint data2;
+};
+
+static Data globalVar;
+ByteAddressBuffer bab;
+RWStructuredBuffer<uint> outputBuffer;
+
+struct Payload_t
+{
+ uint dataOut;
+};
+
+[shader("anyhit")]
+void main1(inout Payload_t payload)
+{
+ globalVar = bab.Load<Data>(0);
+ payload.dataOut = globalVar.data0;
+}
+
+[shader("anyhit")]
+void main2(inout Payload_t payload)
+{
+ globalVar = bab.Load<Data>(0);
+ payload.dataOut = globalVar.data0;
+} \ No newline at end of file