Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track end operations to align artifacts with pgraph log #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions Trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(
self.nv2a_log = NV2ALog(os.path.join(output_dir, "nv2a_log.txt"))
self.flip_stall_count = 0
self.command_count = 0
self.end_op_count = 0

self.real_dma_pull_addr = dma_pull_addr
self.real_dma_push_addr = dma_push_addr
Expand Down Expand Up @@ -353,10 +354,12 @@ def dump(img_tags, adjusted_offset, layer):
layer_name = ""

if self.alpha_mode != self.ALPHA_MODE_KEEP:
no_alpha_path = "command%d--tex_%d%scolor.png" % (
no_alpha_path = "command%d-draw%d--tex_%d%scolor_0x%X.png" % (
self.command_count,
self.end_op_count,
index,
layer_name,
adjusted_offset,
)
img_tags += '<img height="128px" src="%s" alt="%s"/>' % (
no_alpha_path,
Expand All @@ -366,10 +369,12 @@ def dump(img_tags, adjusted_offset, layer):
no_alpha_path = None

if self.alpha_mode != self.ALPHA_MODE_DROP:
alpha_path = "command%d--tex_%d%scolor-a.png" % (
alpha_path = "command%d-draw%d--tex_%d%scolor_0x%X-a.png" % (
self.command_count,
self.end_op_count,
index,
layer_name,
adjusted_offset,
)
img_tags += '<img height="128px" src="%s" alt="%s"/>' % (
alpha_path,
Expand Down Expand Up @@ -456,7 +461,11 @@ def dump_surfaces(self, _data, *_args):
# FIXME: Respect anti-aliasing
img_tags = ""
if self.alpha_mode != self.ALPHA_MODE_KEEP:
no_alpha_path = "command%d--color.png" % (self.command_count)
no_alpha_path = "command%d_draw%d--color_0x%X.png" % (
self.command_count,
self.end_op_count,
(params.color_offset or 0),
)
img_tags += '<img height="128px" src="%s" alt="%s"/>' % (
no_alpha_path,
no_alpha_path,
Expand All @@ -465,15 +474,18 @@ def dump_surfaces(self, _data, *_args):
no_alpha_path = None

if self.alpha_mode != self.ALPHA_MODE_DROP:
alpha_path = "command%d--color-a.png" % (self.command_count)
alpha_path = "command%d_draw%d--color_0x%X-a.png" % (
self.command_count,
self.end_op_count,
(params.color_offset or 0),
)
img_tags += '<img height="128px" src="%s" alt="%s"/>' % (
alpha_path,
alpha_path,
)
else:
alpha_path = None

path = "command%d--color.png" % (self.command_count)
extra_html = []

extra_html += [img_tags]
Expand Down Expand Up @@ -558,7 +570,14 @@ def _handle_begin(self, data, *args):
if not data:
return []

print("BEGIN %d" % self.command_count)
print(
"BEGIN %d (%d:%d)"
% (self.command_count, self.flip_stall_count, self.end_op_count)
)
self.nv2a_log.log(
"BEGIN: command %d frame_draw %d\n"
% (self.command_count, self.end_op_count)
)

extra_html = []
extra_html += self.dump_textures(data, *args)
Expand All @@ -572,6 +591,7 @@ def _handle_end(self, data, *args):

extra_html = []
extra_html += self.dump_surfaces(data, *args)
self.end_op_count += 1
return extra_html

def _begin_pgraph_recording(self, _data, *_args):
Expand Down Expand Up @@ -701,6 +721,7 @@ def _end_pgraph_recording(self, _data, *_args):
def _handle_flip_stall(self, _data, *_args):
print("Flip (Stall)")
self.flip_stall_count += 1
self.end_op_count = 0

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

Expand Down Expand Up @@ -900,7 +921,11 @@ def process_push_buffer_command(self, pull_addr):
def _write(self, suffix, contents):
"""Writes a raw byte dump."""
out_path = (
os.path.join(self.output_dir, "command%d_" % self.command_count) + suffix
os.path.join(
self.output_dir,
"command%d_draw%d_" % (self.command_count, self.end_op_count),
)
+ suffix
)
with open(out_path, "wb") as dumpfile:
dumpfile.write(contents)