diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-04-25 16:14:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-25 16:14:08 -0700 |
| commit | bc7231bbcf32819bed37012db3f01b34b5dd856a (patch) | |
| tree | 03d0c2f1f813b3e0c88e309add0e3c104ce97648 /tests | |
| parent | ed0681164d78591148781d08934676bfec63f9da (diff) | |
Fix unpackUnorm4x8 and unpackSnorm4x8 (#4033)
Fixes #4031
Each component of unpackU/Snorm4x8 had to be masked for 8bits.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-4031.slang | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/bugs/gh-4031.slang b/tests/bugs/gh-4031.slang new file mode 100644 index 000000000..015eeefc6 --- /dev/null +++ b/tests/bugs/gh-4031.slang @@ -0,0 +1,54 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -compute -entry computeMain -allow-glsl -profile cs_6_6 -use-dxil -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type -emit-spirv-directly + +//TEST_INPUT: ubuffer(data=[0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +bool Test_unpackUnorm4x8() +{ + vector<float,4> val; + val[0] = 1.f / 1.f; + val[1] = 1.f / 2.f; + val[2] = 1.f / 4.f; + val[3] = 1.f / 8.f; + + const uint32_t packed = packUnorm4x8(val); + const vector<float,4> unpacked = unpackUnorm4x8(packed); + + return true + && int(unpacked[0] * 1.f) == 1 + && int(unpacked[1] * 2.f) == 1 + && int(unpacked[2] * 4.f) == 1 + && int(unpacked[3] * 8.f) == 1 + ; +} + +bool Test_unpackSnorm4x8() +{ + vector<float,4> val; + val[0] = 1.f / 1.f; + val[1] = 1.f / 2.f; + val[2] = 1.f / 4.f; + val[3] = 1.f / 8.f; + + const uint32_t packed = packSnorm4x8(val); + const vector<float,4> unpacked = unpackSnorm4x8(packed); + + return true + && int(unpacked[0] * 1.f) == 1 + && int(unpacked[1] * 2.f) == 1 + && int(unpacked[2] * 4.f) == 1 + && int(unpacked[3] * 8.f) == 1 + ; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + //BUF:1 + outputBuffer[0] = int(true + && Test_unpackUnorm4x8() + && Test_unpackSnorm4x8() + ); +} |
