12 self
.gmem_reason
= None
21 self
.formats
= [] # format per MRT + zsbuf
22 self
.lrz_clear_time
= 0
24 self
.restore_clear_time
= 0
29 def dump_gmem_passes(gmem_passes
, blit_time
, sysmem_time
, total_time
):
33 restore_clear_time
= 0
37 for gmem
in gmem_passes
:
38 print(" GMEM[{}]: {}x{} ({}x{} tiles), {} draws, lrz clear: {:,} ns, binning: {:,} ns, restore/clear: {:,} ns, draw: {:,} ns, resolve: {:,} ns, total: {:,} ns, rt/zs: {}".format(
39 i
, gmem
.width
, gmem
.height
, gmem
.nbinx
, gmem
.nbiny
, gmem
.num_draws
,
40 gmem
.lrz_clear_time
, gmem
.binning_time
, gmem
.restore_clear_time
,
41 gmem
.draw_time
, gmem
.resolve_time
, gmem
.elapsed_time
,
42 ", ".join(gmem
.formats
)
44 lrz_clear_time
+= gmem
.lrz_clear_time
45 binning_time
+= gmem
.binning_time
46 restore_clear_time
+= gmem
.restore_clear_time
47 draw_time
+= gmem
.draw_time
48 resolve_time
+= gmem
.resolve_time
49 elapsed_time
+= gmem
.elapsed_time
52 print(" TOTAL: lrz clear: {:,} ns ({}%), binning: {:,} ns ({}%), restore/clear: {:,} ns ({}%), draw: {:,} ns ({}%), resolve: {:,} ns ({}%), blit: {:,} ns ({}%), sysmem: {:,} ns ({}%), total: {:,} ns\n".format(
53 lrz_clear_time
, 100.0 * lrz_clear_time
/ total_time
,
54 binning_time
, 100.0 * binning_time
/ total_time
,
55 restore_clear_time
, 100.0 * restore_clear_time
/ total_time
,
56 draw_time
, 100.0 * draw_time
/ total_time
,
57 resolve_time
, 100.0 * resolve_time
/ total_time
,
58 blit_time
, 100.0 * blit_time
/ total_time
,
59 sysmem_time
, 100.0 * sysmem_time
/ total_time
,
64 filename
= sys
.argv
[1]
65 if filename
.endswith(".gz"):
66 file = gzip
.open(filename
, "r")
67 file = io
.TextIOWrapper(file)
69 file = open(filename
, "r")
70 lines
= file.read().split('\n')
72 compute_match
= re
.compile(r
"COMPUTE: START")
73 gmem_start_match
= re
.compile(r
": GMEM: cleared=(\S+), gmem_reason=(\S+), num_draws=(\S+), samples=(\S+)")
74 gmem_match
= re
.compile(r
": rendering (\S+)x(\S+) tiles (\S+)x(\S+)")
75 gmem_surf_match
= re
.compile(r
": {format = (\S+),")
76 gmem_lrz_clear_match
= re
.compile(r
"\+(\S+): END LRZ CLEAR")
77 gmem_binning_match
= re
.compile(r
"\+(\S+): GMEM: END BINNING IB")
78 gmem_restore_clear_match
= re
.compile(r
"\+(\S+): TILE: END CLEAR/RESTORE")
79 gmem_draw_match
= re
.compile(r
"\+(\S+): TILE\[\S+\]: END DRAW IB")
80 gmem_resolve_match
= re
.compile(r
"\+(\S+): TILE: END RESOLVE")
81 sysmem_match
= re
.compile(r
": rendering sysmem (\S+)x(\S+)")
82 blit_match
= re
.compile(r
": END BLIT")
83 elapsed_match
= re
.compile(r
"ELAPSED: (\S+) ns")
84 eof_match
= re
.compile(r
"END OF FRAME (\S+)")
92 gmem_passes
= [] # set of GMEM passes in frame
93 gmem
= None # current GMEM pass
96 match
= re
.search(compute_match
, line
)
98 #printf("GRID/COMPUTE")
100 print("expected times to not be set yet")
101 times
= times_compute
104 match
= re
.search(gmem_start_match
, line
)
105 if match
is not None:
107 print("expected gmem to not be set yet")
108 if times
is not None:
109 print("expected times to not be set yet")
112 gmem
.cleared
= match
.group(1)
113 gmem
.gmem_reason
= match
.group(2)
114 gmem
.num_draws
= match
.group(3)
115 gmem
.samples
= match
.group(4)
118 match
= re
.search(gmem_match
, line
)
119 if match
is not None:
120 gmem
.width
= int(match
.group(1))
121 gmem
.height
= int(match
.group(2))
122 gmem
.nbinx
= int(match
.group(3))
123 gmem
.nbiny
= int(match
.group(4))
126 match
= re
.search(gmem_surf_match
, line
)
127 if match
is not None:
128 gmem
.formats
.append(match
.group(1))
131 match
= re
.search(gmem_lrz_clear_match
, line
)
132 if match
is not None:
133 gmem
.lrz_clear_time
+= int(match
.group(1))
136 match
= re
.search(gmem_binning_match
, line
)
137 if match
is not None:
138 gmem
.binning_time
+= int(match
.group(1))
141 match
= re
.search(gmem_restore_clear_match
, line
)
142 if match
is not None:
143 gmem
.restore_clear_time
+= int(match
.group(1))
146 match
= re
.search(gmem_draw_match
, line
)
147 if match
is not None:
148 gmem
.draw_time
+= int(match
.group(1))
151 match
= re
.search(gmem_resolve_match
, line
)
152 if match
is not None:
153 gmem
.resolve_time
+= int(match
.group(1))
157 match
= re
.search(sysmem_match
, line
)
158 if match
is not None:
160 if times
is not None:
161 print("expected times to not be set yet")
165 match
= re
.search(blit_match
, line
)
166 if match
is not None:
168 if times
is not None:
169 print("expected times to not be set yet")
173 match
= re
.search(eof_match
, line
)
174 if match
is not None:
175 frame_nr
= int(match
.group(1))
176 print("FRAME[{}]: {} blits ({:,} ns), {} SYSMEM ({:,} ns), {} GMEM ({:,} ns), {} COMPUTE ({:,} ns)".format(
178 len(times_blit
), sum(times_blit
),
179 len(times_sysmem
), sum(times_sysmem
),
180 len(times_gmem
), sum(times_gmem
),
181 len(times_compute
), sum(times_compute
)
183 if len(gmem_passes
) > 0:
184 total_time
= sum(times_blit
) + sum(times_sysmem
) + sum(times_gmem
) + sum(times_compute
)
185 dump_gmem_passes(gmem_passes
, sum(times_blit
), sum(times_sysmem
), total_time
)
195 match
= re
.search(elapsed_match
, line
)
196 if match
is not None:
197 time
= int(match
.group(1))
198 #print("ELAPSED: " + str(time) + " ns")
202 gmem
.elapsed_time
= time
203 gmem_passes
.append(gmem
)
208 if __name__
== "__main__":