10 self
.gmem_reason
= None
19 self
.formats
= [] # format per MRT + zsbuf
20 self
.lrz_clear_time
= 0
22 self
.restore_clear_time
= 0
27 def dump_gmem_passes(gmem_passes
, blit_time
, sysmem_time
, total_time
):
31 restore_clear_time
= 0
35 for gmem
in gmem_passes
:
36 print(" GMEM[{}]: {}x{} ({}x{} tiles), {} draws, lrz clear: {:,} ns, binning: {:,} ns, restore/clear: {:,} ns, draw: {:,} ns, resolve: {:,} ns, total: {:,} ns, rt/zs: {}".format(
37 i
, gmem
.width
, gmem
.height
, gmem
.nbinx
, gmem
.nbiny
, gmem
.num_draws
,
38 gmem
.lrz_clear_time
, gmem
.binning_time
, gmem
.restore_clear_time
,
39 gmem
.draw_time
, gmem
.resolve_time
, gmem
.elapsed_time
,
40 ", ".join(gmem
.formats
)
42 lrz_clear_time
+= gmem
.lrz_clear_time
43 binning_time
+= gmem
.binning_time
44 restore_clear_time
+= gmem
.restore_clear_time
45 draw_time
+= gmem
.draw_time
46 resolve_time
+= gmem
.resolve_time
47 elapsed_time
+= gmem
.elapsed_time
50 print(" TOTAL: lrz clear: {:,} ns ({}%), binning: {:,} ns ({}%), restore/clear: {:,} ns ({}%), draw: {:,} ns ({}%), resolve: {:,} ns ({}%), blit: {:,} ns ({}%), sysmem: {:,} ns ({}%), total: {:,} ns\n".format(
51 lrz_clear_time
, 100.0 * lrz_clear_time
/ total_time
,
52 binning_time
, 100.0 * binning_time
/ total_time
,
53 restore_clear_time
, 100.0 * restore_clear_time
/ total_time
,
54 draw_time
, 100.0 * draw_time
/ total_time
,
55 resolve_time
, 100.0 * resolve_time
/ total_time
,
56 blit_time
, 100.0 * blit_time
/ total_time
,
57 sysmem_time
, 100.0 * sysmem_time
/ total_time
,
62 file = open(sys
.argv
[1], "r")
63 lines
= file.read().split('\n')
65 compute_match
= re
.compile(r
"COMPUTE: START")
66 gmem_start_match
= re
.compile(r
": GMEM: cleared=(\S+), gmem_reason=(\S+), num_draws=(\S+), samples=(\S+)")
67 gmem_match
= re
.compile(r
": rendering (\S+)x(\S+) tiles (\S+)x(\S+)")
68 gmem_surf_match
= re
.compile(r
": {format = (\S+),")
69 gmem_lrz_clear_match
= re
.compile(r
"\+(\S+): END LRZ CLEAR")
70 gmem_binning_match
= re
.compile(r
"\+(\S+): GMEM: END BINNING IB")
71 gmem_restore_clear_match
= re
.compile(r
"\+(\S+): TILE: END CLEAR/RESTORE")
72 gmem_draw_match
= re
.compile(r
"\+(\S+): TILE\[\S+\]: END DRAW IB")
73 gmem_resolve_match
= re
.compile(r
"\+(\S+): TILE: END RESOLVE")
74 sysmem_match
= re
.compile(r
": rendering sysmem (\S+)x(\S+)")
75 blit_match
= re
.compile(r
": END BLIT")
76 elapsed_match
= re
.compile(r
"ELAPSED: (\S+) ns")
77 eof_match
= re
.compile(r
"END OF FRAME (\S+)")
85 gmem_passes
= [] # set of GMEM passes in frame
86 gmem
= None # current GMEM pass
89 match
= re
.search(compute_match
, line
)
91 #printf("GRID/COMPUTE")
93 print("expected times to not be set yet")
97 match
= re
.search(gmem_start_match
, line
)
100 print("expected gmem to not be set yet")
101 if times
is not None:
102 print("expected times to not be set yet")
105 gmem
.cleared
= match
.group(1)
106 gmem
.gmem_reason
= match
.group(2)
107 gmem
.num_draws
= match
.group(3)
108 gmem
.samples
= match
.group(4)
111 match
= re
.search(gmem_match
, line
)
112 if match
is not None:
113 gmem
.width
= int(match
.group(1))
114 gmem
.height
= int(match
.group(2))
115 gmem
.nbinx
= int(match
.group(3))
116 gmem
.nbiny
= int(match
.group(4))
119 match
= re
.search(gmem_surf_match
, line
)
120 if match
is not None:
121 gmem
.formats
.append(match
.group(1))
124 match
= re
.search(gmem_lrz_clear_match
, line
)
125 if match
is not None:
126 gmem
.lrz_clear_time
+= int(match
.group(1))
129 match
= re
.search(gmem_binning_match
, line
)
130 if match
is not None:
131 gmem
.binning_time
+= int(match
.group(1))
134 match
= re
.search(gmem_restore_clear_match
, line
)
135 if match
is not None:
136 gmem
.restore_clear_time
+= int(match
.group(1))
139 match
= re
.search(gmem_draw_match
, line
)
140 if match
is not None:
141 gmem
.draw_time
+= int(match
.group(1))
144 match
= re
.search(gmem_resolve_match
, line
)
145 if match
is not None:
146 gmem
.resolve_time
+= int(match
.group(1))
150 match
= re
.search(sysmem_match
, line
)
151 if match
is not None:
153 if times
is not None:
154 print("expected times to not be set yet")
158 match
= re
.search(blit_match
, line
)
159 if match
is not None:
161 if times
is not None:
162 print("expected times to not be set yet")
166 match
= re
.search(eof_match
, line
)
167 if match
is not None:
168 frame_nr
= int(match
.group(1))
169 print("FRAME[{}]: {} blits ({:,} ns), {} SYSMEM ({:,} ns), {} GMEM ({:,} ns), {} COMPUTE ({:,} ns)".format(
171 len(times_blit
), sum(times_blit
),
172 len(times_sysmem
), sum(times_sysmem
),
173 len(times_gmem
), sum(times_gmem
),
174 len(times_compute
), sum(times_compute
)
176 if len(gmem_passes
) > 0:
177 total_time
= sum(times_blit
) + sum(times_sysmem
) + sum(times_gmem
) + sum(times_compute
)
178 dump_gmem_passes(gmem_passes
, sum(times_blit
), sum(times_sysmem
), total_time
)
187 match
= re
.search(elapsed_match
, line
)
188 if match
is not None:
189 time
= int(match
.group(1))
190 #print("ELAPSED: " + str(time) + " ns")
194 gmem
.elapsed_time
= time
195 gmem_passes
.append(gmem
)
200 if __name__
== "__main__":