summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/inout.slang47
-rw-r--r--tests/compute/inout.slang.expected.txt4
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/compute/inout.slang b/tests/compute/inout.slang
new file mode 100644
index 000000000..d56887cf9
--- /dev/null
+++ b/tests/compute/inout.slang
@@ -0,0 +1,47 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(0),glbinding(0),out
+
+// Test that we correctly support both `out`
+// and `inout` function parameters.
+
+void testOut(int x, out int y)
+{
+ y = x;
+}
+
+void testInOut(int x, in out int y)
+{
+ y = y + x;
+}
+
+void testInout(int x, inout int y)
+{
+ y = y + x;
+}
+
+int test(int inVal)
+{
+ int x0 = inVal;
+ int x1;
+
+ testOut(x0, x1);
+
+ int x2 = x0;
+ testInOut(x1, x2);
+
+ int x3 = x0;
+ testInout(x2, x3);
+
+ return x3;
+}
+
+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/inout.slang.expected.txt b/tests/compute/inout.slang.expected.txt
new file mode 100644
index 000000000..f9d85ed42
--- /dev/null
+++ b/tests/compute/inout.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+3
+6
+9