diff options
author | Jason Ekstrand <[email protected]> | 2019-07-11 13:04:05 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-07-16 16:05:16 +0000 |
commit | ce3af830cb6b1b6225a85aeade927db6c736412f (patch) | |
tree | 8523ea17dc4d2a6c27a967c331ad8a2e025c6b98 /src | |
parent | 758fdce9feef7d337d972a0e349d49429f1e696e (diff) |
nir/lower_subgroups: Use the new generic NIR lowering helpers
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir_lower_subgroups.c | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index 70d736b040f..eca441fcf39 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -286,10 +286,18 @@ lower_shuffle(nir_builder *b, nir_intrinsic_instr *intrin, } } +static bool +lower_subgroups_filter(const nir_instr *instr, const void *_options) +{ + return instr->type == nir_instr_type_intrinsic; +} + static nir_ssa_def * -lower_subgroups_intrin(nir_builder *b, nir_intrinsic_instr *intrin, - const nir_lower_subgroups_options *options) +lower_subgroups_instr(nir_builder *b, nir_instr *instr, void *_options) { + const nir_lower_subgroups_options *options = _options; + + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { case nir_intrinsic_vote_any: case nir_intrinsic_vote_all: @@ -479,51 +487,12 @@ lower_subgroups_intrin(nir_builder *b, nir_intrinsic_instr *intrin, return NULL; } -static bool -lower_subgroups_impl(nir_function_impl *impl, - const nir_lower_subgroups_options *options) -{ - nir_builder b; - nir_builder_init(&b, impl); - bool progress = false; - - nir_foreach_block(block, impl) { - nir_foreach_instr_safe(instr, block) { - if (instr->type != nir_instr_type_intrinsic) - continue; - - nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - b.cursor = nir_before_instr(instr); - - nir_ssa_def *lower = lower_subgroups_intrin(&b, intrin, options); - if (!lower) - continue; - - nir_ssa_def_rewrite_uses(&intrin->dest.ssa, nir_src_for_ssa(lower)); - nir_instr_remove(instr); - progress = true; - } - } - - return progress; -} - bool nir_lower_subgroups(nir_shader *shader, const nir_lower_subgroups_options *options) { - bool progress = false; - - nir_foreach_function(function, shader) { - if (!function->impl) - continue; - - if (lower_subgroups_impl(function->impl, options)) { - progress = true; - nir_metadata_preserve(function->impl, nir_metadata_block_index | - nir_metadata_dominance); - } - } - - return progress; + return nir_shader_lower_instructions(shader, + lower_subgroups_filter, + lower_subgroups_instr, + (void *)options); } |