Mesa (master): radeonsi/sqtt: use more event identifier

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 29 09:09:22 UTC 2021


Module: Mesa
Branch: master
Commit: f2d57d28ed6f3740b3b7de0cc874178dcff936f5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2d57d28ed6f3740b3b7de0cc874178dcff936f5

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Fri Jan 15 18:09:59 2021 +0100

radeonsi/sqtt: use more event identifier

Using event identifiers allows to add a bit more context to the RGP trace.
Without this all draw calls are identified as vkCmdDraw.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8746>

---

 src/gallium/drivers/radeonsi/si_blit.c         |  6 ++++++
 src/gallium/drivers/radeonsi/si_clear.c        |  7 +++++++
 src/gallium/drivers/radeonsi/si_compute.c      |  6 ++++++
 src/gallium/drivers/radeonsi/si_pipe.h         |  5 +++++
 src/gallium/drivers/radeonsi/si_sqtt.c         | 29 ++++++++++++++++++++++++--
 src/gallium/drivers/radeonsi/si_state_draw.cpp |  2 +-
 6 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index 3d2c81e92fc..eba077d8b35 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -1148,6 +1148,9 @@ static void si_blit(struct pipe_context *ctx, const struct pipe_blit_info *info)
       return;
    }
 
+   if (unlikely(sctx->thread_trace_enabled))
+      sctx->sqtt_next_event = EventCmdCopyImage;
+
    /* Using compute for copying to a linear texture in GTT is much faster than
     * going through RBs (render backends). This improves DRI PRIME performance.
     */
@@ -1169,6 +1172,9 @@ static void si_blit(struct pipe_context *ctx, const struct pipe_blit_info *info)
    si_decompress_subresource(ctx, info->src.resource, PIPE_MASK_RGBAZS, info->src.level,
                              info->src.box.z, info->src.box.z + info->src.box.depth - 1);
 
+   if (unlikely(sctx->thread_trace_enabled))
+      sctx->sqtt_next_event = EventCmdBlitImage;
+
    si_blitter_begin(sctx, SI_BLIT | (info->render_condition_enable ? 0 : SI_DISABLE_RENDER_COND));
    util_blitter_blit(sctx->blitter, info);
    si_blitter_end(sctx);
diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c
index fe2cac59588..e26797634f9 100644
--- a/src/gallium/drivers/radeonsi/si_clear.c
+++ b/src/gallium/drivers/radeonsi/si_clear.c
@@ -661,6 +661,13 @@ static void si_clear(struct pipe_context *ctx, unsigned buffers,
          sctx->flags |= SI_CONTEXT_FLUSH_AND_INV_DB;
    }
 
+   if (unlikely(sctx->thread_trace_enabled)) {
+      if (buffers & PIPE_CLEAR_COLOR)
+         sctx->sqtt_next_event = EventCmdClearColorImage;
+      else if (buffers & PIPE_CLEAR_DEPTHSTENCIL)
+         sctx->sqtt_next_event = EventCmdClearDepthStencilImage;
+   }
+
    si_blitter_begin(sctx, SI_CLEAR);
    util_blitter_clear(sctx->blitter, fb->width, fb->height, util_framebuffer_get_num_layers(fb),
                       buffers, color, depth, stencil, sctx->framebuffer.nr_samples > 1);
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
index 40933fee016..0f1ece6965d 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -749,6 +749,12 @@ static void si_emit_dispatch_packets(struct si_context *sctx, const struct pipe_
    if (sctx->chip_class >= GFX10 && waves_per_threadgroup == 1)
       threadgroups_per_cu = 2;
 
+   if (unlikely(sctx->thread_trace_enabled)) {
+      si_write_event_with_dims_marker(sctx, &sctx->gfx_cs,
+                                      info->indirect ? EventCmdDispatchIndirect : EventCmdDispatch,
+                                      info->grid[0], info->grid[1], info->grid[2]);
+   }
+
    radeon_begin(cs);
    radeon_set_sh_reg(
       cs, R_00B854_COMPUTE_RESOURCE_LIMITS,
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 68130373b6c..4aed81d76b2 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -1292,6 +1292,7 @@ struct si_context {
    /* SQTT */
    struct ac_thread_trace_data *thread_trace;
    struct pipe_fence_handle *last_sqtt_fence;
+   enum rgp_sqtt_marker_event_type sqtt_next_event;
    bool thread_trace_enabled;
 };
 
@@ -1564,6 +1565,10 @@ void si_sqtt_write_event_marker(struct si_context* sctx, struct radeon_cmdbuf *r
                                 uint32_t vertex_offset_user_data,
                                 uint32_t instance_offset_user_data,
                                 uint32_t draw_index_user_data);
+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);
 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 f5263d5e9fa..28c08a3a0ba 100644
--- a/src/gallium/drivers/radeonsi/si_sqtt.c
+++ b/src/gallium/drivers/radeonsi/si_sqtt.c
@@ -571,6 +571,8 @@ si_init_thread_trace(struct si_context *sctx)
 
    si_thread_trace_init_cs(sctx);
 
+   sctx->sqtt_next_event = EventInvalid;
+
    return true;
 }
 
