diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-02-08 09:02:55 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-08 09:02:55 -0500 |
| commit | c34a5e7ed2da03c9ceaddd167e4b0421246b0c25 (patch) | |
| tree | 078851510f93a4fdd62d819f30a86483a4165075 /tests | |
| parent | 23b36c5cb10c820c0b0f66000711d1013bc009f3 (diff) | |
Fix vector compares on GLSL targets (#833)
* * Make vector comparisons out correct functions on glsl
* Test for vector comparisons
* Typo fixes
* Glsl vector comparisons use functions.
* Added a coercion test.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/vec-compare.slang | 80 | ||||
| -rw-r--r-- | tests/bugs/vec-compare.slang.expected.txt | 17 |
2 files changed, 97 insertions, 0 deletions
diff --git a/tests/bugs/vec-compare.slang b/tests/bugs/vec-compare.slang new file mode 100644 index 000000000..0eaec0191 --- /dev/null +++ b/tests/bugs/vec-compare.slang @@ -0,0 +1,80 @@ +//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 0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4,4,1)] +void computeMain(uint3 pixelIndex : SV_DispatchThreadID) +{ + + // We will test floats, uints, and int vectors + // We need all comparisons < > <= >= == != + + int x = pixelIndex.x; + int y = pixelIndex.y; + + int uintBits; + { + uint2 v = { uint(x), uint(y) }; + uint2 test = { 1, 3 }; + + int bits = 0; + bits |= any(v < test) ? 0x01 : 0; + bits |= any(v <= test) ? 0x02 : 0; + bits |= any(v == test) ? 0x04 : 0; + bits |= any(v > test) ? 0x08 : 0; + bits |= any(v >= test) ? 0x10 : 0; + bits |= any(v != test) ? 0x20 : 0; + uintBits = bits; + } + + int intBits; + { + int2 v = { x, y }; + int2 test = { 2, 0 }; + + int bits = 0; + bits |= any(v < test) ? 0x01 : 0; + bits |= any(v <= test) ? 0x02 : 0; + bits |= any(v == test) ? 0x04 : 0; + bits |= any(v > test) ? 0x08 : 0; + bits |= any(v >= test) ? 0x10 : 0; + bits |= any(v != test) ? 0x20 : 0; + intBits = bits; + } + + int floatBits; + { + float2 v = { float(x), float(y) }; + float2 test = { 1, 2 }; + + int bits = 0; + bits |= any(v < test) ? 0x01 : 0; + bits |= any(v <= test) ? 0x02 : 0; + bits |= any(v == test) ? 0x04 : 0; + bits |= any(v > test) ? 0x08 : 0; + bits |= any(v >= test) ? 0x10 : 0; + bits |= any(v != test) ? 0x20 : 0; + floatBits = bits; + } + + int coerceBits; + { + float2 v = { float(x), float(y) }; + int2 test = { 1, 2 }; + + int bits = 0; + bits |= any(v < test) ? 0x01 : 0; + bits |= any(v <= test) ? 0x02 : 0; + bits |= any(v == test) ? 0x04 : 0; + bits |= any(v > test) ? 0x08 : 0; + bits |= any(v >= test) ? 0x10 : 0; + bits |= any(v != test) ? 0x20 : 0; + coerceBits = bits; + } + + outputBuffer[pixelIndex.x + pixelIndex.y * 4] = (coerceBits << 24) | (floatBits << 16) | (intBits << 8) | (uintBits); +}
\ No newline at end of file diff --git a/tests/bugs/vec-compare.slang.expected.txt b/tests/bugs/vec-compare.slang.expected.txt new file mode 100644 index 000000000..477414740 --- /dev/null +++ b/tests/bugs/vec-compare.slang.expected.txt @@ -0,0 +1,17 @@ +23233723 +37373737 +3B3B163B +3B3B3E3B +23233B23 +37373B37 +3B3B3E3B +3B3B383B +37373B23 +16163B37 +3E3E3E3B +3E3E383B +3B3B3B37 +3E3E3B16 +38383E3E +3838383E + |
