diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-03-14 16:21:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-14 16:21:03 -0400 |
| commit | c8e36bd128a29654b2ec145038da9e132330581b (patch) | |
| tree | 950ce7c3bb1cc235f97ceb982643e99245c87e16 /tests/bugs | |
| parent | 04416431993b1d5efa8eac759a16832d40c2a159 (diff) | |
Hotfix/bool fix (#907)
* * Handle ! for bool vector in glsl
* Handle operators that have a boolean return value
* || or && take bool
* * Add comment in bool-op.slang test about doing || or && on vector types not supported for GLSL targets
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/bool-op.slang | 77 | ||||
| -rw-r--r-- | tests/bugs/bool-op.slang.expected.txt | 16 |
2 files changed, 93 insertions, 0 deletions
diff --git a/tests/bugs/bool-op.slang b/tests/bugs/bool-op.slang new file mode 100644 index 000000000..1388ef8f1 --- /dev/null +++ b/tests/bugs/bool-op.slang @@ -0,0 +1,77 @@ +// enum.slang +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +// Confirm operations that produce bools - such as comparisons, or && ||, ! work correctly + +//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(16, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x;; + + uint uv = tid; + int iv = int(tid); + + bool2 bv2 = { tid & 1, tid > 10 }; + + float2 f2 = { float(tid), float(tid + 1) }; + + bool bv = tid > 6; + let not_bv2 = !bv2; + + int r = 0; + if (bv) + { + r |= 0x0001; + } + if (!bv) + { + r |= 0x0002; + } + + if (iv) + { + r|= 0x0004; + } + if (!iv) + { + r|= 0x0008; + } + + if (uv) + { + r |= 0x0010; + } + if (!uv) + { + r |= 0x0020; + } + + if (all(bv2)) + { + r |= 0x0040; + } + if (all(not_bv2)) + { + r |= 0x0080; + } + + if (any(!f2)) + { + r |= 0x0100; + } + + // TODO(JS): Support on GLSL targets + // This doesn't currently work on GLSL targets, and because there + // do not appear to be any vector bitwise operations. Could be achieved + // by deconstructing, and reconstructing the vec result + /* if (all(f2 || bv2)) + { + r |= 0x0200; + } */ + + outputBuffer[tid] = r; +}
\ No newline at end of file diff --git a/tests/bugs/bool-op.slang.expected.txt b/tests/bugs/bool-op.slang.expected.txt new file mode 100644 index 000000000..08b720347 --- /dev/null +++ b/tests/bugs/bool-op.slang.expected.txt @@ -0,0 +1,16 @@ +1AA +16 +96 +16 +96 +16 +96 +15 +95 +15 +95 +55 +15 +55 +15 +55 |
