From 5988ce80f580d57ce6718a61c86da6296caf0845 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 21 Jan 2020 18:49:44 -0500 Subject: HLSL intrinsic coverage (#1169) * 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. --- tests/compute/hlsl-scalar-float-intrinsic.slang | 88 --------------------- .../hlsl-scalar-float-intrinsic.slang.expected.txt | 4 - tests/hlsl-intrinsic/scalar-float.slang | 91 ++++++++++++++++++++++ .../hlsl-intrinsic/scalar-float.slang.expected.txt | 4 + 4 files changed, 95 insertions(+), 92 deletions(-) delete mode 100644 tests/compute/hlsl-scalar-float-intrinsic.slang delete mode 100644 tests/compute/hlsl-scalar-float-intrinsic.slang.expected.txt create mode 100644 tests/hlsl-intrinsic/scalar-float.slang create mode 100644 tests/hlsl-intrinsic/scalar-float.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/hlsl-scalar-float-intrinsic.slang b/tests/compute/hlsl-scalar-float-intrinsic.slang deleted file mode 100644 index 213db4b23..000000000 --- a/tests/compute/hlsl-scalar-float-intrinsic.slang +++ /dev/null @@ -1,88 +0,0 @@ -//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 outputBuffer; - -[numthreads(4, 1, 1)] -void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) -{ - int idx = int(dispatchThreadID.x); - - float f = idx * (1.0f / (4.0f - 1)); - - int it = 0; - float ft = 0.0f; - - // fmod - // ft += f % 0.5f; - - ft += sin(f); - ft += cos(f); - ft += tan(f); - - ft += asin(f); - ft += acos(f); - ft += atan(f); - - ft += atan2(f, 2.0); - - { - float sf, cf; - sincos(f, sf, cf); - - ft += sf; - ft += cf; - } - - ft += rcp(1.0 + f); - ft += sign(f - 0.5); - - ft += saturate(f * 4 - 2.0); - - ft += sqrt(f); - ft += rsqrt(1.0f + f); - - ft += exp2(f); - ft += exp(f); - - - ft += frac(f * 3); -// ft += ceil(f * 5 - 3); - - ft += floor(f * 10 - 7); - ft += trunc(f * 7); - - - ft += log(f + 10.0); - ft += log2(f * 3 + 2); - - // ft += log10(f * 10 + 4); - - ft += abs(f * 4 - 2.0f); - - ft += min(0.5, f); - ft += max(f, 0.75); - - ft += pow(0.5, f); - - ft += smoothstep(0.2, 0.7, f); - ft += lerp(-100, 100, f); - - - ft += clamp(f, 0.1, 0.3); - - ft += step(f, 0.5); - - int vi = asint(f - f) + idx; - - ft += float(vi); - - uint vu = asuint(f); - ft += asfloat(vu); - - outputBuffer[idx] = int(ft * 16); -} \ No newline at end of file diff --git a/tests/compute/hlsl-scalar-float-intrinsic.slang.expected.txt b/tests/compute/hlsl-scalar-float-intrinsic.slang.expected.txt deleted file mode 100644 index 04d17659c..000000000 --- a/tests/compute/hlsl-scalar-float-intrinsic.slang.expected.txt +++ /dev/null @@ -1,4 +0,0 @@ -FFFFFA3C -FFFFFEEC -3CA -8C1 diff --git a/tests/hlsl-intrinsic/scalar-float.slang b/tests/hlsl-intrinsic/scalar-float.slang new file mode 100644 index 000000000..a1982bbb8 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-float.slang @@ -0,0 +1,91 @@ +//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 outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + float f = idx * (1.0f / (4.0f)); + + int it = 0; + float ft = 0.0f; + + // fmod + ft += int(((f % 0.11f) * 100) + 0.5); + + ft += sin(f); + ft += cos(f); + ft += tan(f); + + ft += asin(f); + ft += acos(f); + ft += atan(f); + + ft += atan2(f, 2.0); + + { + float sf, cf; + sincos(f, sf, cf); + + ft += sf; + ft += cf; + } + + ft += rcp(1.0 + f); + ft += sign(f - 0.5); + + ft += saturate(f * 4 - 2.0); + + ft += sqrt(f); + ft += rsqrt(1.0f + f); + + ft += exp2(f); + ft += exp(f); + + + ft += frac(f * 3); + ft += ceil(f * 5 - 3); + + ft += floor(f * 10 - 7); + ft += trunc(f * 7); + + + ft += log(f + 10.0); + ft += log2(f * 3 + 2); + + { + float v[] = { 1, 10, 100, 1000 }; + ft += int(log10(v[idx]) + 0.5f); + } + + ft += abs(f * 4 - 2.0f); + + ft += min(0.5, f); + ft += max(f, 0.75); + + ft += pow(0.5, f); + + ft += smoothstep(0.2, 0.7, f); + ft += lerp(-100, 100, f); + + + ft += clamp(f, 0.1, 0.3); + + ft += step(f, 0.5); + + int vi = asint(f - f) + idx; + + ft += float(vi); + + uint vu = asuint(f); + ft += asfloat(vu); + + outputBuffer[idx] = int(ft * 16); +} \ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-float.slang.expected.txt b/tests/hlsl-intrinsic/scalar-float.slang.expected.txt new file mode 100644 index 000000000..3ad5914c4 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-float.slang.expected.txt @@ -0,0 +1,4 @@ +FFFFFA0C +FFFFFDF4 +1ED +5EE -- cgit v1.2.3