Skip to content

Commit ce628fc

Browse files
committed
Track end operations to align artifacts with pgraph log
1 parent 65bdd23 commit ce628fc

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

Trace.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(
115115
self.nv2a_log = NV2ALog(os.path.join(output_dir, "nv2a_log.txt"))
116116
self.flip_stall_count = 0
117117
self.command_count = 0
118+
self.end_op_count = 0
118119

119120
self.real_dma_pull_addr = dma_pull_addr
120121
self.real_dma_push_addr = dma_push_addr
@@ -353,8 +354,9 @@ def dump(img_tags, adjusted_offset, layer):
353354
layer_name = ""
354355

355356
if self.alpha_mode != self.ALPHA_MODE_KEEP:
356-
no_alpha_path = "command%d--tex_%d%scolor.png" % (
357+
no_alpha_path = "command%d-draw%d--tex_%d%scolor.png" % (
357358
self.command_count,
359+
self.end_op_count,
358360
index,
359361
layer_name,
360362
)
@@ -366,8 +368,9 @@ def dump(img_tags, adjusted_offset, layer):
366368
no_alpha_path = None
367369

368370
if self.alpha_mode != self.ALPHA_MODE_DROP:
369-
alpha_path = "command%d--tex_%d%scolor-a.png" % (
371+
alpha_path = "command%d-draw%d--tex_%d%scolor-a.png" % (
370372
self.command_count,
373+
self.end_op_count,
371374
index,
372375
layer_name,
373376
)
@@ -456,7 +459,10 @@ def dump_surfaces(self, _data, *_args):
456459
# FIXME: Respect anti-aliasing
457460
img_tags = ""
458461
if self.alpha_mode != self.ALPHA_MODE_KEEP:
459-
no_alpha_path = "command%d--color.png" % (self.command_count)
462+
no_alpha_path = "command%d_draw%d--color.png" % (
463+
self.command_count,
464+
self.end_op_count,
465+
)
460466
img_tags += '<img height="128px" src="%s" alt="%s"/>' % (
461467
no_alpha_path,
462468
no_alpha_path,
@@ -465,15 +471,18 @@ def dump_surfaces(self, _data, *_args):
465471
no_alpha_path = None
466472

467473
if self.alpha_mode != self.ALPHA_MODE_DROP:
468-
alpha_path = "command%d--color-a.png" % (self.command_count)
474+
alpha_path = "command%d_draw%d--color-a.png" % (
475+
self.command_count,
476+
self.end_op_count,
477+
)
469478
img_tags += '<img height="128px" src="%s" alt="%s"/>' % (
470479
alpha_path,
471480
alpha_path,
472481
)
473482
else:
474483
alpha_path = None
475484

476-
path = "command%d--color.png" % (self.command_count)
485+
path = "command%d_draw%d--color.png" % (self.command_count, self.end_op_count)
477486
extra_html = []
478487

479488
extra_html += [img_tags]
@@ -558,7 +567,14 @@ def _handle_begin(self, data, *args):
558567
if not data:
559568
return []
560569

561-
print("BEGIN %d" % self.command_count)
570+
print(
571+
"BEGIN %d (%d:%d)"
572+
% (self.command_count, self.flip_stall_count, self.end_op_count)
573+
)
574+
self.nv2a_log.log(
575+
"BEGIN: command %d frame_draw %d\n"
576+
% (self.command_count, self.end_op_count)
577+
)
562578

563579
extra_html = []
564580
extra_html += self.dump_textures(data, *args)
@@ -572,6 +588,7 @@ def _handle_end(self, data, *args):
572588

573589
extra_html = []
574590
extra_html += self.dump_surfaces(data, *args)
591+
self.end_op_count += 1
575592
return extra_html
576593

577594
def _begin_pgraph_recording(self, _data, *_args):
@@ -701,6 +718,7 @@ def _end_pgraph_recording(self, _data, *_args):
701718
def _handle_flip_stall(self, _data, *_args):
702719
print("Flip (Stall)")
703720
self.flip_stall_count += 1
721+
self.end_op_count = 0
704722

705723
self.nv2a_log.log("Flip (stall) %d\n\n" % self.flip_stall_count)
706724

@@ -900,7 +918,11 @@ def process_push_buffer_command(self, pull_addr):
900918
def _write(self, suffix, contents):
901919
"""Writes a raw byte dump."""
902920
out_path = (
903-
os.path.join(self.output_dir, "command%d_" % self.command_count) + suffix
921+
os.path.join(
922+
self.output_dir,
923+
"command%d_draw%d_" % (self.command_count, self.end_op_count),
924+
)
925+
+ suffix
904926
)
905927
with open(out_path, "wb") as dumpfile:
906928
dumpfile.write(contents)

0 commit comments

Comments
 (0)