calibrated_texture: crop NPOT mips to the DDS grid (CALIBRATED-TEXTURE-NPOT-DDS) #2325
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2325
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/calibrated-texture-npot-dds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: CALIBRATED-TEXTURE-NPOT-DDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193838373)
What and why
tools/calibrated_texture.pyLocalDecoder.dds(the--calibrationexport) wrote every block of a mip's stored grid under a standard DDS header. For NPOT chains the stored grid can be wider or taller than the DDS mip, which is the casettpf_mips._visible_rowsexists for in the regular export:compact_dds_layout's return values, not the payload.addresses()takes its tile pitch from the grid it is given. A 513x520 BC7 array stores mip 1 as 65x65 blocks (two 64-block tiles per row) where DDS holds 64x65, so rows 64 and on were read from the wrong tile (128 blocks differ per export).Each mip is now read on its stored grid, which also sets the tile pitch, and cropped to the DDS rows and columns. Aligned textures are unchanged (the crop is skipped when the grids match). For both cases above the export is now byte-identical to
ttpf_mips.texture_dds.Tested
Windows 11, Python 3.14.7, synthetic pools only (numpy is not installed here, so the test runs on the file's own numpy stand-in; CI's numpy job runs it with numpy):
python -I tests/test_calibrated_texture_extra.py: the newTestLocalDecoder.test_dds_npot_mips_are_cropped_to_the_dds_gridwrites a 17x13 BC1 chain and a 2-slice 513x520 BC7 mode-1 array whose every block holds its own (slice, mip, x, y) and compares the export with the DDS rows of each mip. Onmainboth cases fail (208 != 192; block 20866 is (0, 1, 64, 0) instead of (0, 1, 0, 64)); with the fix both pass. 30 of 31 tests pass;test_export_file_replacement_failure_cleans_temporary_filefails onmainas well (claimed in #1608, open #2101).tests/test_calibrated_texture.py(skips without numpy),tests/test_ttpf_mips.py(93),tests/test_ttpf_assets.py(31),tests/test_tool_startup.pyOK.python -m compileall;scripts/check_no_game_data.pyon both files.GPUs tested: n/a (CPU-only tool)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.
(AI-assisted triage.)
Now ready for review and
MERGEABLE. Clean-room verified: cropping NPOT mips to the DDS grid intools/calibrated_texture.py:272-322(with fail-closed bounds guard and regression coverage intests/test_calibrated_texture_extra.py) is clean and verified on Windows and macOS (@lixonik,@wavehs; the unrelated no-numpyreplace_retryfailure@wavehsnoted is pre-existing onmain).Approving — ready to merge once CI runs green on current
main.(AI-assisted review.)
Added portrait cases to the synthetic DDS comparison at
a80bb68f7+e04721c7on Linux. I ran the same block-tagged fixture on main and the PR with both orientations of the compact BC1 and mode-1 BC7 array cases. The new 13×17 BC1 case with four mips had 232 payload bytes on main, where 208 were expected. Main also failed the two original cases. With the PR all four checked byte-for-byte, including the additional three-mip portrait BC7 array. The checked-in test file passed 31/31. Synthetic blocks only.AI-assisted with OpenAI Codex.