From 65697d6141bb17360e31d2eda9931451be46ac12 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 22 Nov 2021 11:30:50 +0200 Subject: [PATCH] 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 Reviewed-by: Danylo Piliaiev Part-of: --- 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 b0878a5..6b4201e 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 bd5fea4..b51d7f2 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 ee8dddd..1252897 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 29d7b87..7e3f7aa 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 24d1ddc..f80b253 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 331a8c8..8733715 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 /** -- 2.7.4