diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/mutating-and-inout.slang | 49 | ||||
| -rw-r--r-- | tests/compute/mutating-and-inout.slang.expected.txt | 4 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/compute/mutating-and-inout.slang b/tests/compute/mutating-and-inout.slang new file mode 100644 index 000000000..d06933b77 --- /dev/null +++ b/tests/compute/mutating-and-inout.slang @@ -0,0 +1,49 @@ +// mutating-and-inout.slang + +// Test that calling a `[mutating]` method on an `inout` function parameter works. + +//TEST(compute):COMPARE_COMPUTE: + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +struct A +{ + int x; + + [mutating] void doThings(inout int y) + { + int tmp = x; + x = y; + y = tmp; + } +} + +int doThings(inout A a, int val) +{ + a.doThings(val); + return val; +} + +int test(int val) +{ + A a = { val }; + int b = val ^ 3; + + int c = doThings(a, b); + + int result = 0; + result = result*16 + a.x; + result = result*16 + b; + result = result*16 + c; + + return result; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 tid : SV_DispatchThreadID) +{ + int val = tid.x; + val = test(val); + outputBuffer[tid.x] = val; +} diff --git a/tests/compute/mutating-and-inout.slang.expected.txt b/tests/compute/mutating-and-inout.slang.expected.txt new file mode 100644 index 000000000..6c842da55 --- /dev/null +++ b/tests/compute/mutating-and-inout.slang.expected.txt @@ -0,0 +1,4 @@ +330 +221 +112 +3 |
