diff options
Diffstat (limited to 'tests')
7 files changed, 143 insertions, 19 deletions
diff --git a/tests/hlsl-intrinsic/matrix-int-runtime-index.slang b/tests/hlsl-intrinsic/matrix-int-runtime-index.slang new file mode 100644 index 000000000..e3e2733b7 --- /dev/null +++ b/tests/hlsl-intrinsic/matrix-int-runtime-index.slang @@ -0,0 +1,37 @@ +// NOTE we can't test on VK/gl because we will output imat3 - and imat3 is not supported by glsl. +// NOTE we also can't do this test on fxc - as it does not allow runtime non constant indexing. + +//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 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +int horizontalAdd(int3 v) { return v.x + v.y + v.z; } + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + matrix<int, 3, 3> a = { { 0, 1, 2}, {2, 4, 6}, {7, 21, 32}}; + matrix<int, 3, 3> b = { { 4, 9, -1}, {-2, 4, 2}, {31, -3, 7}}; + + // Do a dynamic row swap + { + matrix<int, 3, 3> c = a; + + int row0 = idx % 3; + int row1 = (idx + 1) % 3; + int row2 = (idx + 2) % 3; + + a[row0] = c[0]; + a[row1] = c[1]; + a[row2] = c[2]; + } + + outputBuffer[idx] = (a[0].x & 15) + ((a[1].x & 15) << 4) + ((a[2].x & 15) << 8); +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/matrix-int-runtime-index.slang.expected.txt b/tests/hlsl-intrinsic/matrix-int-runtime-index.slang.expected.txt new file mode 100644 index 000000000..b31b447b8 --- /dev/null +++ b/tests/hlsl-intrinsic/matrix-int-runtime-index.slang.expected.txt @@ -0,0 +1,4 @@ +720 +207 +72 +720 diff --git a/tests/hlsl-intrinsic/matrix-int.slang b/tests/hlsl-intrinsic/matrix-int.slang new file mode 100644 index 000000000..cd69156a7 --- /dev/null +++ b/tests/hlsl-intrinsic/matrix-int.slang @@ -0,0 +1,46 @@ +// NOTE we can't test on VK/gl at the moment because we don't support intrinsics over matrices on that target currently + +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +int horizontalAdd(int3 v) { return v.x + v.y + v.z; } + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + matrix<int, 3, 3> a = { { 0, 1, 2}, {2, 4, 6}, {16, 21, 32}}; + matrix<int, 3, 3> b = { { 4, 9, -1}, {-2, 4, 2}, {31, -3, 7}}; + + matrix<int, 3, 3> t = {}; + + t += max(a, b); + t += min(a, b); + t += abs(a); + t += b % 5; + + { + int3 low = int3(3 + idx * 1); + int3 high = int3(5 + idx * 2); + + t += clamp(a, matrix<int, 3, 3>(low, low, low), matrix<int, 3, 3>(high, high, high)); + } + + // Access rows and elements, both read and write + + a[0].x ++; + a[1][1] --; + a[0] = a[1]; + a[2].y += b[1].x; + + t += a; + + outputBuffer[idx] = horizontalAdd(t[0]) + horizontalAdd(t[1]) + horizontalAdd(t[2]); +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/matrix-int.slang.expected.txt b/tests/hlsl-intrinsic/matrix-int.slang.expected.txt new file mode 100644 index 000000000..ad9f3b0fb --- /dev/null +++ b/tests/hlsl-intrinsic/matrix-int.slang.expected.txt @@ -0,0 +1,4 @@ +163 +16E +179 +184 diff --git a/tests/hlsl-intrinsic/vector-int-runtime-index.slang b/tests/hlsl-intrinsic/vector-int-runtime-index.slang new file mode 100644 index 000000000..bb704ed1a --- /dev/null +++ b/tests/hlsl-intrinsic/vector-int-runtime-index.slang @@ -0,0 +1,46 @@ +//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 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute, vulkan):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); + + int3 a = { idx + 10, idx - 9, idx + 3}; + int3 b = { idx * 2, idx * 3, idx * 10}; + + int3 t = { 0, 0, 0}; + + t += max(a, b); + t += min(a, b); + t += abs(a); + t += b % 5; + + t += clamp(a, int3(10), int3(23)); + + // Swizzle + t += a.zyx; + // Swizzle from scalar + t += idx.xxx; + + { + t += int3(a[idx % 3], a[0], b[2]); + } + + // Writes + { + int3 v = int3(b[(idx + 1) % 3], b[(idx + 2) % 3], b[(idx + 3) % 3]); + v[1] += v[0]; + v[idx & 1] += v[2]; + + t += v; + } + + outputBuffer[idx] = t.x + t.y + t.z; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/vector-int-runtime-index.slang.expected.txt b/tests/hlsl-intrinsic/vector-int-runtime-index.slang.expected.txt new file mode 100644 index 000000000..1ff551cc3 --- /dev/null +++ b/tests/hlsl-intrinsic/vector-int-runtime-index.slang.expected.txt @@ -0,0 +1,4 @@ +50 +84 +D0 +103 diff --git a/tests/hlsl-intrinsic/vector-int.slang b/tests/hlsl-intrinsic/vector-int.slang index 9a3f1faaa..d3327cfd0 100644 --- a/tests/hlsl-intrinsic/vector-int.slang +++ b/tests/hlsl-intrinsic/vector-int.slang @@ -1,6 +1,6 @@ //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute @@ -28,23 +28,6 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) t += a.zyx; // Swizzle from scalar t += idx.xxx; - -#if 0 - // TODO(JS): On C++ not all accesses are turned into getAt/setAt, so disable for now. - // Reads - { - t += int3(a[idx % 3], a[0], b[2]); - } - - // Writes - { - int3 v = int3(b[(idx + 1) % 3], b[(idx + 2) % 3], b[(idx + 3) % 3]); - v[1] += v[0]; - v[idx & 1] += v[2]; - - t += v; - } -#endif - + outputBuffer[idx] = t.x + t.y + t.z; }
\ No newline at end of file |
