diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-01-28 12:28:05 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-28 12:28:05 -0500 |
| commit | df9dc5710725d00630831b77ca7005e390383aa6 (patch) | |
| tree | d75dd22c377ee4396c43e6d75518733589d1cf9a /tests | |
| parent | 41fde4b836dbab627f8643a5002b2b6dd0417211 (diff) | |
Feature/bit cast glsl (#808)
* First attempt at asint, asuint, asfloat intrinsics.
* Test with countbits
* Placing glsl definitions first makes them get picked up.
* Some more improvements around asint.
* Add support for vector versions of asint/asunit
* Fix some typos in asuint/asint intrinsics for glsl.
Simplified and increased coverage of as/u/int tests.
* Added bit-cast-double test.
Added notional support for asdouble bit casts to glsl - but couldn't test because glslang doesn't seem to support the extension.
* Try to get double bit casts working - doesn't work cos of block issue.
* Only output parents on intrinic replacement if return type is not void.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/bit-cast-double.slang | 21 | ||||
| -rw-r--r-- | tests/compute/bit-cast-double.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/bit-cast.slang | 42 | ||||
| -rw-r--r-- | tests/compute/bit-cast.slang.expected.txt | 12 |
4 files changed, 79 insertions, 0 deletions
diff --git a/tests/compute/bit-cast-double.slang b/tests/compute/bit-cast-double.slang new file mode 100644 index 000000000..27d0b48cf --- /dev/null +++ b/tests/compute/bit-cast-double.slang @@ -0,0 +1,21 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + double d = double(dispatchThreadID.x); + + uint hi, low; + asuint(d, low, hi); + + // Reconstruct + double r = asdouble(low, hi); + + outputBuffer[dispatchThreadID.x] = int(r); +}
\ No newline at end of file diff --git a/tests/compute/bit-cast-double.slang.expected.txt b/tests/compute/bit-cast-double.slang.expected.txt new file mode 100644 index 000000000..bc856dafa --- /dev/null +++ b/tests/compute/bit-cast-double.slang.expected.txt @@ -0,0 +1,4 @@ +0 +1 +2 +3 diff --git a/tests/compute/bit-cast.slang b/tests/compute/bit-cast.slang new file mode 100644 index 000000000..050b84f30 --- /dev/null +++ b/tests/compute/bit-cast.slang @@ -0,0 +1,42 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + const int id = asint(dispatchThreadID.x); + + { + int4 i4 = int4(id, id + 1, id + 2, id + 3); + uint3 u3 = asuint(i4.xyz); + int2 i2 = asint(u3.xy); + uint u1 = asuint(i2.x); + + outputBuffer[id + 0] = int(u1); + } + + { + uint v = asuint(id); + uint4 u4 = uint4(v, v + 1, v + 2, v + 3); + int3 i3 = asint(u4.xyz); + uint2 u2 = asuint(i3.xy); + int i1 = asint(u2.x); + + outputBuffer[id + 4] = i1; + } + + { + int4 i4 = int4(id, id + 1, id + 2, id + 3); + float4 f4 = asfloat(i4); + uint3 u3 = asuint(f4.xyz); + float2 f2 = asfloat(u3.xy); + int i1 = asint(id); + + outputBuffer[id + 8] = i1; + } +}
\ No newline at end of file diff --git a/tests/compute/bit-cast.slang.expected.txt b/tests/compute/bit-cast.slang.expected.txt new file mode 100644 index 000000000..f5414793f --- /dev/null +++ b/tests/compute/bit-cast.slang.expected.txt @@ -0,0 +1,12 @@ +0 +1 +2 +3 +0 +1 +2 +3 +0 +1 +2 +3
\ No newline at end of file |
