util/u_trace: add PERFETTO HeaderScope

Headers with the PERFETTO scope will be included by the generated
perfetto utils header.  This is needed because to_prim_type may have
header dependencies.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18238>
This commit is contained in:
Chia-I Wu 2022-08-23 10:06:31 -07:00 committed by Marge Bot
parent dea0d684b7
commit 9aa57bae9f

View file

@ -122,6 +122,7 @@ HEADERS = []
class HeaderScope(IntEnum):
HEADER = (1 << 0)
SOURCE = (1 << 1)
PERFETTO = (1 << 2)
class Header(object):
"""Class that represents a header file dependency of generated tracepoints
@ -514,6 +515,10 @@ perfetto_utils_hdr_template = """\
#include <perfetto.h>
% for header in HEADERS:
#include "${header.hdr}"
% endfor
% for trace_name, trace in TRACEPOINTS.items():
static void UNUSED
trace_payload_as_extra_${trace_name}(perfetto::protos::pbzero::GpuRenderStageEvent *event,
@ -550,4 +555,5 @@ def utrace_generate_perfetto_utils(hpath):
with open(hpath, 'wb') as f:
f.write(Template(perfetto_utils_hdr_template, output_encoding='utf-8').render(
hdrname=hdr.rstrip('.h').upper(),
HEADERS=[h for h in HEADERS if h.scope & HeaderScope.PERFETTO],
TRACEPOINTS=TRACEPOINTS))