• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2020 Google, Inc.
3#
4# Permission is hereby granted, free of charge, to any person obtaining a
5# copy of this software and associated documentation files (the "Software"),
6# to deal in the Software without restriction, including without limitation
7# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8# and/or sell copies of the Software, and to permit persons to whom the
9# Software is furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice (including the next
12# paragraph) shall be included in all copies or substantial portions of the
13# Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21# IN THE SOFTWARE.
22#
23
24import argparse
25import sys
26
27#
28# TODO can we do this with less boilerplate?
29#
30parser = argparse.ArgumentParser()
31parser.add_argument('-p', '--import-path', required=True)
32parser.add_argument('-C', '--src', required=True)
33parser.add_argument('-H', '--hdr', required=True)
34args = parser.parse_args()
35sys.path.insert(0, args.import_path)
36
37
38from u_trace import Header
39from u_trace import Tracepoint
40from u_trace import TracepointArg
41from u_trace import utrace_generate
42
43#
44# Tracepoint definitions:
45#
46
47Header('util/u_dump.h')
48Header('freedreno_batch.h')
49
50Tracepoint('start_state_restore')
51Tracepoint('end_state_restore')
52
53Tracepoint('flush_batch',
54    args=[TracepointArg(type='struct fd_batch *', var='batch',       c_format='%x'),
55          TracepointArg(type='uint16_t',          var='cleared',     c_format='%x'),
56          TracepointArg(type='uint16_t',          var='gmem_reason', c_format='%x'),
57          TracepointArg(type='uint16_t',          var='num_draws',   c_format='%u')],
58    tp_print=['%p: cleared=%x, gmem_reason=%x, num_draws=%u', '__entry->batch',
59        '__entry->cleared', '__entry->gmem_reason', '__entry->num_draws'],
60)
61
62Tracepoint('render_gmem',
63    args=[TracepointArg(type='uint16_t', var='nbins_x', c_format='%u'),
64          TracepointArg(type='uint16_t', var='nbins_y', c_format='%u'),
65          TracepointArg(type='uint16_t', var='bin_w',   c_format='%u'),
66          TracepointArg(type='uint16_t', var='bin_h',   c_format='%u')],
67    tp_print=['%ux%u bins of %ux%u',
68        '__entry->nbins_x', '__entry->nbins_y', '__entry->bin_w', '__entry->bin_h'],
69)
70
71Tracepoint('render_sysmem')
72
73# Note that this doesn't include full information about all of the MRTs
74# but seems to roughly match what I see with a blob trace
75Tracepoint('start_render_pass',
76    args=[TracepointArg(type='uint32_t',         var='submit_id',     c_format='%u'),
77          TracepointArg(type='enum pipe_format', var='cbuf0_format',  c_format='%s', to_prim_type='util_format_description({})->short_name'),
78          TracepointArg(type='enum pipe_format', var='zs_format',     c_format='%s', to_prim_type='util_format_description({})->short_name'),
79          TracepointArg(type='uint16_t',         var='width',         c_format='%u'),
80          TracepointArg(type='uint16_t',         var='height',        c_format='%u'),
81          TracepointArg(type='uint8_t',          var='mrts',          c_format='%u'),
82          TracepointArg(type='uint8_t',          var='samples',       c_format='%u'),
83          TracepointArg(type='uint16_t',         var='nbins',         c_format='%u'),
84          TracepointArg(type='uint16_t',         var='binw',          c_format='%u'),
85          TracepointArg(type='uint16_t',         var='binh',          c_format='%u')],
86    tp_perfetto='fd_start_render_pass'
87)
88Tracepoint('end_render_pass',
89    tp_perfetto='fd_end_render_pass')
90
91Tracepoint('start_binning_ib',
92    tp_perfetto='fd_start_binning_ib')
93Tracepoint('end_binning_ib',
94    tp_perfetto='fd_end_binning_ib')
95
96Tracepoint('start_vsc_overflow_test')
97Tracepoint('end_vsc_overflow_test')
98
99Tracepoint('start_prologue')
100Tracepoint('end_prologue')
101
102# For GMEM pass, where this could either be a clear or resolve
103Tracepoint('start_clear_restore',
104    args=[TracepointArg(type='uint16_t', var='fast_cleared', c_format='0x%x')],
105    tp_print=['fast_cleared: 0x%x', '__entry->fast_cleared'],
106    tp_perfetto='fd_start_clear_restore',
107)
108Tracepoint('end_clear_restore',
109    tp_perfetto='fd_end_clear_restore')
110
111Tracepoint('start_resolve',
112    tp_perfetto='fd_start_resolve')
113Tracepoint('end_resolve',
114    tp_perfetto='fd_end_resolve')
115
116Tracepoint('start_tile',
117    args=[TracepointArg(type='uint16_t', var='bin_h', c_format='%u'),
118          TracepointArg(type='uint16_t', var='yoff',  c_format='%u'),
119          TracepointArg(type='uint16_t', var='bin_w', c_format='%u'),
120          TracepointArg(type='uint16_t', var='xoff',  c_format='%u')],
121    tp_print=['bin_h=%d, yoff=%d, bin_w=%d, xoff=%d',
122        '__entry->bin_h', '__entry->yoff', '__entry->bin_w', '__entry->xoff'],
123)
124
125Tracepoint('start_draw_ib',
126    tp_perfetto='fd_start_draw_ib')
127Tracepoint('end_draw_ib',
128    tp_perfetto='fd_end_draw_ib')
129
130Tracepoint('start_blit',
131    args=[TracepointArg(type='enum pipe_texture_target', var='src_target', c_format='%s', to_prim_type="util_str_tex_target({}, true)"),
132          TracepointArg(type='enum pipe_texture_target', var='dst_target', c_format='%s', to_prim_type="util_str_tex_target({}, true)")],
133    tp_print=['%s -> %s', 'util_str_tex_target(__entry->src_target, true)',
134        'util_str_tex_target(__entry->dst_target, true)'],
135    tp_perfetto='fd_start_blit',
136)
137Tracepoint('end_blit',
138    tp_perfetto='fd_end_blit')
139
140Tracepoint('start_compute',
141    tp_perfetto='fd_start_compute')
142Tracepoint('end_compute',
143    tp_perfetto='fd_end_compute')
144
145utrace_generate(cpath=args.src, hpath=args.hdr, ctx_param='struct pipe_context *pctx')
146