From 998e2a70e7d7585cb821a1a32d845ed413a3a0dc Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 23 Sep 2025 14:47:35 +0200 Subject: [PATCH] radeonsi: Add RADEON_FLUSH_FORCE and use it to force flush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forcing flush by setting initial_gfx_cs_size to zero requires there are always packets emitted on starting new gfx IB. But this is not the case with userq, as there is no preamble. Add a new flag to be used with si_flush_gfx_cs to force flush. Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/gfx/si_state_shaders.cpp | 3 +-- src/gallium/drivers/radeonsi/si_fence.c | 4 ++-- src/gallium/drivers/radeonsi/si_gfx_cs.c | 2 +- src/gallium/include/winsys/radeon_winsys.h | 3 +++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx/si_state_shaders.cpp b/src/gallium/drivers/radeonsi/gfx/si_state_shaders.cpp index 6639a815b07..55b9c24e88f 100644 --- a/src/gallium/drivers/radeonsi/gfx/si_state_shaders.cpp +++ b/src/gallium/drivers/radeonsi/gfx/si_state_shaders.cpp @@ -3841,8 +3841,7 @@ bool si_update_gs_ring_buffers(struct si_context *sctx) } /* Flush the context to re-emit both cs_preamble states. */ - sctx->initial_gfx_cs_size = 0; /* force flush */ - si_flush_gfx_cs(sctx, RADEON_FLUSH_ASYNC_START_NEXT_GFX_IB_NOW, NULL); + si_flush_gfx_cs(sctx, RADEON_FLUSH_ASYNC_START_NEXT_GFX_IB_NOW | RADEON_FLUSH_FORCE, NULL); return true; } diff --git a/src/gallium/drivers/radeonsi/si_fence.c b/src/gallium/drivers/radeonsi/si_fence.c index 63afe7f90c6..ae104361928 100644 --- a/src/gallium/drivers/radeonsi/si_fence.c +++ b/src/gallium/drivers/radeonsi/si_fence.c @@ -439,10 +439,10 @@ static void si_flush_all_queues(struct pipe_context *ctx, } if (force_flush) { - sctx->initial_gfx_cs_size = 0; + rflags |= RADEON_FLUSH_FORCE; } - if (!radeon_emitted(&sctx->gfx_cs, sctx->initial_gfx_cs_size)) { + if (!force_flush && !radeon_emitted(&sctx->gfx_cs, sctx->initial_gfx_cs_size)) { if (fence) ws->fence_reference(ws, &gfx_fence, sctx->last_gfx_fence); if (!(flags & PIPE_FLUSH_DEFERRED)) diff --git a/src/gallium/drivers/radeonsi/si_gfx_cs.c b/src/gallium/drivers/radeonsi/si_gfx_cs.c index 2305aa924b8..fc0bbfbd63f 100644 --- a/src/gallium/drivers/radeonsi/si_gfx_cs.c +++ b/src/gallium/drivers/radeonsi/si_gfx_cs.c @@ -114,7 +114,7 @@ void si_flush_gfx_cs(struct si_context *ctx, unsigned flags, struct pipe_fence_h /* Drop this flush if it's a no-op. */ if (!radeon_emitted(cs, ctx->initial_gfx_cs_size) && (!wait_flags || !ctx->gfx_last_ib_is_busy) && - !(flags & RADEON_FLUSH_TOGGLE_SECURE_SUBMISSION)) { + !(flags & (RADEON_FLUSH_TOGGLE_SECURE_SUBMISSION | RADEON_FLUSH_FORCE))) { tc_driver_internal_flush_notify(ctx->tc); return; } diff --git a/src/gallium/include/winsys/radeon_winsys.h b/src/gallium/include/winsys/radeon_winsys.h index c78460a9399..b7b935e7a42 100644 --- a/src/gallium/include/winsys/radeon_winsys.h +++ b/src/gallium/include/winsys/radeon_winsys.h @@ -11,6 +11,9 @@ /* The public winsys interface header for the radeon driver. */ +/* Force flush. */ +#define RADEON_FLUSH_FORCE (1u << 28) + /* Skip command submission. Same as RADEON_NOOP=1. */ #define RADEON_FLUSH_NOOP (1u << 29)