diff options
author | Jason Ekstrand <[email protected]> | 2017-08-28 19:55:34 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-03-07 12:13:47 -0800 |
commit | 0e893356fef37fa290522e47ec0172da03a3341e (patch) | |
tree | b2894f0bbbfe3b4fab6284bb19938a963c3ce563 /src/compiler/nir | |
parent | d792f3d4cd49a5022dbdc00770a3144907640dfd (diff) |
nir/lower_subgroups: Add scalarizing for vote_eq
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir_lower_subgroups.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index 3753b5e6427..c97849bf8ba 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -111,6 +111,32 @@ lower_read_invocation_to_scalar(nir_builder *b, nir_intrinsic_instr *intrin) } static nir_ssa_def * +lower_vote_eq_to_scalar(nir_builder *b, nir_intrinsic_instr *intrin) +{ + assert(intrin->src[0].is_ssa); + nir_ssa_def *value = intrin->src[0].ssa; + + nir_ssa_def *result = NULL; + for (unsigned i = 0; i < intrin->num_components; i++) { + nir_intrinsic_instr *chan_intrin = + nir_intrinsic_instr_create(b->shader, intrin->intrinsic); + nir_ssa_dest_init(&chan_intrin->instr, &chan_intrin->dest, + 1, intrin->dest.ssa.bit_size, NULL); + chan_intrin->num_components = 1; + chan_intrin->src[0] = nir_src_for_ssa(nir_channel(b, value, i)); + nir_builder_instr_insert(b, &chan_intrin->instr); + + if (result) { + result = nir_iand(b, result, &chan_intrin->dest.ssa); + } else { + result = &chan_intrin->dest.ssa; + } + } + + return result; +} + +static nir_ssa_def * lower_subgroups_intrin(nir_builder *b, nir_intrinsic_instr *intrin, const nir_lower_subgroups_options *options) { @@ -125,6 +151,9 @@ lower_subgroups_intrin(nir_builder *b, nir_intrinsic_instr *intrin, case nir_intrinsic_vote_ieq: if (options->lower_vote_trivial) return nir_imm_int(b, NIR_TRUE); + + if (options->lower_to_scalar && intrin->num_components > 1) + return lower_vote_eq_to_scalar(b, intrin); break; case nir_intrinsic_load_subgroup_size: |