diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-01-22 11:06:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-22 11:06:20 -0500 |
| commit | c74a700681b0be44a74f16b0f9eaad05bba159d2 (patch) | |
| tree | 6855baa362b336f17e199f1ad33242e73e98f6a7 /tests | |
| parent | 346a56749c99e4e05d24ad6217f34dd5d44af189 (diff) | |
WIP HLSL intrinsic coverage (#1171)
* Added hlsl-intrinsic test folder.
Enabled ceil as works across targets.
* log10 support.
* Fix float % on CPU/CUDA to match HLSL which is fmod (not fremainder).
* Added log10 tests back to scalar-float.slang
* Don't add the ( for $Sx - it's clearer what's going on without it.
* Works on CUDA/CPU. Problem with asint/asuint do not seem to be found.
* Only asuint exists for double.
* Support countbits on CUDA and C++.
* Fix typo in C++ population count.
* First pass at int vector intrinsic tests.
* Swizzle for int.
* Bit cast tests on CUDA.
* Fix warning on gcc.
* Fix bit-cast-double execution on CUDA.
* scalar-int test working on gcc release.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/hlsl-intrinsic/bit-cast-double.slang (renamed from tests/compute/bit-cast-double.slang) | 3 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/bit-cast-double.slang.expected.txt (renamed from tests/compute/bit-cast-double.slang.expected.txt) | 0 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/bit-cast.slang (renamed from tests/compute/bit-cast.slang) | 1 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/bit-cast.slang.expected.txt (renamed from tests/compute/bit-cast.slang.expected.txt) | 0 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/scalar-int.slang | 25 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/scalar-int.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/scalar-uint.slang | 26 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/scalar-uint.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/vector-int.slang | 50 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/vector-int.slang.expected.txt | 4 |
10 files changed, 116 insertions, 1 deletions
diff --git a/tests/compute/bit-cast-double.slang b/tests/hlsl-intrinsic/bit-cast-double.slang index 6b0925a58..b52c9de2b 100644 --- a/tests/compute/bit-cast-double.slang +++ b/tests/hlsl-intrinsic/bit-cast-double.slang @@ -1,7 +1,8 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-slang -vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -cuda -compute //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/compute/bit-cast-double.slang.expected.txt b/tests/hlsl-intrinsic/bit-cast-double.slang.expected.txt index bc856dafa..bc856dafa 100644 --- a/tests/compute/bit-cast-double.slang.expected.txt +++ b/tests/hlsl-intrinsic/bit-cast-double.slang.expected.txt diff --git a/tests/compute/bit-cast.slang b/tests/hlsl-intrinsic/bit-cast.slang index a8fec61e3..4ecd911d7 100644 --- a/tests/compute/bit-cast.slang +++ b/tests/hlsl-intrinsic/bit-cast.slang @@ -2,6 +2,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer diff --git a/tests/compute/bit-cast.slang.expected.txt b/tests/hlsl-intrinsic/bit-cast.slang.expected.txt index f5414793f..f5414793f 100644 --- a/tests/compute/bit-cast.slang.expected.txt +++ b/tests/hlsl-intrinsic/bit-cast.slang.expected.txt diff --git a/tests/hlsl-intrinsic/scalar-int.slang b/tests/hlsl-intrinsic/scalar-int.slang new file mode 100644 index 000000000..7fccc8645 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-int.slang @@ -0,0 +1,25 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//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); + + int ti =0; + + ti += max(2, idx); + ti += min(idx, 1); + ti += abs(idx - 2); + ti += (idx * 3) % 5; + + ti += clamp(idx * 10, 11, 23); + + outputBuffer[idx] = ti; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-int.slang.expected.txt b/tests/hlsl-intrinsic/scalar-int.slang.expected.txt new file mode 100644 index 000000000..4efe33dc6 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-int.slang.expected.txt @@ -0,0 +1,4 @@ +F +12 +18 +20 diff --git a/tests/hlsl-intrinsic/scalar-uint.slang b/tests/hlsl-intrinsic/scalar-uint.slang new file mode 100644 index 000000000..eb16bb3b8 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-uint.slang @@ -0,0 +1,26 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//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) +{ + uint idx = dispatchThreadID.x; + + uint ti = 0; + + ti += max(2, idx); + ti += min(idx, 1); + ti += (idx * 3) %5; + + ti += clamp(idx * 10, 11, 23); + + ti += countbits(idx * 13); + + outputBuffer[idx] = ti; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-uint.slang.expected.txt b/tests/hlsl-intrinsic/scalar-uint.slang.expected.txt new file mode 100644 index 000000000..1a7befbe1 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-uint.slang.expected.txt @@ -0,0 +1,4 @@ +D +14 +1B +23 diff --git a/tests/hlsl-intrinsic/vector-int.slang b/tests/hlsl-intrinsic/vector-int.slang new file mode 100644 index 000000000..9a3f1faaa --- /dev/null +++ b/tests/hlsl-intrinsic/vector-int.slang @@ -0,0 +1,50 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//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; + +#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 diff --git a/tests/hlsl-intrinsic/vector-int.slang.expected.txt b/tests/hlsl-intrinsic/vector-int.slang.expected.txt new file mode 100644 index 000000000..e4c658883 --- /dev/null +++ b/tests/hlsl-intrinsic/vector-int.slang.expected.txt @@ -0,0 +1,4 @@ +3C +5B +75 +8F |
