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

[F3D] [Bugfix] Fix Sync Optimization for Mat Bleed #487

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
18 changes: 9 additions & 9 deletions fast64_internal/f3d/f3d_bleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ def bleed_fmesh(
# make better error msg
print("could not find material used in fmesh draw")
continue
bleed_gfx_lists.bled_mats = self.bleed_mat(cur_fmat, last_mat, bleed_state)
if not (cur_fmat.isTexLarge[0] or cur_fmat.isTexLarge[1]):
bleed_gfx_lists.bled_tex = self.bleed_textures(cur_fmat, last_mat, bleed_state)
else:
bleed_gfx_lists.bled_tex = cur_fmat.texture_DL.commands
bleed_gfx_lists.bled_mats = self.bleed_mat(cur_fmat, last_mat, bleed_state)
# some syncs may become redundant after bleeding
self.optimize_syncs(bleed_gfx_lists, bleed_state)
# bleed tri group (for large textures) and to remove other unnecessary cmds
if jump_list_cmd.displayList.tag & GfxListTag.Geometry:
tri_list = jump_list_cmd.displayList
Expand Down Expand Up @@ -251,8 +253,6 @@ def bleed_mat(self, cur_fmat: FMaterial, last_mat: FMaterial, bleed_state: int):
commands_bled.commands.remove(None)
else:
commands_bled = self.bleed_cmd_list(cur_fmat.mat_only_DL, bleed_state)
# some syncs may become redundant after bleeding
self.optimize_syncs(commands_bled, bleed_state)
# remove SPEndDisplayList
while SPEndDisplayList() in commands_bled.commands:
commands_bled.commands.remove(SPEndDisplayList())
Expand Down Expand Up @@ -354,22 +354,22 @@ def on_bleed_end(
self.bled_gfx_lists[cmd_list] = last_mat

# remove syncs if first material, or if no gsDP cmds in material
def optimize_syncs(self, cmd_list: GfxList, bleed_state: int):
def optimize_syncs(self, bleed_gfx_lists: BleedGfxLists, bleed_state: int):
no_syncs_needed = {"DPSetPrimColor", "DPSetPrimDepth"} # will not affect rdp
syncs_needed = {"SPSetOtherMode"} # will affect rdp
if bleed_state == self.bleed_start:
while DPPipeSync() in cmd_list.commands:
cmd_list.commands.remove(DPPipeSync())
for cmd in cmd_list.commands:
while DPPipeSync() in bleed_gfx_lists.bled_mats:
bleed_gfx_lists.bled_mats.remove(DPPipeSync())
for cmd in (*bleed_gfx_lists.bled_mats, *bleed_gfx_lists.bled_tex):
cmd_name = type(cmd).__name__
if cmd == DPPipeSync():
continue
if "DP" in cmd_name and cmd_name not in no_syncs_needed:
return
if cmd_name in syncs_needed:
return
while DPPipeSync() in cmd_list.commands:
cmd_list.commands.remove(DPPipeSync())
while DPPipeSync() in bleed_gfx_lists.bled_mats:
bleed_gfx_lists.bled_mats.remove(DPPipeSync())

def create_reset_cmds(self, reset_cmd_dict: dict[GbiMacro], default_render_mode: list[str]):
reset_cmds = []
Expand Down
Loading