summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-06-22 15:07:31 -0400
committerGitHub <noreply@github.com>2023-06-22 15:07:31 -0400
commit769c7fdd19ea579770baac7b6d5e16d6406a8013 (patch)
treea0f04c668911a2b3b58e0fc89f5bb765540226bd /tests
parentac541d45fafde340b141172cf76d003ff70d471e (diff)
[branch] and [flatten] support (#2928)
* #include an absolute path didn't work - because paths were taken to always be relative. * Small fixes and improvements around reflection tool. * Make PrettyWriter printing a class. * Add HLSL output support for [flatten] and [branch] * Handle [branch] on switch.
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/branch-attribute.slang29
-rw-r--r--tests/bugs/branch-switch-attribute.slang24
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/bugs/branch-attribute.slang b/tests/bugs/branch-attribute.slang
new file mode 100644
index 000000000..17e30a278
--- /dev/null
+++ b/tests/bugs/branch-attribute.slang
@@ -0,0 +1,29 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// CHECK: [branch]
+// CHECK: [flatten]
+
+[numthreads(4, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = dispatchThreadID.x;
+
+ int v = idx;
+
+ [branch]
+ if (idx != 0)
+ {
+ ++v;
+ }
+
+ [flatten]
+ if (idx > 2)
+ {
+ v += v;
+ }
+
+ outputBuffer[dispatchThreadID.x] = v;
+} \ No newline at end of file
diff --git a/tests/bugs/branch-switch-attribute.slang b/tests/bugs/branch-switch-attribute.slang
new file mode 100644
index 000000000..761b80e9e
--- /dev/null
+++ b/tests/bugs/branch-switch-attribute.slang
@@ -0,0 +1,24 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// CHECK: [branch]
+
+[numthreads(4, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = dispatchThreadID.x;
+
+ int v = idx;
+
+ [branch]
+ switch (idx)
+ {
+ case 0: v ++; break;
+ case 2: v -= 7; break;
+ default: v--;
+ }
+
+ outputBuffer[dispatchThreadID.x] = v;
+} \ No newline at end of file