diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-775.slang | 32 | ||||
| -rw-r--r-- | tests/bugs/gh-775.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/init-list-defaults.slang | 37 | ||||
| -rw-r--r-- | tests/compute/init-list-defaults.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/struct-default-init.slang | 40 | ||||
| -rw-r--r-- | tests/compute/struct-default-init.slang.expected.txt | 4 |
6 files changed, 121 insertions, 0 deletions
diff --git a/tests/bugs/gh-775.slang b/tests/bugs/gh-775.slang new file mode 100644 index 000000000..f8125d7d4 --- /dev/null +++ b/tests/bugs/gh-775.slang @@ -0,0 +1,32 @@ +// gh-775.slang +//TEST(compute):COMPARE_COMPUTE: + +int test(int inVal) +{ + float4x4 identity = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + }; + + float4 v = float4(inVal, inVal+1, inVal+2, inVal+3); + + v = mul(identity, v); + + return int(dot(v, float4(1, 16, 256, 4096))); +} + +//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<int> outputBuffer : register(u0); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int inVal = int(tid); + int outVal = test(inVal); + + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/bugs/gh-775.slang.expected.txt b/tests/bugs/gh-775.slang.expected.txt new file mode 100644 index 000000000..611a87ad6 --- /dev/null +++ b/tests/bugs/gh-775.slang.expected.txt @@ -0,0 +1,4 @@ +3210 +4321 +5432 +6543 diff --git a/tests/compute/init-list-defaults.slang b/tests/compute/init-list-defaults.slang new file mode 100644 index 000000000..d8eb72b5b --- /dev/null +++ b/tests/compute/init-list-defaults.slang @@ -0,0 +1,37 @@ +// init-list-defaults.slang +//TEST(compute):COMPARE_COMPUTE: + +// Confirm that initializer lists correctly default-initialize elements past those specified. + +struct Test +{ + int4 a; + int b[4]; +} + +int test(int inVal) +{ + Test myArray[4] = { + { int4(1), { 2, 3} }, + { {4, 5, 6, }, { 7, } }, + }; + + return myArray[0].b[inVal] + + myArray[1].a[inVal]*16 + + myArray[inVal].a.x*256 + + (inVal+1)*4096; +} + +//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<int> outputBuffer : register(u0); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int inVal = int(tid); + int outVal = test(inVal); + + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/init-list-defaults.slang.expected.txt b/tests/compute/init-list-defaults.slang.expected.txt new file mode 100644 index 000000000..fa9fe4c8a --- /dev/null +++ b/tests/compute/init-list-defaults.slang.expected.txt @@ -0,0 +1,4 @@ +1142 +2453 +3060 +4000 diff --git a/tests/compute/struct-default-init.slang b/tests/compute/struct-default-init.slang new file mode 100644 index 000000000..9638465b0 --- /dev/null +++ b/tests/compute/struct-default-init.slang @@ -0,0 +1,40 @@ +// struct-default-init.slang +//TEST(compute):COMPARE_COMPUTE: + +struct Test +{ + int a; + int b = 1; + int c; + int d = 1 + 1; +} + +int test(int inVal) +{ + Test myArray[4] = { + { 3, 4, 5, 6 }, + { 7, 8, 9, }, + { 10, 11 }, + { 12, } + }; + + Test t = myArray[inVal]; + return t.a * 4096 + + t.b * 256 + + t.c * 16 + + t.d; +} + +//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<int> outputBuffer : register(u0); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int inVal = int(tid); + int outVal = test(inVal); + + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/struct-default-init.slang.expected.txt b/tests/compute/struct-default-init.slang.expected.txt new file mode 100644 index 000000000..39ce03d0a --- /dev/null +++ b/tests/compute/struct-default-init.slang.expected.txt @@ -0,0 +1,4 @@ +3456 +7892 +AB02 +C102 |
