diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-01-22 09:26:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-22 09:26:03 -0500 |
| commit | 346a56749c99e4e05d24ad6217f34dd5d44af189 (patch) | |
| tree | 2183c2ccd7fc1b2d7e281374267e0fc3c0b18ee8 | |
| parent | 5988ce80f580d57ce6718a61c86da6296caf0845 (diff) | |
Testing double based intrinsics (#1170)
* 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.
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
| -rw-r--r-- | tests/hlsl-intrinsic/scalar-double.slang | 90 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/scalar-double.slang.expected.txt | 4 |
2 files changed, 94 insertions, 0 deletions
diff --git a/tests/hlsl-intrinsic/scalar-double.slang b/tests/hlsl-intrinsic/scalar-double.slang new file mode 100644 index 000000000..8fa87f25a --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double.slang @@ -0,0 +1,90 @@ +// 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 +//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_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); + + double f = idx * (1.0f / (4.0f)); + + int it = 0; + double ft = 0.0l; + + // fmod + ft += int(((f % 0.11l) * 100) + 0.5l); + + ft += sin(f); + ft += cos(f); + ft += tan(f); + + ft += asin(f); + ft += acos(f); + ft += atan(f); + + ft += atan2(f, 2.0l); + + { + double sf, cf; + sincos(f, sf, cf); + + ft += sf; + ft += cf; + } + + 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 += 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.0l); + ft += log2(f * 3 + 2); + + { + double v[] = { 1, 10, 100, 1000 }; + ft += int(log10(v[idx]) + 0.5l); + } + + ft += abs(f * 4 - 2.0l); + + ft += min(0.5l, f); + ft += max(f, 0.75l); + + ft += pow(0.5l, f); + + 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] = int(ft * 16); +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/scalar-double.slang.expected.txt b/tests/hlsl-intrinsic/scalar-double.slang.expected.txt new file mode 100644 index 000000000..2fedcded2 --- /dev/null +++ b/tests/hlsl-intrinsic/scalar-double.slang.expected.txt @@ -0,0 +1,4 @@ +FFFFFA0C +FFFFFDE8 +1D5 +5CA |
