From 5570043af3bfb7729f1bb8462d401f1fdf95e4cd Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Mon, 8 Mar 2021 12:06:46 +0100 Subject: [PATCH] GLSL: Add support for Logical subgroup ops. Completely missed these ... --- .../comp/subgroups.nocompat.invalid.vk.comp.vk | 6 ++++++ shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp | 7 +++++++ spirv_glsl.cpp | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk b/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk index 6d288574..f3fa6dd0 100644 --- a/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk +++ b/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk @@ -62,6 +62,9 @@ void main() uvec4 anded = subgroupAnd(ballot_value); uvec4 ored = subgroupOr(ballot_value); uvec4 xored = subgroupXor(ballot_value); + bvec4 anded_b = subgroupAnd(equal(ballot_value, uvec4(42u))); + bvec4 ored_b = subgroupOr(equal(ballot_value, uvec4(42u))); + bvec4 xored_b = subgroupXor(equal(ballot_value, uvec4(42u))); added = subgroupInclusiveAdd(added); iadded = subgroupInclusiveAdd(iadded); multiplied = subgroupInclusiveMul(multiplied); @@ -102,6 +105,9 @@ void main() anded = subgroupClusteredAnd(anded, 4u); ored = subgroupClusteredOr(ored, 4u); xored = subgroupClusteredXor(xored, 4u); + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0)); diff --git a/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp b/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp index 68fc74f9..a73a2312 100644 --- a/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp +++ b/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp @@ -72,6 +72,9 @@ void main() uvec4 anded = subgroupAnd(ballot_value); uvec4 ored = subgroupOr(ballot_value); uvec4 xored = subgroupXor(ballot_value); + bvec4 anded_b = subgroupAnd(equal(ballot_value, uvec4(42))); + bvec4 ored_b = subgroupOr(equal(ballot_value, uvec4(42))); + bvec4 xored_b = subgroupXor(equal(ballot_value, uvec4(42))); added = subgroupInclusiveAdd(added); iadded = subgroupInclusiveAdd(iadded); @@ -117,6 +120,10 @@ void main() ored = subgroupClusteredOr(ored, 4u); xored = subgroupClusteredXor(xored, 4u); + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); + // quad vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 1b857074..cd35b62c 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -7646,6 +7646,9 @@ void CompilerGLSL::emit_subgroup_op(const Instruction &i) case OpGroupNonUniformBitwiseAnd: case OpGroupNonUniformBitwiseOr: case OpGroupNonUniformBitwiseXor: + case OpGroupNonUniformLogicalAnd: + case OpGroupNonUniformLogicalOr: + case OpGroupNonUniformLogicalXor: { auto operation = static_cast(ops[3]); if (operation == GroupOperationClusteredReduce) @@ -7802,6 +7805,9 @@ case OpGroupNonUniform##op: \ GLSL_GROUP_OP(BitwiseAnd, And) GLSL_GROUP_OP(BitwiseOr, Or) GLSL_GROUP_OP(BitwiseXor, Xor) + GLSL_GROUP_OP(LogicalAnd, And) + GLSL_GROUP_OP(LogicalOr, Or) + GLSL_GROUP_OP(LogicalXor, Xor) #undef GLSL_GROUP_OP #undef GLSL_GROUP_OP_CAST // clang-format on @@ -12148,6 +12154,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) case OpGroupNonUniformBitwiseAnd: case OpGroupNonUniformBitwiseOr: case OpGroupNonUniformBitwiseXor: + case OpGroupNonUniformLogicalAnd: + case OpGroupNonUniformLogicalOr: + case OpGroupNonUniformLogicalXor: case OpGroupNonUniformQuadSwap: case OpGroupNonUniformQuadBroadcast: emit_subgroup_op(instruction);