diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-01-31 17:40:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-31 14:40:46 -0800 |
| commit | 2ee06a4f2f3c995717bf18ba287a20e81d6141bc (patch) | |
| tree | ea5454fe367deba5ce451ce1e9139f592eaaca3c /tests | |
| parent | 922cd543d7b852fac4bd0b93d1a0c1a889c5c7e6 (diff) | |
64 bit doc and testing improvements (#1196)
* Improve 64 bit documentation.
Add a simple scalar test that doesn't use a double resource.
* Added int64-literal-problem.slang test.
Fixed some typos in test.
* More accurate description of the issues around use of double and dxc/fxc and intrinsics.
* Add clarity on what intrinsics are supported on d3d with double.
* Detail on intrinsics available on vk for double.
* Small improvements to 64bit-type-support.md documentation.
Diffstat (limited to 'tests')
10 files changed, 183 insertions, 3 deletions
diff --git a/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang new file mode 100644 index 000000000..02bffb7b1 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang @@ -0,0 +1,46 @@ +// It doesn't look like fxc, dxc, vk support double versions of many of the intrinsics, so they are disabled here. + +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type +// Fxc doesn't have double intrinsics available +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<double> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + double f = idx * (1.0f / (4.0f)); + + int it = 0; + double ft = 0.0l; + + // We known fmod is NOT supported on double on DX - only float is supported + // ft += int(((f % 0.11l) * 100) + 0.5l); + + ft += rcp(1.0l + f); + ft += sign(f - 0.5l); + + ft += saturate(f * 4 - 2.0l); + + ft += abs(f * 4 - 2.0l); + + ft += min(0.5l, f); + ft += max(f, 0.75l); + + ft += clamp(f, 0.1l, 0.3l); + + { + uint low, high; + asuint(f * 2.0l, low, high); + ft += asdouble(low, high); + } + + outputBuffer[idx] = ft; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt new file mode 100644 index 000000000..60826a847 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt @@ -0,0 +1,4 @@ +2.850000 +2.550000 +3.216667 +6.621429 diff --git a/tests/hlsl-intrinsic/scalar-double-simple.slang b/tests/hlsl-intrinsic/scalar-double-simple.slang new file mode 100644 index 000000000..9dc40c0e4 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double-simple.slang @@ -0,0 +1,29 @@ +// Here we are going to do a very simple calculation with double. +// For simplicity we are not going to use any intrinsics, and not use any resources that use double + +//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 -profile sm_6_0 -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 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + double f = idx * (1.0l / (4.0l)); + + f = 1.0l / f; + + { + uint low, high; + asuint(f * 2.0l, low, high); + outputBuffer[idx * 2 + 0] = low; + outputBuffer[idx * 2 + 1] = high; + } +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-double-simple.slang.expected.txt b/tests/hlsl-intrinsic/scalar-double-simple.slang.expected.txt new file mode 100644 index 000000000..44e0239c0 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double-simple.slang.expected.txt @@ -0,0 +1,8 @@ +0 +7FF00000 +0 +40200000 +0 +40100000 +55555555 +40055555 diff --git a/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang b/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang new file mode 100644 index 000000000..a48f80d74 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang @@ -0,0 +1,57 @@ +// This test is to see what intrinsics are available on VK + +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type + +// We don't want to run a cuda test here... +//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<double> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + double f = idx * (1.0f / (4.0f)); + + double ft = 0.0l; + + // fmod + ft += int(((f % 0.11l) * 100) + 0.5l); + + ft += rcp(1.0l + f); + ft += sign(f - 0.5l); + + ft += saturate(f * 4 - 2.0l); + + ft += sqrt(f); + ft += rsqrt(1.0l + f); + + ft += frac(f * 3); + ft += ceil(f * 5 - 3); + + ft += floor(f * 10 - 7); + ft += trunc(f * 7); + + ft += abs(f * 4 - 2.0l); + + ft += min(0.5l, f); + ft += max(f, 0.75l); + + ft += smoothstep(0.2l, 0.7l, f); + ft += lerp(-100.0l, 100.0l, f); + + ft += clamp(f, 0.1l, 0.3l); + + ft += step(f, 0.5l); + + { + uint low, high; + asuint(f * 2.0l, low, high); + ft += asdouble(low, high); + } + + outputBuffer[idx] = ft; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt b/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt new file mode 100644 index 000000000..6fd20cd00 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt @@ -0,0 +1,4 @@ +-105.150000 +-46.277573 +13.888270 +74.493383 diff --git a/tests/hlsl-intrinsic/scalar-double.slang b/tests/hlsl-intrinsic/scalar-double.slang index 8fa87f25a..705a6d88a 100644 --- a/tests/hlsl-intrinsic/scalar-double.slang +++ b/tests/hlsl-intrinsic/scalar-double.slang @@ -4,7 +4,7 @@ //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //DISABLE_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; diff --git a/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang new file mode 100644 index 000000000..71f058dc1 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang @@ -0,0 +1,32 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +// No support for int64_t on dx11 (no sm 6.0) +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +// No support with Dx12 with dxbc. Needs SM6.0 + dxil +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -profile cs_6_0 -dx12 -use-dxil +// GLSL notices the narrowing of a 64 bit literal into 32 bits and for it this is an error. +//DISABLE_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], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint idx = dispatchThreadID.x; + + // The multiply here will see dispatchThreadID.x as being uint, + // and then the multiply will coerce the lhs 0x7fff... into being uint, + // meaning 0x7fff.... will be interpreted as -1. int32_t(0x7ffff...) -> 0xffffffff + int64_t m = 0x7fffffffffffffff * idx; + + m += 0x7fffffffffffffff * int(idx); + + int64_t v = 0x7fffffffffffffff; + + int64_t r = m + v; + + outputBuffer[idx * 2] = int(uint64_t(r) >> 32); + outputBuffer[idx * 2 + 1] = int(r); +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt diff --git a/tests/hlsl-intrinsic/scalar-int64.slang b/tests/hlsl-intrinsic/scalar-int64.slang index 4ad805081..50d2b5816 100644 --- a/tests/hlsl-intrinsic/scalar-int64.slang +++ b/tests/hlsl-intrinsic/scalar-int64.slang @@ -1,11 +1,11 @@ //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -// No support for int64_t on dx11 (no sm 6.0) +// No support for int64_t on D3D11 (no sm 6.0) //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute // No support with Dx12 with dxbc. Needs SM6.0 + dxil //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -profile cs_6_0 -dx12 -use-dxil //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; |