@@ -691,6 +693,7 @@ si_emit_spi_config_cntl(struct si_context* sctx,
    radeon_end();
 }
 
+static uint32_t num_events = 0;
 void
 si_sqtt_write_event_marker(struct si_context* sctx, struct radeon_cmdbuf *rcs,
                            enum rgp_sqtt_marker_event_type api_type,
@@ -698,11 +701,10 @@ si_sqtt_write_event_marker(struct si_context* sctx, struct radeon_cmdbuf *rcs,
                            uint32_t instance_offset_user_data,
                            uint32_t draw_index_user_data)
 {
-   static uint32_t num_events = 0;
    struct rgp_sqtt_marker_event marker = {0};
 
    marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_EVENT;
-   marker.api_type = api_type;
+   marker.api_type = api_type == EventInvalid ? EventCmdDraw : api_type;
    marker.cmd_id = num_events++;
    marker.cb_id = 0;
 
@@ -720,4 +722,27 @@ si_sqtt_write_event_marker(struct si_context* sctx, struct radeon_cmdbuf *rcs,
    marker.draw_index_reg_idx = draw_index_user_data;
 
    si_emit_thread_trace_userdata(sctx, rcs, &marker, sizeof(marker) / 4);
+
+   sctx->sqtt_next_event = EventInvalid;
+}
+
+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)
+{
+   struct rgp_sqtt_marker_event_with_dims marker = {0};
+
+   marker.event.identifier = RGP_SQTT_MARKER_IDENTIFIER_EVENT;
+   marker.event.api_type = api_type;
+   marker.event.cmd_id = num_events++;
+   marker.event.cb_id = 0;
+   marker.event.has_thread_dims = 1;
+
+   marker.thread_x = x;
+   marker.thread_y = y;
+   marker.thread_z = z;
+
+   si_emit_thread_trace_userdata(sctx, rcs, &marker, sizeof(marker) / 4);
+   sctx->sqtt_next_event = EventInvalid;
 }
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp
index f7360e68ff1..3d0043e5648 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.cpp
+++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp
@@ -991,7 +991,7 @@ static void si_emit_draw_packets(struct si_context *sctx, const struct pipe_draw
    struct radeon_cmdbuf *cs = &sctx->gfx_cs;
 
    if (unlikely(sctx->thread_trace_enabled)) {
-      si_sqtt_write_event_marker(sctx, &sctx->gfx_cs, EventCmdDraw,
+      si_sqtt_write_event_marker(sctx, &sctx->gfx_cs, sctx->sqtt_next_event,
                                  UINT_MAX, UINT_MAX, UINT_MAX);
    }
 



More information about the mesa-commit mailing list