diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/rewriter-array-type.hlsl | 35 | ||||
| -rw-r--r-- | tests/compute/rewriter-array-type.hlsl.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/rewriter-types.hlsl | 34 | ||||
| -rw-r--r-- | tests/compute/rewriter-types.hlsl.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/rewriter-types.slang | 17 |
5 files changed, 94 insertions, 0 deletions
diff --git a/tests/compute/rewriter-array-type.hlsl b/tests/compute/rewriter-array-type.hlsl new file mode 100644 index 000000000..38a2abc1e --- /dev/null +++ b/tests/compute/rewriter-array-type.hlsl @@ -0,0 +1,35 @@ +//TEST(compute):HLSL_COMPUTE:-xslang -no-checking -xslang -use-ir + +//TEST_INPUT:cbuffer(data=[16 0 0 0 32 0 0 0]):dxbinding(0),glbinding(0) +//TEST_INPUT:cbuffer(data=[256 0 0 0 512 0 0 0 768 0 0 0 1024 0 0 0]):dxbinding(1),glbinding(1) +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +//TEST_INPUT:ubuffer(data=[90 91 92 93], stride=4):dxbinding(1),glbinding(1) +//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(2),glbinding(2) + +// Test the case of user code with that uses the "rewriter" mode +// (`-no-checking` flag) and that uses a type declared in +// imported code (that will compile via IR). Also test +// the case where such a type requires legalization. + +import rewriter_types; + +RWStructuredBuffer<int> outputBuffer : register(u0); + +cbuffer C +{ + MyHelper myHelpers[2]; +} + +cbuffer D +{ + Other others[2]; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal, myHelpers[1], others[tid]); + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/rewriter-array-type.hlsl.expected.txt b/tests/compute/rewriter-array-type.hlsl.expected.txt new file mode 100644 index 000000000..9bde1c082 --- /dev/null +++ b/tests/compute/rewriter-array-type.hlsl.expected.txt @@ -0,0 +1,4 @@ +120 +222 +324 +426 diff --git a/tests/compute/rewriter-types.hlsl b/tests/compute/rewriter-types.hlsl new file mode 100644 index 000000000..01da92997 --- /dev/null +++ b/tests/compute/rewriter-types.hlsl @@ -0,0 +1,34 @@ +//TEST(compute):HLSL_COMPUTE:-xslang -no-checking -xslang -use-ir + +//TEST_INPUT:cbuffer(data=[16]):dxbinding(0),glbinding(0) +//TEST_INPUT:cbuffer(data=[256]):dxbinding(1),glbinding(1) +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(1),glbinding(1) + +// Test the case of user code with that uses the "rewriter" mode +// (`-no-checking` flag) and that uses a type declared in +// imported code (that will compile via IR). Also test +// the case where such a type requires legalization. + +import rewriter_types; + +RWStructuredBuffer<int> outputBuffer : register(u0); + +cbuffer C +{ + MyHelper myHelper; +} + +cbuffer D +{ + Other other; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal, myHelper, other); + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/rewriter-types.hlsl.expected.txt b/tests/compute/rewriter-types.hlsl.expected.txt new file mode 100644 index 000000000..b68ea4a4f --- /dev/null +++ b/tests/compute/rewriter-types.hlsl.expected.txt @@ -0,0 +1,4 @@ +110 +112 +114 +116 diff --git a/tests/compute/rewriter-types.slang b/tests/compute/rewriter-types.slang new file mode 100644 index 000000000..a627b7891 --- /dev/null +++ b/tests/compute/rewriter-types.slang @@ -0,0 +1,17 @@ +//TEST_IGNORE_FILE: + +struct MyHelper +{ + int val; + RWStructuredBuffer<int> buf; +}; + +struct Other +{ + int val; +}; + +int test(int inVal, MyHelper helper, Other other) +{ + return inVal + helper.val + helper.buf[inVal] + other.val; +} |
