u_trace: generate tracepoint name array in perfetto header
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sat, 14 Oct 2023 19:14:43 +0000 (22:14 +0300)
committerMarge Bot <emma+marge@anholt.net>
Tue, 17 Oct 2023 11:19:13 +0000 (11:19 +0000)
The driver glue doesn't have access to that information in a
centralized place. If you want to generate perfetto iid, you need
access to all names.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Tested-by: Felix DeGrood <felix.j.degrood@intel.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25730>

src/util/perf/u_trace.py

index 90c2c8a..3d00e42 100644 (file)
@@ -568,6 +568,12 @@ perfetto_utils_hdr_template = """\
 #include "${header.hdr}"
 % endfor
 
+UNUSED static const char *${basename}_names[] = {
+% for trace_name, trace in TRACEPOINTS.items():
+   "${trace_name}",
+% endfor
+};
+
 % for trace_name, trace in TRACEPOINTS.items():
 static void UNUSED
 trace_payload_as_extra_${trace_name}(perfetto::protos::pbzero::GpuRenderStageEvent *event,
@@ -598,11 +604,12 @@ trace_payload_as_extra_${trace_name}(perfetto::protos::pbzero::GpuRenderStageEve
 #endif /* ${guard_name} */
 """
 
-def utrace_generate_perfetto_utils(hpath):
+def utrace_generate_perfetto_utils(hpath,basename="tracepoint"):
     if hpath is not None:
         hdr = os.path.basename(hpath)
         with open(hpath, 'wb') as f:
             f.write(Template(perfetto_utils_hdr_template, output_encoding='utf-8').render(
+                basename=basename,
                 hdrname=hdr.rstrip('.h').upper(),
                 HEADERS=[h for h in HEADERS if h.scope & HeaderScope.PERFETTO],
                 TRACEPOINTS=TRACEPOINTS))