summaryrefslogtreecommitdiff
path: root/tests/compute
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-11-16 19:31:57 -0800
committerGitHub <noreply@github.com>2017-11-16 19:31:57 -0800
commit0e3d9ba255b86c11521a951183d38bffae008559 (patch)
tree3be0a0da5a8f6bfddaae761dff7a4872f355787d /tests/compute
parent871fbeec58caaa02ec990a676f10fa7014391a58 (diff)
IR: pass through `[unroll]` attribute (#284)
The initial lowering was adding an `IRLoopControlDecoration` to the instruction at the head of a loop, but this was getting dropped when the IR gets cloned for a particular entry point. The fix was simply to add a case for loop-control decorations to `cloneDecoration`.
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/loop-unroll.slang29
-rw-r--r--tests/compute/loop-unroll.slang.expected.txt4
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/compute/loop-unroll.slang b/tests/compute/loop-unroll.slang
new file mode 100644
index 000000000..5b1635a8d
--- /dev/null
+++ b/tests/compute/loop-unroll.slang
@@ -0,0 +1,29 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(0),glbinding(0),out
+//TEST_INPUT:ubuffer(data=[1 2 3 0], stride=4):dxbinding(1),glbinding(1)
+
+// Check that we propagate the `[unroll]` attribute
+// through to HLSL output correctly.
+//
+// If we neglect to generate the attribute in the output,
+// it will generate a warning output from fxc, and the
+// test will fail to match the expected output.
+
+RWStructuredBuffer<int> buffers[2];
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ int val = buffers[1][tid];
+
+ [unroll]
+ for(int ii = 0; ii < 2; ii++)
+ {
+ val = buffers[ii][val];
+ }
+
+ buffers[0][tid] = val;
+} \ No newline at end of file
diff --git a/tests/compute/loop-unroll.slang.expected.txt b/tests/compute/loop-unroll.slang.expected.txt
new file mode 100644
index 000000000..7ffb87d2b
--- /dev/null
+++ b/tests/compute/loop-unroll.slang.expected.txt
@@ -0,0 +1,4 @@
+2
+3
+0
+1