• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright © 2021 Igalia S.L.
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 FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# 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('--utrace-src', required=True)
33parser.add_argument('--utrace-hdr', required=True)
34parser.add_argument('--perfetto-hdr', required=True)
35args = parser.parse_args()
36sys.path.insert(0, args.import_path)
37
38
39from u_trace import Header, HeaderScope
40from u_trace import ForwardDecl
41from u_trace import Tracepoint
42from u_trace import TracepointArg as Arg
43from u_trace import TracepointArgStruct as ArgStruct
44from u_trace import utrace_generate
45from u_trace import utrace_generate_perfetto_utils
46
47#
48# Tracepoint definitions:
49#
50
51Header('util/u_dump.h')
52Header('vk_format.h')
53Header('freedreno/vulkan/tu_private.h', scope=HeaderScope.SOURCE)
54
55ForwardDecl('struct tu_device')
56
57Tracepoint('start_render_pass',
58    tp_perfetto='tu_start_render_pass'
59)
60Tracepoint('end_render_pass',
61    args=[ArgStruct(type='const struct tu_framebuffer *', var='fb')],
62    tp_struct=[Arg(type='uint16_t', name='width',        var='fb->width',                                    c_format='%u'),
63               Arg(type='uint16_t', name='height',       var='fb->height',                                   c_format='%u'),
64               Arg(type='uint8_t',  name='MRTs',         var='fb->attachment_count',                         c_format='%u'),
65            #    Arg(type='uint8_t',  name='samples',      var='fb->samples',                                  c_format='%u'),
66               Arg(type='uint16_t', name='numberOfBins', var='fb->tile_count.width * fb->tile_count.height', c_format='%u'),
67               Arg(type='uint16_t', name='binWidth',     var='fb->tile0.width',                              c_format='%u'),
68               Arg(type='uint16_t', name='binHeight',    var='fb->tile0.height',                             c_format='%u')],
69    tp_perfetto='tu_end_render_pass')
70
71Tracepoint('start_binning_ib',
72    tp_perfetto='tu_start_binning_ib')
73Tracepoint('end_binning_ib',
74    tp_perfetto='tu_end_binning_ib')
75
76Tracepoint('start_resolve',
77    tp_perfetto='tu_start_resolve')
78Tracepoint('end_resolve',
79    tp_perfetto='tu_end_resolve')
80
81Tracepoint('start_draw_ib_sysmem',
82    tp_perfetto='tu_start_draw_ib_sysmem')
83Tracepoint('end_draw_ib_sysmem',
84    tp_perfetto='tu_end_draw_ib_sysmem')
85
86Tracepoint('start_draw_ib_gmem',
87    tp_perfetto='tu_start_draw_ib_gmem')
88Tracepoint('end_draw_ib_gmem',
89    tp_perfetto='tu_end_draw_ib_gmem')
90
91Tracepoint('start_gmem_clear',
92    tp_perfetto='tu_start_gmem_clear')
93Tracepoint('end_gmem_clear',
94    args=[Arg(type='enum VkFormat',  var='format',  c_format='%s', to_prim_type='vk_format_description({})->short_name'),
95          Arg(type='uint8_t',        var='samples', c_format='%u')],
96    tp_perfetto='tu_end_gmem_clear')
97
98Tracepoint('start_sysmem_clear',
99    tp_perfetto='tu_start_sysmem_clear')
100Tracepoint('end_sysmem_clear',
101    args=[Arg(type='enum VkFormat',  var='format',      c_format='%s', to_prim_type='vk_format_description({})->short_name'),
102          Arg(type='uint8_t',        var='uses_3d_ops', c_format='%u'),
103          Arg(type='uint8_t',        var='samples',     c_format='%u')],
104    tp_perfetto='tu_end_sysmem_clear')
105
106Tracepoint('start_sysmem_clear_all',
107    tp_perfetto='tu_start_sysmem_clear_all')
108Tracepoint('end_sysmem_clear_all',
109    args=[Arg(type='uint8_t',        var='mrt_count',   c_format='%u'),
110          Arg(type='uint8_t',        var='rect_count',  c_format='%u')],
111    tp_perfetto='tu_end_sysmem_clear_all')
112
113Tracepoint('start_gmem_load',
114    tp_perfetto='tu_start_gmem_load')
115Tracepoint('end_gmem_load',
116    args=[Arg(type='enum VkFormat',  var='format',   c_format='%s', to_prim_type='vk_format_description({})->short_name'),
117          Arg(type='uint8_t',        var='force_load', c_format='%u')],
118    tp_perfetto='tu_end_gmem_load')
119
120Tracepoint('start_gmem_store',
121    tp_perfetto='tu_start_gmem_store')
122Tracepoint('end_gmem_store',
123    args=[Arg(type='enum VkFormat',  var='format',   c_format='%s', to_prim_type='vk_format_description({})->short_name'),
124          Arg(type='uint8_t',        var='fast_path', c_format='%u'),
125          Arg(type='uint8_t',        var='unaligned', c_format='%u')],
126    tp_perfetto='tu_end_gmem_store')
127
128Tracepoint('start_sysmem_resolve',
129    tp_perfetto='tu_start_sysmem_resolve')
130Tracepoint('end_sysmem_resolve',
131    args=[Arg(type='enum VkFormat',  var='format',   c_format='%s', to_prim_type='vk_format_description({})->short_name')],
132    tp_perfetto='tu_end_sysmem_resolve')
133
134Tracepoint('start_blit',
135    tp_perfetto='tu_start_blit',
136)
137Tracepoint('end_blit',
138    # TODO: add source megapixels count and target megapixels count arguments
139    args=[Arg(type='uint8_t',        var='uses_3d_blit', c_format='%u'),
140          Arg(type='enum VkFormat',  var='src_format',   c_format='%s', to_prim_type='vk_format_description({})->short_name'),
141          Arg(type='enum VkFormat',  var='dst_format',   c_format='%s', to_prim_type='vk_format_description({})->short_name'),
142          Arg(type='uint8_t',        var='layers',       c_format='%u')],
143    tp_perfetto='tu_end_blit')
144
145Tracepoint('start_compute',
146    tp_perfetto='tu_start_compute')
147Tracepoint('end_compute',
148    args=[Arg(type='uint8_t',  var='indirect',       c_format='%u'),
149          Arg(type='uint16_t', var='local_size_x',   c_format='%u'),
150          Arg(type='uint16_t', var='local_size_y',   c_format='%u'),
151          Arg(type='uint16_t', var='local_size_z',   c_format='%u'),
152          Arg(type='uint16_t', var='num_groups_x',   c_format='%u'),
153          Arg(type='uint16_t', var='num_groups_y',   c_format='%u'),
154          Arg(type='uint16_t', var='num_groups_z',   c_format='%u')],
155    tp_perfetto='tu_end_compute')
156
157utrace_generate(cpath=args.utrace_src, hpath=args.utrace_hdr, ctx_param='struct tu_device *dev')
158utrace_generate_perfetto_utils(hpath=args.perfetto_hdr)
159