summaryrefslogtreecommitdiffstats
path: root/tests/bugs/nested-switch.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-06 10:07:02 -0800
committerGitHub <noreply@github.com>2023-02-06 10:07:02 -0800
commite893a831d7f64eb52e76df087190247f43b150ae (patch)
tree1cf91d943741ed25ad057a1bf34f47ee03b5229b /tests/bugs/nested-switch.slang
parenta12c5511a9003efb23b265a7f2f613cf49aa9f07 (diff)
Fix crash when processing nested switch. (#2624)
* Fix crash when processing nested switch. * Clean up. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/bugs/nested-switch.slang')
-rw-r--r--tests/bugs/nested-switch.slang37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/nested-switch.slang b/tests/bugs/nested-switch.slang
new file mode 100644
index 000000000..3cfc0758b
--- /dev/null
+++ b/tests/bugs/nested-switch.slang
@@ -0,0 +1,37 @@
+// nested-switch.slang
+
+//TEST(compute):COMPARE_COMPUTE: -shaderobj
+//TEST(compute):COMPARE_COMPUTE:-vk -shaderobj
+//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
+
+int test(int t, int r)
+{
+ int result = 0;
+ switch (t)
+ {
+ case 0:
+ switch (r)
+ {
+ case 0:
+ return 1;
+ case 2:
+ return 2;
+ }
+ default:
+ result = 3;
+ break;
+ }
+ return result;
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
+{
+ outputBuffer[0] = test(dispatchThreadID.x, 0);
+ outputBuffer[1] = test(dispatchThreadID.x, 1);
+ outputBuffer[2] = test(dispatchThreadID.x, 2);
+ outputBuffer[3] = 0;
+}