From: Marcin Ĺšlusarz Date: Tue, 10 Aug 2021 09:15:57 +0000 (+0200) Subject: nir: use nir_shader_instructions_pass in nir_lower_samplers X-Git-Tag: upstream/22.3.5~2392 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9dcff3ea53fb5e6e534c82a9f0016fc7b2535616;p=platform%2Fupstream%2Fmesa.git nir: use nir_shader_instructions_pass in nir_lower_samplers No functional changes. Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c index 48e28c9..b894adb 100644 --- a/src/compiler/nir/nir_lower_samplers.c +++ b/src/compiler/nir/nir_lower_samplers.c @@ -115,8 +115,13 @@ lower_tex_src_to_offset(nir_builder *b, } static bool -lower_sampler(nir_builder *b, nir_tex_instr *instr) +lower_sampler(nir_builder *b, nir_instr *instr_, UNUSED void *cb_data) { + if (instr_->type != nir_instr_type_tex) + return false; + + nir_tex_instr *instr = nir_instr_as_tex(instr_); + int texture_idx = nir_tex_instr_src_index(instr, nir_tex_src_texture_deref); @@ -139,40 +144,11 @@ lower_sampler(nir_builder *b, nir_tex_instr *instr) return true; } -static bool -lower_impl(nir_function_impl *impl) -{ - nir_builder b; - nir_builder_init(&b, impl); - bool progress = false; - - nir_foreach_block(block, impl) { - nir_foreach_instr(instr, block) { - if (instr->type == nir_instr_type_tex) - progress |= lower_sampler(&b, nir_instr_as_tex(instr)); - } - } - - if (progress) { - nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); - } else { - nir_metadata_preserve(impl, nir_metadata_all); - } - - return progress; -} - bool nir_lower_samplers(nir_shader *shader) { - bool progress = false; - - /* Next, lower derefs to offsets. */ - nir_foreach_function(function, shader) { - if (function->impl) - progress |= lower_impl(function->impl); - } - - return progress; + return nir_shader_instructions_pass(shader, lower_sampler, + nir_metadata_block_index | + nir_metadata_dominance, + NULL); }