From 15e320e970570e1579d7886748cffa2cca7a4c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 25 Aug 2024 16:24:27 -0400 Subject: [PATCH] radeonsi: don't sync VS and PS if they are idle Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_barrier.c | 16 +++++++++++++++- src/gallium/drivers/radeonsi/si_pipe.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_barrier.c b/src/gallium/drivers/radeonsi/si_barrier.c index 297a082e044..6df0e4ffc07 100644 --- a/src/gallium/drivers/radeonsi/si_barrier.c +++ b/src/gallium/drivers/radeonsi/si_barrier.c @@ -59,7 +59,7 @@ static unsigned get_reduced_barrier_flags(struct si_context *ctx) if (!ctx->compute_is_busy) flags &= ~SI_BARRIER_SYNC_CS; - /* Track the last flush. */ + /* Track the last CB/DB flush. */ if (flags & SI_BARRIER_SYNC_AND_INV_CB) { ctx->num_cb_cache_flushes++; ctx->last_cb_flush_num_draw_calls = ctx->num_draw_calls; @@ -71,6 +71,20 @@ static unsigned get_reduced_barrier_flags(struct si_context *ctx) ctx->last_db_flush_num_decompress_calls = ctx->num_decompress_calls; } + /* Skip VS and PS synchronization if they are idle. */ + if (ctx->num_draw_calls == ctx->last_ps_sync_num_draw_calls) + flags &= ~SI_BARRIER_SYNC_VS & ~SI_BARRIER_SYNC_PS; + else if (ctx->num_draw_calls == ctx->last_vs_sync_num_draw_calls) + flags &= ~SI_BARRIER_SYNC_VS; + + /* Track the last VS/PS flush. Flushing CB or DB also waits for PS (obviously). */ + if (flags & (SI_BARRIER_SYNC_AND_INV_CB | SI_BARRIER_SYNC_AND_INV_DB | SI_BARRIER_SYNC_PS)) { + ctx->last_ps_sync_num_draw_calls = ctx->num_draw_calls; + ctx->last_vs_sync_num_draw_calls = ctx->num_draw_calls; + } else if (SI_BARRIER_SYNC_VS) { + ctx->last_vs_sync_num_draw_calls = ctx->num_draw_calls; + } + /* We use a TS event to flush CB/DB on GFX9+, which also waits for compute shaders. */ if (flags & SI_BARRIER_SYNC_CS || (ctx->gfx_level >= GFX9 && diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index cbeac0aad2b..6fe86631fbb 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1277,6 +1277,8 @@ struct si_context { unsigned num_decompress_calls; unsigned last_cb_flush_num_draw_calls; unsigned last_db_flush_num_draw_calls; + unsigned last_ps_sync_num_draw_calls; + unsigned last_vs_sync_num_draw_calls; unsigned last_cb_flush_num_decompress_calls; unsigned last_db_flush_num_decompress_calls; unsigned num_compute_calls;