From f72a11f38d107a4f3235fc857f4fc007886626f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 3 Jan 2025 11:42:26 -0500 Subject: [PATCH] radeonsi: always use RADEON_USAGE_DISALLOW_SLOW_REPLY All places are fine with getting a false negative as long as buffer_wait returns quickly. This can improve performance. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/gfx11_query.c | 3 ++- src/gallium/drivers/radeonsi/si_buffer.c | 6 ++++-- src/gallium/drivers/radeonsi/si_pipe.c | 3 ++- src/gallium/drivers/radeonsi/si_query.c | 3 ++- src/gallium/drivers/radeonsi/si_texture.c | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx11_query.c b/src/gallium/drivers/radeonsi/gfx11_query.c index b94ed6af5aa..62b304d92d2 100644 --- a/src/gallium/drivers/radeonsi/gfx11_query.c +++ b/src/gallium/drivers/radeonsi/gfx11_query.c @@ -62,7 +62,8 @@ static bool gfx11_alloc_query_buffer(struct si_context *sctx) qbuf = list_first_entry(&sctx->shader_query_buffers, struct gfx11_sh_query_buffer, list); if (!qbuf->refcount && !si_cs_is_buffer_referenced(sctx, qbuf->buf->buf, RADEON_USAGE_READWRITE) && - sctx->ws->buffer_wait(sctx->ws, qbuf->buf->buf, 0, RADEON_USAGE_READWRITE)) { + sctx->ws->buffer_wait(sctx->ws, qbuf->buf->buf, 0, + RADEON_USAGE_READWRITE | RADEON_USAGE_DISALLOW_SLOW_REPLY)) { /* Can immediately re-use the oldest buffer */ list_del(&qbuf->list); } else { diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c index 2b661dc58aa..c41c4be1147 100644 --- a/src/gallium/drivers/radeonsi/si_buffer.c +++ b/src/gallium/drivers/radeonsi/si_buffer.c @@ -256,7 +256,8 @@ static bool si_invalidate_buffer(struct si_context *sctx, struct si_resource *bu /* Check if mapping this buffer would cause waiting for the GPU. */ if (si_cs_is_buffer_referenced(sctx, buf->buf, RADEON_USAGE_READWRITE) || - !sctx->ws->buffer_wait(sctx->ws, buf->buf, 0, RADEON_USAGE_READWRITE)) { + !sctx->ws->buffer_wait(sctx->ws, buf->buf, 0, + RADEON_USAGE_READWRITE | RADEON_USAGE_DISALLOW_SLOW_REPLY)) { /* Reallocate the buffer in the same pipe_resource. */ si_alloc_resource(sctx->screen, buf); si_rebind_buffer(sctx, &buf->b.b); @@ -399,7 +400,8 @@ static void *si_buffer_transfer_map(struct pipe_context *ctx, struct pipe_resour if (buf->flags & (RADEON_FLAG_SPARSE | RADEON_FLAG_NO_CPU_ACCESS) || force_discard_range || si_cs_is_buffer_referenced(sctx, buf->buf, RADEON_USAGE_READWRITE) || - !sctx->ws->buffer_wait(sctx->ws, buf->buf, 0, RADEON_USAGE_READWRITE)) { + !sctx->ws->buffer_wait(sctx->ws, buf->buf, 0, + RADEON_USAGE_READWRITE | RADEON_USAGE_DISALLOW_SLOW_REPLY)) { /* Do a wait-free write-only transfer using a temporary buffer. */ struct u_upload_mgr *uploader; struct si_resource *staging = NULL; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 3ace56464d9..13673399c22 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -908,7 +908,8 @@ static bool si_is_resource_busy(struct pipe_screen *screen, struct pipe_resource /* If mapping for write, we need to wait for all reads and writes. * If mapping for read, we only need to wait for writes. */ - usage & PIPE_MAP_WRITE ? RADEON_USAGE_READWRITE : RADEON_USAGE_WRITE); + (usage & PIPE_MAP_WRITE ? RADEON_USAGE_READWRITE : RADEON_USAGE_WRITE) | + RADEON_USAGE_DISALLOW_SLOW_REPLY); } static struct pipe_context *si_pipe_create_context(struct pipe_screen *screen, void *priv, diff --git a/src/gallium/drivers/radeonsi/si_query.c b/src/gallium/drivers/radeonsi/si_query.c index d69ba929071..4a48b72383c 100644 --- a/src/gallium/drivers/radeonsi/si_query.c +++ b/src/gallium/drivers/radeonsi/si_query.c @@ -518,7 +518,8 @@ void si_query_buffer_reset(struct si_context *sctx, struct si_query_buffer *buff /* Discard even the oldest buffer if it can't be mapped without a stall. */ if (si_cs_is_buffer_referenced(sctx, buffer->buf->buf, RADEON_USAGE_READWRITE) || - !sctx->ws->buffer_wait(sctx->ws, buffer->buf->buf, 0, RADEON_USAGE_READWRITE)) { + !sctx->ws->buffer_wait(sctx->ws, buffer->buf->buf, 0, + RADEON_USAGE_READWRITE | RADEON_USAGE_DISALLOW_SLOW_REPLY)) { si_resource_reference(&buffer->buf, NULL); } } diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index e9932d4ff46..3a2e6e98cec 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -2064,7 +2064,8 @@ static void *si_texture_transfer_map(struct pipe_context *ctx, struct pipe_resou tex->buffer.domains & RADEON_DOMAIN_VRAM || tex->buffer.flags & RADEON_FLAG_GTT_WC; /* Write & linear only: */ else if (si_cs_is_buffer_referenced(sctx, tex->buffer.buf, RADEON_USAGE_READWRITE) || - !sctx->ws->buffer_wait(sctx->ws, tex->buffer.buf, 0, RADEON_USAGE_READWRITE)) { + !sctx->ws->buffer_wait(sctx->ws, tex->buffer.buf, 0, + RADEON_USAGE_READWRITE | RADEON_USAGE_DISALLOW_SLOW_REPLY)) { /* It's busy. */ if (si_can_invalidate_texture(sctx->screen, tex, usage, box)) si_texture_invalidate_storage(sctx, tex);