From 49c1b404e5e1cf7010855c1345d01c53e3e17ea5 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 3 Dec 2023 04:45:44 +0100 Subject: [PATCH] panfrost: Fix dual-source blending If dual blending is enabled, only 1 output is supported. Multiple outputs confuse the write combining pass in this case, leading to incorrect output and/or an assert failure in emit_fragment_store. The fix is straightforward, just skip the speculative emitting of multiple outputs in the case where dual source blending is enabled. This also adds an extra sanity check in `pan_nir_lower_zs_store` to check for only one blend store being present. Fixes: c65a9be421c ("panfrost: Preprocess shaders at CSO create time") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9487 Co-Authored-By: Eric R. Smith Part-of: --- src/gallium/drivers/panfrost/pan_shader.c | 2 +- src/panfrost/util/pan_lower_writeout.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_shader.c b/src/gallium/drivers/panfrost/pan_shader.c index 6493b85dd78..87104f19cb7 100644 --- a/src/gallium/drivers/panfrost/pan_shader.c +++ b/src/gallium/drivers/panfrost/pan_shader.c @@ -405,7 +405,7 @@ panfrost_create_shader_state(struct pipe_context *pctx, if (nir->info.stage == MESA_SHADER_FRAGMENT && nir->info.outputs_written & BITFIELD_BIT(FRAG_RESULT_COLOR)) { - NIR_PASS_V(nir, nir_lower_fragcolor, 8); + NIR_PASS_V(nir, nir_lower_fragcolor, nir->info.fs.color_is_dual_source ? 1 : 8); so->fragcolor_lowered = true; } diff --git a/src/panfrost/util/pan_lower_writeout.c b/src/panfrost/util/pan_lower_writeout.c index 56b33a495b0..eb528ce3bf3 100644 --- a/src/panfrost/util/pan_lower_writeout.c +++ b/src/panfrost/util/pan_lower_writeout.c @@ -106,6 +106,7 @@ pan_nir_lower_zs_store(nir_shader *nir) stores[1] = intr; writeout |= PAN_WRITEOUT_S; } else if (sem.dual_source_blend_index) { + assert(!stores[2]); /* there should be only 1 source for dual blending */ stores[2] = intr; writeout |= PAN_WRITEOUT_2; }