From 2f849f7f6519746ff2ecd2e7894c258555bc1e97 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 7 Jan 2026 11:17:21 +0100 Subject: [PATCH] radeonsi/sqtt: use pipe_buffer_map instead of ws->buffer_map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pipe_buffer_map has heuristics to chose the best method to access the BO's content, including using a staging buffer if needed. Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_sqtt.c | 31 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_sqtt.c b/src/gallium/drivers/radeonsi/si_sqtt.c index 2cc8768c58c..0e0dd9aec23 100644 --- a/src/gallium/drivers/radeonsi/si_sqtt.c +++ b/src/gallium/drivers/radeonsi/si_sqtt.c @@ -286,15 +286,19 @@ si_sqtt_resize_bo(struct si_context *sctx) static bool si_get_sqtt_trace(struct si_context *sctx, struct ac_sqtt_trace *sqtt) { + struct pipe_transfer *transfer; + struct pipe_resource *bo = sctx->sqtt->bo; + memset(sqtt, 0, sizeof(*sqtt)); - sctx->sqtt->ptr = - sctx->ws->buffer_map(sctx->ws, si_resource(sctx->sqtt->bo)->buf, NULL, PIPE_MAP_READ); + sctx->sqtt->ptr = pipe_buffer_map(&sctx->b, bo, PIPE_MAP_READ, &transfer); if (!sctx->sqtt->ptr) return false; if (!ac_sqtt_get_trace(sctx->sqtt, &sctx->screen->info, sqtt)) { + pipe_buffer_unmap(&sctx->b, transfer); + if (!si_sqtt_resize_bo(sctx)) { mesa_loge("Failed to resize the SQTT buffer."); } else { @@ -306,6 +310,8 @@ static bool si_get_sqtt_trace(struct si_context *sctx, } return false; } + + pipe_buffer_unmap(&sctx->b, transfer); return true; } @@ -485,20 +491,23 @@ void si_handle_sqtt(struct si_context *sctx, struct radeon_cmdbuf *rcs) if (sctx->ws->fence_wait(sctx->ws, sctx->last_sqtt_fence, OS_TIMEOUT_INFINITE) && si_get_sqtt_trace(sctx, &sqtt_trace)) { + struct pipe_transfer *transfer; struct ac_spm_trace spm_trace; /* Map the SPM counter buffer */ - if (sctx->spm.bo) { - sctx->spm.ptr = sctx->ws->buffer_map( - sctx->ws, si_resource(sctx->spm.bo)->buf, NULL, PIPE_MAP_READ | RADEON_MAP_TEMPORARY); - ac_spm_get_trace(&sctx->spm, &spm_trace); - } - - ac_dump_rgp_capture(&sctx->screen->info, &sqtt_trace, - sctx->spm.bo ? &spm_trace : NULL); + if (sctx->spm.bo) + sctx->spm.ptr = pipe_buffer_map(&sctx->b, sctx->spm.bo, PIPE_MAP_READ, &transfer); if (sctx->spm.ptr) - sctx->ws->buffer_unmap(sctx->ws, si_resource(sctx->spm.bo)->buf); + ac_spm_get_trace(&sctx->spm, &spm_trace); + + ac_dump_rgp_capture(&sctx->screen->info, &sqtt_trace, + sctx->spm.ptr ? &spm_trace : NULL); + + if (sctx->spm.ptr) { + pipe_buffer_unmap(&sctx->b, transfer); + sctx->spm.ptr = NULL; + } } else if (sctx->sqtt->bo) { if (!sctx->sqtt->trigger_file) { sctx->sqtt->start_frame = num_frames + 10;