From 90819b9b0ea0ea8ffe4bd34100ee12dce8f63ebf Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Fri, 11 Sep 2020 13:07:48 +0200 Subject: [PATCH] nir/subgroups: Replace lower_vote_eq_to_ballot with lower_vote_eq Lower it to a vote instead of a ballot. This was only used for AMD, and in that case they're pretty much the same. However Qualcomm has a vote builtin, which we want to use instead of ballots. Reviewed-by: Jason Ekstrand Acked-by: Rhys Perry Part-of: --- src/amd/vulkan/radv_shader.c | 2 +- src/compiler/nir/nir.h | 2 +- src/compiler/nir/nir_lower_subgroups.c | 10 ++++------ src/gallium/drivers/radeonsi/si_shader_nir.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 9eebd2853ba..8e655a2f0ea 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -642,7 +642,7 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module * .lower_subgroup_masks = 1, .lower_shuffle = 1, .lower_shuffle_to_32bit = 1, - .lower_vote_eq_to_ballot = 1, + .lower_vote_eq = 1, .lower_quad_broadcast_dynamic = 1, .lower_quad_broadcast_dynamic_to_const = gfx7minus, .lower_shuffle_to_swizzle_amd = 1, diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index c4796179232..1471623cf53 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4728,7 +4728,7 @@ typedef struct nir_lower_subgroups_options { uint8_t ballot_bit_size; bool lower_to_scalar:1; bool lower_vote_trivial:1; - bool lower_vote_eq_to_ballot:1; + bool lower_vote_eq:1; bool lower_subgroup_masks:1; bool lower_shuffle:1; bool lower_shuffle_to_32bit:1; diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index b0703bc94df..3f0126dbada 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -178,8 +178,7 @@ lower_vote_eq_to_scalar(nir_builder *b, nir_intrinsic_instr *intrin) } static nir_ssa_def * -lower_vote_eq_to_ballot(nir_builder *b, nir_intrinsic_instr *intrin, - const nir_lower_subgroups_options *options) +lower_vote_eq(nir_builder *b, nir_intrinsic_instr *intrin) { assert(intrin->src[0].is_ssa); nir_ssa_def *value = intrin->src[0].ssa; @@ -203,8 +202,7 @@ lower_vote_eq_to_ballot(nir_builder *b, nir_intrinsic_instr *intrin, } } - nir_ssa_def *ballot = nir_ballot(b, 1, options->ballot_bit_size, nir_inot(b, all_eq)); - return nir_ieq(b, ballot, nir_imm_intN_t(b, 0, options->ballot_bit_size)); + return nir_vote_all(b, 1, all_eq); } static nir_ssa_def * @@ -386,8 +384,8 @@ lower_subgroups_instr(nir_builder *b, nir_instr *instr, void *_options) if (options->lower_vote_trivial) return nir_imm_true(b); - if (options->lower_vote_eq_to_ballot) - return lower_vote_eq_to_ballot(b, intrin, options); + if (options->lower_vote_eq) + return lower_vote_eq(b, intrin); if (options->lower_to_scalar && intrin->num_components > 1) return lower_vote_eq_to_scalar(b, intrin); diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 98c2a0cf08d..ae1192d97ed 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -824,7 +824,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir) .lower_to_scalar = true, .lower_subgroup_masks = true, .lower_vote_trivial = false, - .lower_vote_eq_to_ballot = true, + .lower_vote_eq = true, .lower_elect = true, }; NIR_PASS_V(nir, nir_lower_subgroups, &subgroups_options);