iris: trace frames with u_trace
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 2 Mar 2023 09:22:03 +0000 (11:22 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 10 Mar 2023 00:36:41 +0000 (00:36 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21648>

src/gallium/drivers/iris/iris_batch.c
src/gallium/drivers/iris/iris_batch.h
src/gallium/drivers/iris/iris_context.h
src/intel/ds/intel_driver_ds.cc
src/intel/ds/intel_driver_ds.h
src/intel/ds/intel_tracepoints.py

index fa5e735..3bf383e 100644 (file)
@@ -610,6 +610,16 @@ iris_destroy_batches(struct iris_context *ice)
       iris_batch_free(ice, batch);
 }
 
+void iris_batch_maybe_begin_frame(struct iris_batch *batch)
+{
+   struct iris_context *ice = batch->ice;
+
+   if (ice->tracing_begin_frame != ice->frame) {
+      trace_intel_begin_frame(&batch->trace);
+      ice->tracing_begin_frame = ice->tracing_end_frame = ice->frame;
+   }
+}
+
 /**
  * If we've chained to a secondary batch, or are getting near to the end,
  * then flush.  This should only be called between draws.
@@ -708,6 +718,12 @@ iris_finish_batch(struct iris_batch *batch)
 
    trace_intel_end_batch(&batch->trace, batch->name);
 
+   struct iris_context *ice = batch->ice;
+   if (ice->tracing_end_frame != ice->frame) {
+      trace_intel_end_frame(&batch->trace, ice->tracing_end_frame);
+      ice->tracing_end_frame = ice->frame;
+   }
+
    /* Emit MI_BATCH_BUFFER_END to finish our batch. */
    uint32_t *map = batch->map_next;
 
index e601f98..208a9b6 100644 (file)
@@ -202,6 +202,8 @@ void iris_chain_to_new_batch(struct iris_batch *batch);
 void iris_destroy_batches(struct iris_context *ice);
 void iris_batch_maybe_flush(struct iris_batch *batch, unsigned estimate);
 
+void iris_batch_maybe_begin_frame(struct iris_batch *batch);
+
 void _iris_batch_flush(struct iris_batch *batch, const char *file, int line);
 #define iris_batch_flush(batch) _iris_batch_flush((batch), __FILE__, __LINE__)
 
@@ -250,6 +252,7 @@ iris_get_command_space(struct iris_batch *batch, unsigned bytes)
 {
    if (!batch->begin_trace_recorded) {
       batch->begin_trace_recorded = true;
+      iris_batch_maybe_begin_frame(batch);
       trace_intel_begin_batch(&batch->trace);
    }
    iris_require_command_space(batch, bytes);
index 28a222d..1a9638d 100644 (file)
@@ -730,6 +730,10 @@ struct iris_context {
 
    struct intel_perf_context *perf_ctx;
 
+   /** Frame number for u_trace */
+   uint32_t tracing_begin_frame;
+   uint32_t tracing_end_frame;
+
    /** Frame number for debug prints */
    uint32_t frame;
 
index 89042a4..1336fb7 100644 (file)
@@ -61,6 +61,11 @@ static const struct {
 } intel_queue_stage_desc[INTEL_DS_QUEUE_STAGE_N_STAGES] = {
    /* Order must match the enum! */
    {
+      "frame",
+      false,
+      INTEL_DS_QUEUE_STAGE_FRAME,
+   },
+   {
       "cmd-buffer",
       false,
       INTEL_DS_QUEUE_STAGE_CMD_BUFFER,
@@ -451,6 +456,7 @@ extern "C" {
                 &trace_payload_as_extra_intel_end_##event_name);        \
    }                                                                    \
 
+CREATE_DUAL_EVENT_CALLBACK(frame, INTEL_DS_QUEUE_STAGE_FRAME)
 CREATE_DUAL_EVENT_CALLBACK(batch, INTEL_DS_QUEUE_STAGE_CMD_BUFFER)
 CREATE_DUAL_EVENT_CALLBACK(cmd_buffer, INTEL_DS_QUEUE_STAGE_CMD_BUFFER)
 CREATE_DUAL_EVENT_CALLBACK(render_pass, INTEL_DS_QUEUE_STAGE_RENDER_PASS)
index 3bd116e..37f77a9 100644 (file)
@@ -64,6 +64,7 @@ enum intel_ds_stall_flag {
 typedef enum intel_ds_stall_flag (*intel_ds_stall_cb_t)(uint32_t flags);
 
 enum intel_ds_queue_stage {
+   INTEL_DS_QUEUE_STAGE_FRAME,
    INTEL_DS_QUEUE_STAGE_CMD_BUFFER,
    INTEL_DS_QUEUE_STAGE_GENERATE_DRAWS,
    INTEL_DS_QUEUE_STAGE_STALL,
index 56da838..7e68d28 100644 (file)
@@ -60,6 +60,11 @@ def define_tracepoints(args):
                    tp_print=tp_print,
                    end_of_pipe=end_pipelined)
 
+    # Frame tracepoints, only for Iris
+    begin_end_tp('frame',
+                 tp_args=[Arg(type='uint32_t', var='frame', c_format='%u'),],
+                 end_pipelined=False)
+
     # Batch buffer tracepoints, only for Iris
     begin_end_tp('batch',
                  tp_args=[Arg(type='uint8_t', var='name', c_format='%hhu'),],