From 60a7c9688cfb184f45ce7bcc132dc2da286ef95e Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 21 Sep 2023 09:42:53 +0200 Subject: [PATCH] radeonsi: emit framebuffer state after allocating cmask MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit tex->cmask_base_address_reg and tex->cb_color_info are used in si_emit_framebuffer_state so we have to re-emit the state when they're modified. It's not done in si_alloc_separate_cmask because it cannot update framebuffer.dirty_cbufs. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9830 Cc: mesa-stable Reviewed-by: Yogesh Mohan Marimuthu Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_clear.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c index c6051a3..4ad97bc 100644 --- a/src/gallium/drivers/radeonsi/si_clear.c +++ b/src/gallium/drivers/radeonsi/si_clear.c @@ -108,6 +108,9 @@ static bool si_alloc_separate_cmask(struct si_screen *sscreen, struct si_texture if (tex->cmask_buffer == NULL) return false; + /* These 2 fields are part of the framebuffer state but dirtying the atom + * will be done by the caller. + */ tex->cmask_base_address_reg = tex->cmask_buffer->gpu_address >> 8; tex->cb_color_info |= S_028C70_FAST_CLEAR(1); @@ -709,6 +712,7 @@ static void si_fast_clear(struct si_context *sctx, unsigned *buffers, bool too_small = tex->buffer.b.b.nr_samples <= 1 && fb_too_small; bool eliminate_needed = false; bool fmask_decompress_needed = false; + bool need_dirtying_fb = false; /* Try to clear DCC first, otherwise try CMASK. */ if (vi_dcc_enabled(tex, level)) { @@ -805,6 +809,7 @@ static void si_fast_clear(struct si_context *sctx, unsigned *buffers, uint64_t cmask_offset = 0; unsigned clear_size = 0; + bool had_cmask_buffer = tex->cmask_buffer != NULL; if (sctx->gfx_level >= GFX10) { assert(level == 0); @@ -857,6 +862,10 @@ static void si_fast_clear(struct si_context *sctx, unsigned *buffers, cmask_offset, clear_size, 0); clear_types |= SI_CLEAR_TYPE_CMASK; eliminate_needed = true; + /* If we allocated a cmask buffer for this tex we need to re-emit + * the fb state. + */ + need_dirtying_fb = !had_cmask_buffer; } if ((eliminate_needed || fmask_decompress_needed) && @@ -877,7 +886,7 @@ static void si_fast_clear(struct si_context *sctx, unsigned *buffers, /* There are no clear color registers on GFX11. */ assert(sctx->gfx_level < GFX11); - if (si_set_clear_color(tex, fb->cbufs[i]->format, color)) { + if (si_set_clear_color(tex, fb->cbufs[i]->format, color) || need_dirtying_fb) { sctx->framebuffer.dirty_cbufs |= 1 << i; si_mark_atom_dirty(sctx, &sctx->atoms.s.framebuffer); } -- 2.7.4