From de56ebadceac8499753ba85bb712cd76168f8837 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 9 Mar 2018 10:27:20 +0100 Subject: [PATCH] nir/spirv: add support for the SubgroupVoteKHR SPIR-V capability This capability is required for the VK_EXT_shader_subgroup_vote extension. Reviewed-by: Connor Abbott --- src/compiler/spirv/spirv_to_nir.c | 4 ++++ src/compiler/spirv/vtn_subgroup.c | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index fdcc9fdb96b..fe9fe6932e7 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -3653,6 +3653,7 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, spv_check_supported(subgroup_basic, cap); break; + case SpvCapabilitySubgroupVoteKHR: case SpvCapabilityGroupNonUniformVote: spv_check_supported(subgroup_vote, cap); break; @@ -4524,6 +4525,9 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode, case SpvOpGroupNonUniformLogicalXor: case SpvOpGroupNonUniformQuadBroadcast: case SpvOpGroupNonUniformQuadSwap: + case SpvOpSubgroupAllKHR: + case SpvOpSubgroupAnyKHR: + case SpvOpSubgroupAllEqualKHR: vtn_handle_subgroup(b, opcode, w, count); break; diff --git a/src/compiler/spirv/vtn_subgroup.c b/src/compiler/spirv/vtn_subgroup.c index 1b066f9340c..dfa8347b292 100644 --- a/src/compiler/spirv/vtn_subgroup.c +++ b/src/compiler/spirv/vtn_subgroup.c @@ -189,18 +189,24 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode, case SpvOpGroupNonUniformAll: case SpvOpGroupNonUniformAny: - case SpvOpGroupNonUniformAllEqual: { + case SpvOpGroupNonUniformAllEqual: + case SpvOpSubgroupAllKHR: + case SpvOpSubgroupAnyKHR: + case SpvOpSubgroupAllEqualKHR: { vtn_fail_if(val->type->type != glsl_bool_type(), "OpGroupNonUniform(All|Any|AllEqual) must return a bool"); nir_intrinsic_op op; switch (opcode) { case SpvOpGroupNonUniformAll: + case SpvOpSubgroupAllKHR: op = nir_intrinsic_vote_all; break; case SpvOpGroupNonUniformAny: + case SpvOpSubgroupAnyKHR: op = nir_intrinsic_vote_any; break; - case SpvOpGroupNonUniformAllEqual: { + case SpvOpGroupNonUniformAllEqual: + case SpvOpSubgroupAllEqualKHR: { switch (glsl_get_base_type(val->type->type)) { case GLSL_TYPE_FLOAT: case GLSL_TYPE_DOUBLE: @@ -222,8 +228,14 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode, unreachable("Unhandled opcode"); } - nir_ssa_def *src0 = vtn_ssa_value(b, w[4])->def; - + nir_ssa_def *src0; + if (opcode == SpvOpGroupNonUniformAll || + opcode == SpvOpGroupNonUniformAny || + opcode == SpvOpGroupNonUniformAllEqual) { + src0 = vtn_ssa_value(b, w[4])->def; + } else { + src0 = vtn_ssa_value(b, w[3])->def; + } nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->nb.shader, op); intrin->num_components = src0->num_components; -- 2.30.2