From cb201e92aca12f1962124bac2e8220c3651d8dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Fri, 6 Aug 2021 15:36:18 +0200 Subject: [PATCH] glsl: use nir_shader_instructions_pass in gl_nir_lower_samplers_as_deref No functional changes. Reviewed-by: Alyssa Rosenzweig Part-of: --- .../glsl/gl_nir_lower_samplers_as_deref.c | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c index 99622c189ff..25d7acdbdbe 100644 --- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c +++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c @@ -353,36 +353,23 @@ lower_intrinsic(nir_intrinsic_instr *instr, } static bool -lower_impl(nir_function_impl *impl, struct lower_samplers_as_deref_state *state) +lower_instr(nir_builder *b, nir_instr *instr, void *cb_data) { - nir_builder b; - nir_builder_init(&b, impl); - bool progress = false; + struct lower_samplers_as_deref_state *state = cb_data; - nir_foreach_block(block, impl) { - nir_foreach_instr(instr, block) { - if (instr->type == nir_instr_type_tex) - progress |= lower_sampler(nir_instr_as_tex(instr), state, &b); - else if (instr->type == nir_instr_type_intrinsic) - progress |= lower_intrinsic(nir_instr_as_intrinsic(instr), state, &b); - } - } + if (instr->type == nir_instr_type_tex) + return lower_sampler(nir_instr_as_tex(instr), state, b); - if (progress) { - nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); - } else { - nir_metadata_preserve(impl, nir_metadata_all); - } + if (instr->type == nir_instr_type_intrinsic) + return lower_intrinsic(nir_instr_as_intrinsic(instr), state, b); - return progress; + return false; } bool gl_nir_lower_samplers_as_deref(nir_shader *shader, const struct gl_shader_program *shader_program) { - bool progress = false; struct lower_samplers_as_deref_state state; state.shader = shader; @@ -390,10 +377,10 @@ gl_nir_lower_samplers_as_deref(nir_shader *shader, state.remap_table = _mesa_hash_table_create(NULL, _mesa_hash_string, _mesa_key_string_equal); - nir_foreach_function(function, shader) { - if (function->impl) - progress |= lower_impl(function->impl, &state); - } + bool progress = nir_shader_instructions_pass(shader, lower_instr, + nir_metadata_block_index | + nir_metadata_dominance, + &state); /* keys are freed automatically by ralloc */ _mesa_hash_table_destroy(state.remap_table, NULL);