From 53f9cdac9b15eb705fd8e7ba7e9bfed61a51c2e0 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 20 Mar 2024 16:16:24 +0100 Subject: [PATCH] radeonsi: preserve alpha if needed in kill_ps_outputs_cb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some features (eg: ALPHA_TEST) relies on the alpha value being exported even if color_mask.a = false. In these cases, override comp_mask to preserve the alpha value. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10841 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10845 Fixes: 6d2a7f53 ("radeonsi: decrease NUM_INTERP if export formats/colormask eliminated PS inputs") Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_shader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 7f1191f2567..fc201d6a521 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1707,6 +1707,11 @@ static bool kill_ps_outputs_cb(struct nir_builder *b, nir_instr *instr, void *_k assert(nir_intrinsic_component(intr) == 0); unsigned cb_shader_mask = ac_get_cb_shader_mask(key->ps.part.epilog.spi_shader_col_format); + /* Preserve alpha if ALPHA_TESTING is enabled. */ + if (key->ps.part.epilog.alpha_func != PIPE_FUNC_ALWAYS || + key->ps.part.epilog.alpha_to_coverage_via_mrtz) + cb_shader_mask |= 1 << 3; + /* If COLOR is broadcasted to multiple color buffers, combine their masks. */ if (location == FRAG_RESULT_COLOR) { for (unsigned i = 1; i <= key->ps.part.epilog.last_cbuf; i++)