diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-03-06 15:46:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-06 12:46:35 -0800 |
| commit | b94a12b91086ea004d9b78fa8a14fd4726af9e76 (patch) | |
| tree | 0e7a78c3e684ebb12204a981b6a6e90f6c4cde44 /tests | |
| parent | 18be2d81fd2740d3f0c06fc407cff1702b93d468 (diff) | |
Wave intrinsics for Vector and Matrix types (#1262)
* Update slang-binaries to verison with SPIR-V version support.
* Support vec and matrix Wave intrinsics on vk.
Added wave-vector.slang test
Add wave-diverge.slang test
Add support for more wave intrinsics to vk.
* Test out Wave intrinsic support for matrices.
* Remove matrix glsl intrinsics -> not available.
Fix some typo.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/hlsl-intrinsic/wave-active-product.slang | 2 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-diverge.slang | 26 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-diverge.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-matrix.slang | 37 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-matrix.slang.expected.txt | 8 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-vector.slang | 29 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-vector.slang.expected.txt | 8 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave.slang | 2 |
8 files changed, 114 insertions, 2 deletions
diff --git a/tests/hlsl-intrinsic/wave-active-product.slang b/tests/hlsl-intrinsic/wave-active-product.slang index 351df1635..ca3fdcb77 100644 --- a/tests/hlsl-intrinsic/wave-active-product.slang +++ b/tests/hlsl-intrinsic/wave-active-product.slang @@ -2,7 +2,7 @@ //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/hlsl-intrinsic/wave-diverge.slang b/tests/hlsl-intrinsic/wave-diverge.slang new file mode 100644 index 000000000..ab83a1553 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-diverge.slang @@ -0,0 +1,26 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + int value = 0; + + if (idx == 2) + { + // diverge + return; + } + + value = WaveActiveMin(idx + 1); + + outputBuffer[idx] = value; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/wave-diverge.slang.expected.txt b/tests/hlsl-intrinsic/wave-diverge.slang.expected.txt new file mode 100644 index 000000000..68b8a88e2 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-diverge.slang.expected.txt @@ -0,0 +1,4 @@ +1 +1 +0 +1 diff --git a/tests/hlsl-intrinsic/wave-matrix.slang b/tests/hlsl-intrinsic/wave-matrix.slang new file mode 100644 index 000000000..022182164 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-matrix.slang @@ -0,0 +1,37 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(8, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + const int idx = int(dispatchThreadID.x); + + // NOTE! dxc only supports bit ops on uint and associated types NOT int + // Also GLSL does not have built in support for int matrices. So we'll just try with float for now + // GLSL does not support matrix types for Wave like intrinsics + + matrix<int, 2, 2> v0 = matrix<int, 2, 2>(idx + 1, idx + 2, idx + 3, idx + 4); + matrix<float, 2, 2> v1 = matrix<float, 2, 2>(v0) + matrix<float, 2, 2>(1, 1, 1, 1); + + + matrix<uint, 2, 2> uv0 = matrix<uint, 2, 2>(v0[0][0], v0[0][1], v0[1][0], v0[0][1]); + + matrix<int, 2, 2> r0 = WaveActiveSum(v0); + matrix<float, 2, 2> r1 = WaveActiveSum(v1); + matrix<uint, 2, 2> r2 = WaveActiveBitXor(uv0); + matrix<uint, 2, 2> r3 = WaveActiveBitOr(uv0); + matrix<uint, 2, 2> r4 = WaveActiveBitAnd(uv0); + + matrix<uint, 2, 2> r5 = r2 + r3 + r4; + matrix<int, 2, 2> r6 = matrix<int, 2, 2>(r5[0][0], r5[0][1], r5[1][0], r5[1][1]); + + matrix<int, 2, 2> r = r0 + matrix<int, 2, 2>(r1) + r6; + + outputBuffer[idx] = r[0][0] + r[0][1] + r[1][0] + r[1][1]; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/wave-matrix.slang.expected.txt b/tests/hlsl-intrinsic/wave-matrix.slang.expected.txt new file mode 100644 index 000000000..23f9285c3 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-matrix.slang.expected.txt @@ -0,0 +1,8 @@ +1EC +1EC +1EC +1EC +1EC +1EC +1EC +1EC diff --git a/tests/hlsl-intrinsic/wave-vector.slang b/tests/hlsl-intrinsic/wave-vector.slang new file mode 100644 index 000000000..808f0c5f6 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-vector.slang @@ -0,0 +1,29 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(8, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + const int idx = int(dispatchThreadID.x); + + int2 v0 = int2(idx + 1, idx + 2); + float2 v1 = float2(idx + 2, idx + 3); + // NOTE! dxc only supports bit ops on uint and associated types NOT int + uint2 uv0 = v0; + + int2 r0 = WaveActiveSum(v0); + float2 r1 = WaveActiveSum(v1); + int2 r2 = WaveActiveBitXor(uv0); + int2 r3 = WaveActiveBitOr(uv0); + int2 r4 = WaveActiveBitAnd(uv0); + + int2 r = r0 + int2(r1) + r2 + r3 + r4; + + outputBuffer[idx] = r.x + r.y; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/wave-vector.slang.expected.txt b/tests/hlsl-intrinsic/wave-vector.slang.expected.txt new file mode 100644 index 000000000..eb6984bb6 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-vector.slang.expected.txt @@ -0,0 +1,8 @@ +D6 +D6 +D6 +D6 +D6 +D6 +D6 +D6 diff --git a/tests/hlsl-intrinsic/wave.slang b/tests/hlsl-intrinsic/wave.slang index 9fc9dc26d..d8273080c 100644 --- a/tests/hlsl-intrinsic/wave.slang +++ b/tests/hlsl-intrinsic/wave.slang @@ -2,7 +2,7 @@ //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; |
