ttpf: single mips without a tail, cube mip counts, 3D volumes #37
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/holdmysocks--SixNG!37
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/37/head"
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?
@holdmysocks on GitHub · 2026-11-23 04:43 UTC · original
holdmysocks:fix/ttpf-layout→master· +246 −82 · 3 files · 1 commits · merged 2026-11-23 12:08 UTCFixes three ttpf texture-store layout problems. The layout rules come from AMD's public addrlib (Gfx10 swizzle patterns, MIT) and from measurements on the game files.
1. Single-mip textures decoded blank
addrlib builds a mip tail only when a surface has more than one mip, so a single mip starts at offset 0 even when it would fit in the tail. Also, in tile mode 1 a mip field of 1 means one mip:
SW_4KB_Sfootprint.Check: 2,251 small textures, all decoding blank before (0.000 of pixels non-zero), now 0.94 non-zero on average with coherent images. This includes 125 16×8 RGBA8 textures and 3 single-mip cubes.
2. Cubes lost their smallest mips
The cube mip count is the mip field + copies − 1, where copies = tile mode − 8. On every cube the stored mips run to exactly that mip, and the tail slot after it is empty:
Check: On the 43 64×64 BC7 cubes with mip field 6, the restored 1×1 mip differs from the 2×2 mip box-filtered by 2.20 levels on average. For comparison, mip 5 against mip 4 differs by 3.02. Three cubes that had no layout before (128×128 and 256×256) now decode.
3. 3D textures were read as 2D arrays
Descriptor d1 bits 20–23 give the resource kind: 2 = 2D, 4 = cube, 6 = 3D, 10 = 2D array. On 3D textures the array-size field is the depth.
The volumes use the 3D
SW_4KB_Spattern (addrlib'sSW_4K_S3, without XOR), which interleaves Z into each 4 KiB brick:Only those two element sizes, with one mip, are mapped; other volumes are rejected. This replaces the brute-forced "split 2-byte array" special case. That case was the R16F volume: its depth of 8 leaves the top Z bit 0, which is the "every other KiB unused" pattern.
The old R16F order had been fitted to in-slice smoothness only. The new decode is a clean, smooth lookup curve, nearly identical in every slice. The old decode showed seams every 8 rows; the new one has none.
Regression check
I compared the layout of all 357,115 textures (mip count, size, mip 0 placement) before and after. Only the groups above changed.
Tests
cargo test --release --lockedpasses.