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] Fix sameTextures condition, make assert more user friendly #466

Merged
merged 2 commits into from
Oct 14, 2024
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
25 changes: 19 additions & 6 deletions fast64_internal/f3d/f3d_texture_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,25 @@ def writeAll(

# Assign TMEM addresses
sameTextures = (
self.ti0.useTex
and self.ti1.useTex
(self.ti0.useTex and self.ti1.useTex)
and self.ti0.isTexRef == self.ti1.isTexRef
and self.ti0.tmemSize == self.ti1.tmemSize
and self.ti0.texFormat == self.ti1.texFormat
and (
(not self.ti0.isTexRef and not self.ti1.isTexRef and self.ti0.texProp.tex == self.ti1.texProp.tex)
or (
( # not a reference
not self.ti0.isTexRef and self.ti0.texProp.tex == self.ti1.texProp.tex # same image
)
or ( # reference
self.ti0.isTexRef
and self.ti1.isTexRef
and self.ti0.texProp.tex_reference == self.ti1.texProp.tex_reference
and self.ti0.texProp.tex_reference_size == self.ti1.texProp.tex_reference_size
and ( # ci format reference
not self.isCI
or (
self.ti0.texProp.pal_reference == self.ti1.texProp.pal_reference
and self.ti0.texProp.pal_reference_size == self.ti1.texProp.pal_reference_size
)
)
)
)
)
Expand All @@ -779,7 +790,9 @@ def writeAll(
self.ti1.texAddr = None # must be set whenever tex 1 used (and loaded or tiled)
tmemOccupied = self.texDimensions = None # must be set on all codepaths
if sameTextures:
assert self.ti0.tmemSize == self.ti1.tmemSize
assert (
self.ti0.tmemSize == self.ti1.tmemSize
), f"Unreachable code path in material {material.name}, same textures (same image or reference) somehow not the same size"
tmemOccupied = self.ti0.tmemSize
self.ti1.doTexLoad = False
self.ti1.texAddr = 0
Expand Down
Loading