Skip to content

Commit

Permalink
[F3D] Fix sameTextures condition, make assert more user friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Sep 23, 2024
1 parent ddd6969 commit 3c76b12
Showing 1 changed file with 19 additions and 6 deletions.
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"Unrechable 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

0 comments on commit 3c76b12

Please sign in to comment.