summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/stk-chk.slang55
-rw-r--r--tests/bugs/stk-chk.slang.expected.txt4
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/bugs/stk-chk.slang b/tests/bugs/stk-chk.slang
new file mode 100644
index 000000000..8fabaeee5
--- /dev/null
+++ b/tests/bugs/stk-chk.slang
@@ -0,0 +1,55 @@
+//TEST(compute):COMPARE_COMPUTE:-cpu
+
+// Tests slang-llvm can deal with large items on stack.
+// On some targets this requires special handling (_chkstk on windows for example)
+
+struct LargeStruct
+{
+ int values[4096];
+};
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[9 1000 27 34], stride=4):name inputBuffer
+StructuredBuffer<int> inputBuffer;
+
+LargeStruct _calcStruct(int a)
+{
+ LargeStruct s;
+
+ int t = a;
+
+ for (int i = 0; i < 4096; ++i)
+ {
+ s.values[i] = t;
+
+ // Munge
+ t = t ^ (i * t) + (i - a) * 17 + inputBuffer[t & 3];
+ }
+
+ return s;
+}
+
+int _calcValue(LargeStruct s)
+{
+ int v = 0;
+ for (int i = 0; i < 4096; ++i)
+ {
+ v ^= s.values[i];
+ }
+ return v + 1;
+}
+
+int _calc1(int a)
+{
+ return _calcValue(_calcStruct(_calcValue(_calcStruct(_calcValue(_calcStruct(a ^ 19))))));
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ outputBuffer[index] = _calc1(index) + 1;
+} \ No newline at end of file
diff --git a/tests/bugs/stk-chk.slang.expected.txt b/tests/bugs/stk-chk.slang.expected.txt
new file mode 100644
index 000000000..530a099a9
--- /dev/null
+++ b/tests/bugs/stk-chk.slang.expected.txt
@@ -0,0 +1,4 @@
+5B2F1F3C
+FB3647FB
+AC4B2652
+A954D2BD