summaryrefslogtreecommitdiffstats
path: root/tests/optimization/buffer-load-specialize-1.slang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/optimization/buffer-load-specialize-1.slang')
-rw-r--r--tests/optimization/buffer-load-specialize-1.slang35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/optimization/buffer-load-specialize-1.slang b/tests/optimization/buffer-load-specialize-1.slang
new file mode 100644
index 000000000..55f2df473
--- /dev/null
+++ b/tests/optimization/buffer-load-specialize-1.slang
@@ -0,0 +1,35 @@
+//TEST:SIMPLE(filecheck=SPV): -target spirv -O0
+
+struct Bottom
+{
+ float bigArray[1024];
+ // SPV: %Bottom_bottomGetValue = OpFunction %float None %{{.*}}
+ // SPV-NEXT: %{{.*}} = OpFunctionParameter %int
+ // SPV-NEXT: OpLabel
+ // SPV-NOT: OpCompositeConstruct
+ // SPV: OpFunctionEnd
+
+ // SPV: %Bottom_bottomGetValue_0 = OpFunction %float None %{{.*}}
+ // SPV-NEXT: %{{.*}} = OpFunctionParameter %int
+ // SPV-NEXT: OpLabel
+ float bottomGetValue(int index) { return bigArray[index]; }
+}
+
+struct Root
+{
+ Bottom bottom1;
+ Bottom bottom2;
+}
+
+ConstantBuffer<Root> cb;
+
+RWStructuredBuffer<float> outputBuffer;
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void compute_main(uint3 tid: SV_DispatchThreadID)
+{
+ outputBuffer[0] = cb.bottom1.bottomGetValue(0);
+ outputBuffer[1] = cb.bottom2.bottomGetValue(1);
+ outputBuffer[2] = cb.bottom2.bottomGetValue(2);
+}