From 5dc823304b1653fc69b6de73bb304049e69f218d Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 27 Jan 2021 11:59:59 +0100 Subject: [PATCH] radeonsi/sqtt: forward string markers to sqtt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Part-of: --- src/amd/common/ac_sqtt.h | 31 +++++++++++++++++++++++++++++++ src/gallium/drivers/radeonsi/si_pipe.c | 3 +++ src/gallium/drivers/radeonsi/si_pipe.h | 4 ++++ src/gallium/drivers/radeonsi/si_sqtt.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) diff --git a/src/amd/common/ac_sqtt.h b/src/amd/common/ac_sqtt.h index 30361bc..779bea8 100644 --- a/src/amd/common/ac_sqtt.h +++ b/src/amd/common/ac_sqtt.h @@ -418,4 +418,35 @@ struct rgp_sqtt_marker_layout_transition { static_assert(sizeof(struct rgp_sqtt_marker_layout_transition) == 8, "rgp_sqtt_marker_layout_transition doesn't match RGP spec"); + +/** + * "User Event" RGP SQTT instrumentation marker (Table 8) + */ +struct rgp_sqtt_marker_user_event { + union { + struct { + uint32_t identifier : 4; + uint32_t reserved0 : 8; + uint32_t data_type : 8; + uint32_t reserved1 : 12; + }; + uint32_t dword01; + }; +}; +struct rgp_sqtt_marker_user_event_with_length { + struct rgp_sqtt_marker_user_event user_event; + uint32_t length; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_user_event) == 4, + "rgp_sqtt_marker_user_event doesn't match RGP spec"); + +enum rgp_sqtt_marker_user_event_type +{ + UserEventTrigger = 0, + UserEventPop, + UserEventPush, + UserEventObjectName, +}; + #endif diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 012a650..b508a4b 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -386,6 +386,9 @@ static void si_emit_string_marker(struct pipe_context *ctx, const char *string, dd_parse_apitrace_marker(string, len, &sctx->apitrace_call_number); + if (sctx->thread_trace_enabled) + si_write_user_event(sctx, &sctx->gfx_cs, UserEventTrigger, string, len); + if (sctx->log) u_log_printf(sctx->log, "\nString marker: %*s\n", len, string); } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 4aed81d..87ea96e 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1569,6 +1569,10 @@ void si_write_event_with_dims_marker(struct si_context* sctx, struct radeon_cmdbuf *rcs, enum rgp_sqtt_marker_event_type api_type, uint32_t x, uint32_t y, uint32_t z); +void +si_write_user_event(struct si_context* sctx, struct radeon_cmdbuf *rcs, + enum rgp_sqtt_marker_user_event_type type, + const char *str, int len); bool si_init_thread_trace(struct si_context *sctx); void si_destroy_thread_trace(struct si_context *sctx); void si_handle_thread_trace(struct si_context *sctx, struct radeon_cmdbuf *rcs); diff --git a/src/gallium/drivers/radeonsi/si_sqtt.c b/src/gallium/drivers/radeonsi/si_sqtt.c index 4ad1d2e..f86417a 100644 --- a/src/gallium/drivers/radeonsi/si_sqtt.c +++ b/src/gallium/drivers/radeonsi/si_sqtt.c @@ -750,3 +750,31 @@ si_write_event_with_dims_marker(struct si_context* sctx, struct radeon_cmdbuf *r si_emit_thread_trace_userdata(sctx, rcs, &marker, sizeof(marker) / 4); sctx->sqtt_next_event = EventInvalid; } + +void +si_write_user_event(struct si_context* sctx, struct radeon_cmdbuf *rcs, + enum rgp_sqtt_marker_user_event_type type, + const char *str, int len) +{ + if (type == UserEventPop) { + assert (str == NULL); + struct rgp_sqtt_marker_user_event marker = { 0 }; + marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_USER_EVENT; + marker.data_type = type; + + si_emit_thread_trace_userdata(sctx, rcs, &marker, sizeof(marker) / 4); + } else { + assert (str != NULL); + struct rgp_sqtt_marker_user_event_with_length marker = { 0 }; + marker.user_event.identifier = RGP_SQTT_MARKER_IDENTIFIER_USER_EVENT; + marker.user_event.data_type = type; + marker.length = align(len, 4); + + uint8_t *buffer = alloca(sizeof(marker) + marker.length); + memset(buffer, 0, sizeof(marker) + marker.length); + memcpy(buffer, &marker, sizeof(marker)); + memcpy(buffer + sizeof(marker), str, len); + + si_emit_thread_trace_userdata(sctx, rcs, buffer, sizeof(marker) / 4 + marker.length / 4); + } +} -- 2.7.4