summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-01-23 19:37:10 -0800
committerGitHub <noreply@github.com>2024-01-23 19:37:10 -0800
commitad45062fcc76cd622aaa1a9cb00515d42f8d3528 (patch)
tree28a54911021d4e3c8cd69dc47f67b8f39cdb310a /tests/spirv
parent1c1d096234d43b2bcb33c2438a6626831bd4e0aa (diff)
SPIRV Legalization fixes. (#3479)
* Fix CFG legalization for SPIRV backend. * Emit DepthReplacing execution mode. * Fix do-while lowering. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/depth-replacing.slang16
-rw-r--r--tests/spirv/while-continue.slang45
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/spirv/depth-replacing.slang b/tests/spirv/depth-replacing.slang
new file mode 100644
index 000000000..df2ab17e1
--- /dev/null
+++ b/tests/spirv/depth-replacing.slang
@@ -0,0 +1,16 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage fragment -entry main -emit-spirv-directly
+
+struct PSOut
+{
+ float4 color : SV_Target;
+ float depth : SV_Depth;
+}
+// CHECK: OpExecutionMode {{.*}} DepthReplacing
+
+PSOut main()
+{
+ PSOut psout;
+ psout.color = float4(1.0f, 0.0f, 0.0f, 1.0f);
+ psout.depth = 0.5f;
+ return psout;
+}
diff --git a/tests/spirv/while-continue.slang b/tests/spirv/while-continue.slang
new file mode 100644
index 000000000..9c7b89295
--- /dev/null
+++ b/tests/spirv/while-continue.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -emit-spirv-directly
+
+// Test that we can transform a continue in a while loop to valid spirv.
+
+uniform int loopCount;
+
+// CHECK: OpEntryPoint
+
+bool condition1()
+{
+ AllMemoryBarrier();
+ return output[2] < 1;
+}
+bool condition2()
+{
+ AllMemoryBarrier();
+ return output[3] < 1;
+}
+
+RWStructuredBuffer<float> output;
+
+[numthreads(1,1,1)]
+void main()
+{
+ float weight = 0.0;
+ do
+ {
+ if (condition2())
+ {
+ continue;
+ }
+ AllMemoryBarrier();
+ } while (condition1());
+
+ while(condition1())
+ {
+ if (condition2())
+ {
+ continue;
+ }
+ AllMemoryBarrier();
+ }
+
+ output[0] = weight;
+}