summaryrefslogtreecommitdiff
path: root/tests/compute
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/default-initializer.slang35
-rw-r--r--tests/compute/default-initializer.slang.expected.txt4
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/compute/default-initializer.slang b/tests/compute/default-initializer.slang
new file mode 100644
index 000000000..1cda60084
--- /dev/null
+++ b/tests/compute/default-initializer.slang
@@ -0,0 +1,35 @@
+// default-initializer.slang
+
+// Confirm that a type with a default initializer gets
+// default-initialized where appropriate.
+
+//TEST(compute):COMPARE_COMPUTE:
+//TEST(compute):COMPARE_COMPUTE:-cpu
+
+struct Stuff
+{
+ int value;
+
+ __init()
+ {
+ value = 16;
+ }
+}
+
+int test(int value)
+{
+ Stuff s;
+ return value * s.value + value;
+}
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = outputBuffer[tid];
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/default-initializer.slang.expected.txt b/tests/compute/default-initializer.slang.expected.txt
new file mode 100644
index 000000000..d4cb1cc00
--- /dev/null
+++ b/tests/compute/default-initializer.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+11
+22
+33