diff --git a/src/gallium/drivers/lima/ir/lima_ir.h b/src/gallium/drivers/lima/ir/lima_ir.h index fbc3f2cd8c9..e8209b8e5af 100644 --- a/src/gallium/drivers/lima/ir/lima_ir.h +++ b/src/gallium/drivers/lima/ir/lima_ir.h @@ -63,7 +63,7 @@ bool ppir_compile_nir(struct lima_fs_compiled_shader *prog, struct nir_shader *n struct util_debug_callback *debug); struct ra_regs *ppir_regalloc_init(void *mem_ctx); -void lima_nir_lower_uniform_to_scalar(nir_shader *shader); +bool lima_nir_lower_uniform_to_scalar(nir_shader *shader); bool lima_nir_scale_trig(nir_shader *shader); bool lima_nir_lower_ftrunc(nir_shader *shader); bool lima_nir_lower_fdot(nir_shader *shader); diff --git a/src/gallium/drivers/lima/ir/lima_nir_lower_uniform_to_scalar.c b/src/gallium/drivers/lima/ir/lima_nir_lower_uniform_to_scalar.c index 39d501dbadc..896d08cd063 100644 --- a/src/gallium/drivers/lima/ir/lima_nir_lower_uniform_to_scalar.c +++ b/src/gallium/drivers/lima/ir/lima_nir_lower_uniform_to_scalar.c @@ -26,9 +26,12 @@ #include "nir_builder.h" #include "lima_ir.h" -static void -lower_load_uniform_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) +static bool +lower_load_uniform_to_scalar(nir_builder *b, nir_intrinsic_instr *intr, void *unused) { + if (intr->intrinsic != nir_intrinsic_load_uniform) + return false; + b->cursor = nir_before_instr(&intr->instr); nir_def *loads[4]; @@ -52,26 +55,15 @@ lower_load_uniform_to_scalar(nir_builder *b, nir_intrinsic_instr *intr) } nir_def_replace(&intr->def, nir_vec(b, loads, intr->num_components)); + + return true; } -void +bool lima_nir_lower_uniform_to_scalar(nir_shader *shader) { - nir_foreach_function_impl(impl, shader) { - nir_builder b = nir_builder_create(impl); - - nir_foreach_block(block, impl) { - nir_foreach_instr_safe(instr, block) { - if (instr->type != nir_instr_type_intrinsic) - continue; - - nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); - - if (intr->intrinsic != nir_intrinsic_load_uniform) - continue; - - lower_load_uniform_to_scalar(&b, intr); - } - } - } + return nir_shader_intrinsics_pass(shader, + lower_load_uniform_to_scalar, + nir_metadata_control_flow, + NULL); }