radeonsi/sqtt: use pipe_buffer_map instead of ws->buffer_map

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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39194>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2026-01-07 11:17:21 +01:00 committed by Marge Bot
parent 8f7f7a90b7
commit 2f849f7f65

View file

@ -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;