From bfcee149eda243d3b0f3091ee6819dbdcbd7d33a Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 9 Aug 2024 15:39:43 +0200 Subject: [PATCH] radeonsi: don't always update shader coherency draw call counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bug report has a sequence that looks like this: * set tex as framebuffer * dispatch a compute shader that doesn't use tex * dispatch a compute shader that uses it Since we were updating the counters at step 2, step 3 failed to realize that calling si_make_CB_shader_coherent was needed. While at it, this commit splits the draw call tracking counter in 2: one for CB, one for DB. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11638 Cc: mesa-stable Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_compute.c | 18 +++++++++++------- src/gallium/drivers/radeonsi/si_pipe.h | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 35a9fd0114b..ee249d94228 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -1186,20 +1186,24 @@ static void si_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info si_check_dirty_buffers_textures(sctx); if (sctx->has_graphics) { - if (sctx->last_num_draw_calls != sctx->num_draw_calls) { + if (sctx->num_draw_calls_sh_coherent.with_cb != sctx->num_draw_calls || + sctx->num_draw_calls_sh_coherent.with_db != sctx->num_draw_calls) { si_update_fb_dirtiness_after_rendering(sctx); - sctx->last_num_draw_calls = sctx->num_draw_calls; if (sctx->force_shader_coherency.with_cb || - si_check_needs_implicit_sync(sctx, RADEON_USAGE_CB_NEEDS_IMPLICIT_SYNC)) + si_check_needs_implicit_sync(sctx, RADEON_USAGE_CB_NEEDS_IMPLICIT_SYNC)) { + sctx->num_draw_calls_sh_coherent.with_cb = sctx->num_draw_calls; si_make_CB_shader_coherent(sctx, 0, sctx->framebuffer.CB_has_shader_readable_metadata, sctx->framebuffer.all_DCC_pipe_aligned); + } - if (sctx->gfx_level == GFX12 && - (sctx->force_shader_coherency.with_db || - si_check_needs_implicit_sync(sctx, RADEON_USAGE_DB_NEEDS_IMPLICIT_SYNC))) - si_make_DB_shader_coherent(sctx, 0, false, false); + if (sctx->gfx_level == GFX12 && + (sctx->force_shader_coherency.with_db || + si_check_needs_implicit_sync(sctx, RADEON_USAGE_DB_NEEDS_IMPLICIT_SYNC))) { + sctx->num_draw_calls_sh_coherent.with_db = sctx->num_draw_calls; + si_make_DB_shader_coherent(sctx, 0, false, false); + } } if (sctx->gfx_level < GFX11) diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index abcc6236f6e..c07ba4276e1 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1020,7 +1020,10 @@ struct si_context { unsigned last_dirty_tex_counter; unsigned last_dirty_buf_counter; unsigned last_compressed_colortex_counter; - unsigned last_num_draw_calls; + struct { + unsigned with_cb; + unsigned with_db; + } num_draw_calls_sh_coherent; unsigned flags; /* flush flags */ /* Atoms (state emit functions). */