diff options
Diffstat (limited to 'tests')
12 files changed, 263 insertions, 0 deletions
diff --git a/tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang b/tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang new file mode 100644 index 000000000..ea94e6ffa --- /dev/null +++ b/tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang @@ -0,0 +1,55 @@ +// inout-param-opaque-type-in-struct.slang + +// Test that a function/method can have an `out` parameter of +// aggregate type that includes an opaque type + +//TEST(compute):COMPARE_COMPUTE: + +struct Things +{ + int first; + RWStructuredBuffer<int> rest; +} + +//TEST_INPUT:set C = new { {1, ubuffer(data=[2 3 4 5], stride=4)}, {6, ubuffer(data=[7 8 9 10], stride=4)} } +cbuffer C +{ + Things gX; + Things gY; +} + +void swap( + inout Things a, + inout Things b) +{ + Things t = a; + a = b; + b = t; +} + +int eval(Things t, int val) +{ + return t.first*256 + t.rest[val]; +} + +int test(int val) +{ + Things f = gX; + Things g = gY; + + swap(f, g); + + return (eval(f,val) << 16) + eval(g,val); +} + +//TEST_INPUT:set gOutput = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> gOutput; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + gOutput[tid] = outVal; +} diff --git a/tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang.expected.txt b/tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang.expected.txt new file mode 100644 index 000000000..43533c76f --- /dev/null +++ b/tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang.expected.txt @@ -0,0 +1,4 @@ +6070102 +6080103 +6090104 +60A0105 diff --git a/tests/language-feature/types/opaque/inout-param-opaque-type.slang b/tests/language-feature/types/opaque/inout-param-opaque-type.slang new file mode 100644 index 000000000..682f89fd0 --- /dev/null +++ b/tests/language-feature/types/opaque/inout-param-opaque-type.slang @@ -0,0 +1,42 @@ +// inout-param-opaque-type.slang + +// Test that a function/method can have an `out` parameter of opaque type + +//TEST(compute):COMPARE_COMPUTE: + +//TEST_INPUT:set gX = ubuffer(data=[16 17 18 19], stride=4) +RWStructuredBuffer<int> gX; + +//TEST_INPUT:set gY = ubuffer(data=[3 6 9 12], stride=4) +RWStructuredBuffer<int> gY; + +void swap( + inout RWStructuredBuffer<int> a, + inout RWStructuredBuffer<int> b) +{ + RWStructuredBuffer<int> t = a; + a = b; + b = t; +} + +int test(int val) +{ + RWStructuredBuffer<int> f = gX; + RWStructuredBuffer<int> g = gY; + + swap(f, g); + + return f[val] * 256 + g[val]; +} + +//TEST_INPUT:set gOutput = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> gOutput; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + gOutput[tid] = outVal; +} diff --git a/tests/language-feature/types/opaque/inout-param-opaque-type.slang.expected.txt b/tests/language-feature/types/opaque/inout-param-opaque-type.slang.expected.txt new file mode 100644 index 000000000..81cf98393 --- /dev/null +++ b/tests/language-feature/types/opaque/inout-param-opaque-type.slang.expected.txt @@ -0,0 +1,4 @@ +310 +611 +912 +C13 diff --git a/tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang b/tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang new file mode 100644 index 000000000..a6c645c01 --- /dev/null +++ b/tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang @@ -0,0 +1,39 @@ +// out-opaque-type-in-struct.slang + +// Test that a function/method can have an `out` parameter of +// aggregate type that includes an opaque type + +//TEST(compute):COMPARE_COMPUTE: + +struct Things +{ + int first; + RWStructuredBuffer<int> rest; +} + +//TEST_INPUT:set gThings = new Things { 1, ubuffer(data=[2 3 4 5], stride=4) } +ConstantBuffer<Things> gThings; + +void getThings(out Things outThings) +{ + outThings = gThings; +} + +int test(int val) +{ + Things things; + getThings(things); + return things.first * (16 << val) + things.rest[val]; +} + +//TEST_INPUT:set gOutput = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> gOutput; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + gOutput[tid] = outVal; +} diff --git a/tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang.expected.txt b/tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang.expected.txt new file mode 100644 index 000000000..553843b5d --- /dev/null +++ b/tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang.expected.txt @@ -0,0 +1,4 @@ +12 +23 +44 +85 diff --git a/tests/language-feature/types/opaque/out-param-opaque-type.slang b/tests/language-feature/types/opaque/out-param-opaque-type.slang new file mode 100644 index 000000000..3ac7c0d6f --- /dev/null +++ b/tests/language-feature/types/opaque/out-param-opaque-type.slang @@ -0,0 +1,33 @@ +// out-opaque-type.slang + +// Test that a function/method can have an `out` parameter of opaque type + +//TEST(compute):COMPARE_COMPUTE: + +//TEST_INPUT:set gThings = ubuffer(data=[16 17 18 19], stride=4) +RWStructuredBuffer<int> gThings; + + +void getThings(out RWStructuredBuffer<int> things) +{ + things = gThings; +} + +int test(int val) +{ + RWStructuredBuffer<int> t; + getThings(t); + return t[val]; +} + +//TEST_INPUT:set gOutput = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> gOutput; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + gOutput[tid] = outVal; +} diff --git a/tests/language-feature/types/opaque/out-param-opaque-type.slang.expected.txt b/tests/language-feature/types/opaque/out-param-opaque-type.slang.expected.txt new file mode 100644 index 000000000..a0d427709 --- /dev/null +++ b/tests/language-feature/types/opaque/out-param-opaque-type.slang.expected.txt @@ -0,0 +1,4 @@ +10 +11 +12 +13 diff --git a/tests/language-feature/types/opaque/return-opaque-type-in-struct.slang b/tests/language-feature/types/opaque/return-opaque-type-in-struct.slang new file mode 100644 index 000000000..2687af1c3 --- /dev/null +++ b/tests/language-feature/types/opaque/return-opaque-type-in-struct.slang @@ -0,0 +1,38 @@ +// return-opaque-type-in-struct.slang + +// Test that a function/method can return a value of +// aggregate type that includes an opaque type + +//TEST(compute):COMPARE_COMPUTE: + +struct Things +{ + int first; + RWStructuredBuffer<int> rest; +} + +//TEST_INPUT:set gThings = new Things { 1, ubuffer(data=[2 3 4 5], stride=4) } +ConstantBuffer<Things> gThings; + +Things getThings() +{ + return gThings; +} + +int test(int val) +{ + let things = getThings(); + return things.first * (16 << val) + things.rest[val]; +} + +//TEST_INPUT:set gOutput = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> gOutput; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + gOutput[tid] = outVal; +} diff --git a/tests/language-feature/types/opaque/return-opaque-type-in-struct.slang.expected.txt b/tests/language-feature/types/opaque/return-opaque-type-in-struct.slang.expected.txt new file mode 100644 index 000000000..553843b5d --- /dev/null +++ b/tests/language-feature/types/opaque/return-opaque-type-in-struct.slang.expected.txt @@ -0,0 +1,4 @@ +12 +23 +44 +85 diff --git a/tests/language-feature/types/opaque/return-opaque-type.slang b/tests/language-feature/types/opaque/return-opaque-type.slang new file mode 100644 index 000000000..83d4376ba --- /dev/null +++ b/tests/language-feature/types/opaque/return-opaque-type.slang @@ -0,0 +1,32 @@ +// return-opaque-type.slang + +// Test that a function/method can return a value of an opaque type. + +//TEST(compute):COMPARE_COMPUTE: + +struct Stuff +{ + RWStructuredBuffer<int> things; + + RWStructuredBuffer<int> getThings() { return things; } +} + +//TEST_INPUT:set gStuff = new Stuff { ubuffer(data=[16 17 18 19], stride=4) } +ConstantBuffer<Stuff> gStuff; + +int test(int val) +{ + return gStuff.getThings()[val]; +} + +//TEST_INPUT:set gOutput = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> gOutput; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + gOutput[tid] = outVal; +} diff --git a/tests/language-feature/types/opaque/return-opaque-type.slang.expected.txt b/tests/language-feature/types/opaque/return-opaque-type.slang.expected.txt new file mode 100644 index 000000000..a0d427709 --- /dev/null +++ b/tests/language-feature/types/opaque/return-opaque-type.slang.expected.txt @@ -0,0 +1,4 @@ +10 +11 +12 +13 |
