From 04416431993b1d5efa8eac759a16832d40c2a159 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 13 Mar 2019 16:31:29 -0400 Subject: Add support for vector/scalar compares for GLSL (#903) * * leftSide and rightSide set op to nullptr, before was just uninitialized * Added support for GLSL for vector/scalar comparisons * Added test * * Remove unneeded precedence code. * Simplify function to _maybeEmitGLSLCast * * Take into account precedence & closing of brackets in same way as function call, if function call used for vector comparison (as on GLSL) --- tests/compute/vector-scalar-compare.slang | 25 ++++++++++++++++++++++ .../vector-scalar-compare.slang.expected.txt | 16 ++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/compute/vector-scalar-compare.slang create mode 100644 tests/compute/vector-scalar-compare.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/vector-scalar-compare.slang b/tests/compute/vector-scalar-compare.slang new file mode 100644 index 000000000..e8e701dbc --- /dev/null +++ b/tests/compute/vector-scalar-compare.slang @@ -0,0 +1,25 @@ +//TEST(compute):COMPARE_COMPUTE:-dx12 -compute +//TEST(compute):COMPARE_COMPUTE:-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 + +// Test doing vector comparisons +RWStructuredBuffer outputBuffer; + +[numthreads(4, 4, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint2 threadInGroup = dispatchThreadID.xy; + + int r = 0; + if(all((threadInGroup & 1) == 0)) + { + r = 0; + } + else + { + r = 1; + } + + int index = threadInGroup.x + threadInGroup.y * 4; + outputBuffer[index] = r; +} \ No newline at end of file diff --git a/tests/compute/vector-scalar-compare.slang.expected.txt b/tests/compute/vector-scalar-compare.slang.expected.txt new file mode 100644 index 000000000..1424570bc --- /dev/null +++ b/tests/compute/vector-scalar-compare.slang.expected.txt @@ -0,0 +1,16 @@ +0 +1 +0 +1 +1 +1 +1 +1 +0 +1 +0 +1 +1 +1 +1 +1 -- cgit v1.2.3