From: Marcin Ślusarz Date: Tue, 10 Aug 2021 11:53:40 +0000 (+0200) Subject: zink: use nir_shader_instructions_pass in nir_lower_dynamic_bo_access X-Git-Tag: upstream/22.3.5~19338 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1b7a5fad6c6773f7ee71844eb92d000f098e797;p=platform%2Fupstream%2Fmesa.git zink: use nir_shader_instructions_pass in nir_lower_dynamic_bo_access Changes: - nir_metadata_preserve(..., nir_metadata_dominance) is called only when pass makes progress - nir_metadata_preserve(..., nir_metadata_all) is called when pass doesn't make progress Signed-off-by: Marcin Ślusarz Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/gallium/drivers/zink/nir_lower_dynamic_bo_access.c b/src/gallium/drivers/zink/nir_lower_dynamic_bo_access.c index 864030a..157b67b 100644 --- a/src/gallium/drivers/zink/nir_lower_dynamic_bo_access.c +++ b/src/gallium/drivers/zink/nir_lower_dynamic_bo_access.c @@ -91,8 +91,15 @@ generate_store_ssbo_ssa_def(nir_builder *b, nir_intrinsic_instr *instr, nir_ssa_ } static bool -lower_dynamic_bo_access_instr(nir_intrinsic_instr *instr, nir_builder *b) +lower_dynamic_bo_access_instr(nir_builder *b, + nir_instr *instr_, + UNUSED void *cb_data) { + if (instr_->type != nir_instr_type_intrinsic) + return false; + + nir_intrinsic_instr *instr = nir_instr_as_intrinsic(instr_); + if (instr->intrinsic != nir_intrinsic_load_ubo && instr->intrinsic != nir_intrinsic_load_ubo_vec4 && instr->intrinsic != nir_intrinsic_get_ssbo_size && @@ -137,24 +144,8 @@ lower_dynamic_bo_access_instr(nir_intrinsic_instr *instr, nir_builder *b) bool nir_lower_dynamic_bo_access(nir_shader *shader) { - bool progress = false; - - nir_foreach_function(function, shader) { - if (function->impl) { - nir_builder builder; - nir_builder_init(&builder, function->impl); - nir_foreach_block(block, function->impl) { - nir_foreach_instr_safe(instr, block) { - if (instr->type == nir_instr_type_intrinsic) - progress |= lower_dynamic_bo_access_instr( - nir_instr_as_intrinsic(instr), - &builder); - } - } - - nir_metadata_preserve(function->impl, nir_metadata_dominance); - } - } - - return progress; + return nir_shader_instructions_pass(shader, + lower_dynamic_bo_access_instr, + nir_metadata_dominance, + NULL); }