vc4: Use nir_shader_intrinsics_pass(..) for vc4_nir_lower_blend(..)

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35205>
This commit is contained in:
Christian Gmeiner 2025-05-28 12:49:23 +02:00 committed by Marge Bot
parent f2b03202e7
commit 2e6c565b77

View file

@ -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.