From 2e6c565b7774bd4100f0a02e9ddf0a1e947fa3ee Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Wed, 28 May 2025 12:49:23 +0200 Subject: [PATCH] vc4: Use nir_shader_intrinsics_pass(..) for vc4_nir_lower_blend(..) Signed-off-by: Christian Gmeiner Reviewed-by: Juan A. Suarez Part-of: --- src/gallium/drivers/vc4/vc4_nir_lower_blend.c | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c index 35992840ed4..a5753101751 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c @@ -565,38 +565,32 @@ vc4_nir_lower_blend_instr(struct vc4_compile *c, nir_builder *b, } static bool -vc4_nir_lower_blend_block(nir_block *block, struct vc4_compile *c) +vc4_nir_lower_blend_impl(nir_builder *b, nir_intrinsic_instr *intr, void *data) { - 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_store_output) - continue; + struct vc4_compile *c = data; - unsigned loc = nir_intrinsic_io_semantics(intr).location; + if (intr->intrinsic != nir_intrinsic_store_output) + return false; - if (loc != FRAG_RESULT_COLOR && - loc != FRAG_RESULT_DATA0) { - continue; - } + unsigned loc = nir_intrinsic_io_semantics(intr).location; - nir_builder b = nir_builder_at(nir_before_instr(&intr->instr)); - vc4_nir_lower_blend_instr(c, &b, intr); + if (loc != FRAG_RESULT_COLOR && + loc != FRAG_RESULT_DATA0) { + return false; } + + b->cursor = nir_before_instr(&intr->instr); + + vc4_nir_lower_blend_instr(c, b, intr); + return true; } void vc4_nir_lower_blend(nir_shader *s, struct vc4_compile *c) { - nir_foreach_function_impl(impl, s) { - nir_foreach_block(block, impl) { - vc4_nir_lower_blend_block(block, c); - } - - nir_progress(true, impl, nir_metadata_control_flow); - } + nir_shader_intrinsics_pass(s, vc4_nir_lower_blend_impl, + nir_metadata_control_flow, c); /* If we didn't do alpha-to-coverage on the output color, we still * need to pass glSampleMask() through.