Mesa (main): util/u_trace: add end_of_pipe property to tracepoints

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 1 16:04:12 UTC 2021


Module: Mesa
Branch: main
Commit: 65697d6141bb17360e31d2eda9931451be46ac12
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=65697d6141bb17360e31d2eda9931451be46ac12

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Mon Nov 22 11:30:50 2021 +0200

util/u_trace: add end_of_pipe property to tracepoints

In order to capture the timestamp when things actually end on Intel
GPU HW, we need to know whether the timestamp should be capture at the
top or end of pipeline.

v2: use one line python if/else (Danylo)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13911>

---

 src/freedreno/vulkan/tu_device.c                  | 2 +-
 src/gallium/drivers/freedreno/freedreno_context.c | 2 +-
 src/util/perf/u_trace.c                           | 2 +-
 src/util/perf/u_trace.h                           | 3 ++-
 src/util/perf/u_trace.py                          | 6 +++++-
 src/util/perf/u_trace_priv.h                      | 1 +
 6 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index b0878a54474..6b4201ebfe7 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -1313,7 +1313,7 @@ tu_trace_destroy_ts_buffer(struct u_trace_context *utctx, void *timestamps)
 
 static void
 tu_trace_record_ts(struct u_trace *ut, void *cs, void *timestamps,
-                   unsigned idx)
+                   unsigned idx, bool end_of_pipe)
 {
    struct tu_bo *bo = timestamps;
    struct tu_cs *ts_cs = cs;
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
index bd5fea4e51e..b51d7f2a6e1 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -446,7 +446,7 @@ fd_get_device_reset_status(struct pipe_context *pctx)
 
 static void
 fd_trace_record_ts(struct u_trace *ut, void *cs, void *timestamps,
-                   unsigned idx)
+                   unsigned idx, bool end_of_pipe)
 {
    struct fd_batch *batch = container_of(ut, struct fd_batch, trace);
    struct fd_ringbuffer *ring = cs;
diff --git a/src/util/perf/u_trace.c b/src/util/perf/u_trace.c
index ee8dddd4bcf..1252897688b 100644
--- a/src/util/perf/u_trace.c
+++ b/src/util/perf/u_trace.c
@@ -566,7 +566,7 @@ u_trace_append(struct u_trace *ut, void *cs, const struct u_tracepoint *tp)
    }
 
    /* record a timestamp for the trace: */
-   ut->utctx->record_timestamp(ut, cs, chunk->timestamps, chunk->num_traces);
+   ut->utctx->record_timestamp(ut, cs, chunk->timestamps, chunk->num_traces, tp->end_of_pipe);
 
    chunk->traces[chunk->num_traces] = (struct u_trace_event) {
          .tp = tp,
diff --git a/src/util/perf/u_trace.h b/src/util/perf/u_trace.h
index 29d7b87be10..7e3f7aaa2e2 100644
--- a/src/util/perf/u_trace.h
+++ b/src/util/perf/u_trace.h
@@ -99,7 +99,8 @@ typedef void (*u_trace_delete_ts_buffer)(struct u_trace_context *utctx,
  * GL_TIMESTAMP queries should be appropriate.
  */
 typedef void (*u_trace_record_ts)(struct u_trace *ut, void *cs,
-      void *timestamps, unsigned idx);
+                                  void *timestamps, unsigned idx,
+                                  bool end_of_pipe);
 
 /**
  * Driver provided callback to read back a previously recorded timestamp.
diff --git a/src/util/perf/u_trace.py b/src/util/perf/u_trace.py
index 24d1ddce85d..f80b253d899 100644
--- a/src/util/perf/u_trace.py
+++ b/src/util/perf/u_trace.py
@@ -31,7 +31,9 @@ TRACEPOINTS = {}
 class Tracepoint(object):
     """Class that represents all the information about a tracepoint
     """
-    def __init__(self, name, args=[], tp_struct=None, tp_print=None, tp_perfetto=None):
+    def __init__(self, name, args=[],
+                 tp_struct=None, tp_print=None, tp_perfetto=None,
+                 end_of_pipe=False):
         """Parameters:
 
         - name: the tracepoint name, a tracepoint function with the given
@@ -54,6 +56,7 @@ class Tracepoint(object):
         self.tp_struct = tp_struct
         self.tp_print = tp_print
         self.tp_perfetto = tp_perfetto
+        self.end_of_pipe = end_of_pipe
 
         TRACEPOINTS[name] = self
 
@@ -296,6 +299,7 @@ static void __print_${trace_name}(FILE *out, const void *arg) {
 static const struct u_tracepoint __tp_${trace_name} = {
     ALIGN_POT(sizeof(struct trace_${trace_name}), 8),   /* keep size 64b aligned */
     "${trace_name}",
+    ${"true" if trace.end_of_pipe else "false"},
     __print_${trace_name},
 %    if trace.tp_perfetto is not None:
 #ifdef HAVE_PERFETTO
diff --git a/src/util/perf/u_trace_priv.h b/src/util/perf/u_trace_priv.h
index 331a8c84ace..87337155a23 100644
--- a/src/util/perf/u_trace_priv.h
+++ b/src/util/perf/u_trace_priv.h
@@ -42,6 +42,7 @@
 struct u_tracepoint {
    unsigned payload_sz;
    const char *name;
+   bool end_of_pipe;
    void (*print)(FILE *out, const void *payload);
 #ifdef HAVE_PERFETTO
    /**



More information about the mesa-commit mailing list