Fix tTPF mip counts and 3D volume detiling #27

Closed
github-bot wants to merge 1 commit from gh-pr/27/head into gh-pr/27/base
Owner

@⁠ifBars on GitHub · 2026-11-23 03:20 UTC · original
ifBars:fix/ttpf-mips-and-volumes → master · +295 −15 · 2 files · 1 commits · closed without merging

Found a few tTPF layout issues while comparing exports with Leonida and my texture reader. A 16x8 RGBA8 texture came out blank, a 64x64 BC7 cube lost its final 1x1 face mip, and 3D volumes were being read as 2D arrays.

This reads the mip count from both descriptor fields, keeps a standalone mip at offset 0, and adds Z-interleaved addressing for the measured single-mip, uncompressed 3D layout. Other 3D modes, compressed volumes and multiple volume mips are rejected instead of falling through to the array path. The volume rules retain their Leonida attribution.

Checked locally on Windows:

  • cargo test --locked -p sixng-core --no-default-features --lib: 101 passed, one existing test ignored.
  • All 608 requested mip/slice previews across 11 grouped graphics textures match the separate reader after the fix. Before it, 39 failed and three mip counts disagreed.
  • All slices of two RGBA16F volumes and an R16F volume match. The blank RGBA8 case also matches Leonida. Tests use synthetic data; no game assets are included.

The real volume samples cover 2- and 8-byte elements. The other element sizes have synthetic address tests; I haven't checked them on real volumes. This doesn't add support for volume mip chains.

**@⁠ifBars** on GitHub · 2026-11-23 03:20 UTC · [original](https://github.com/holdmysocks/SixNG/pull/27) `ifBars:fix/ttpf-mips-and-volumes` → `master` · +295 −15 · 2 files · 1 commits · closed without merging Found a few tTPF layout issues while comparing exports with Leonida and my texture reader. A 16x8 RGBA8 texture came out blank, a 64x64 BC7 cube lost its final 1x1 face mip, and 3D volumes were being read as 2D arrays. This reads the mip count from both descriptor fields, keeps a standalone mip at offset 0, and adds Z-interleaved addressing for the measured single-mip, uncompressed 3D layout. Other 3D modes, compressed volumes and multiple volume mips are rejected instead of falling through to the array path. The volume rules retain their Leonida attribution. Checked locally on Windows: - `cargo test --locked -p sixng-core --no-default-features --lib`: 101 passed, one existing test ignored. - All 608 requested mip/slice previews across 11 grouped graphics textures match the separate reader after the fix. Before it, 39 failed and three mip counts disagreed. - All slices of two RGBA16F volumes and an R16F volume match. The blank RGBA8 case also matches Leonida. Tests use synthetic data; no game assets are included. The real volume samples cover 2- and 8-byte elements. The other element sizes have synthetic address tests; I haven't checked them on real volumes. This doesn't add support for volume mip chains.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:04:02 +00:00
github-bot closed this pull request 2026-11-26 20:04:02 +00:00
Author
Owner

@⁠holdmysocks on GitHub · 2026-11-23 12:10 UTC · original

Thanks a lot for reporting these, @⁠ifBars. All three cases were real:

  1. small single-mip textures (like the 16×8 RGBA8 one) decoding blank,
  2. the 64×64 BC7 cube losing its last 1×1 mip,
  3. 3D volume textures being read as 2D arrays.

They're fixed in #37. We implemented the fix from AMD's public addrlib Gfx10 swizzle tables (MIT) and our own measurements on the game files:

  • A single mip has no mip tail and starts at offset 0. Tile-mode-1 textures with mip field 1 hold one mip.
  • A cube's mip count is the mip field + copies − 1.
  • Volumes use the 3D SW_4KB_S pattern, with Z interleaved into each 4 KiB brick.

The PR has the checks and their numbers.

We can't merge #27 itself, sorry. Everything in this repo has to come from public, legitimately available material, and the volume table in #27 is sourced from another project's tools and an unpublished SDK. So we rebuilt the fix independently instead of taking the patch. Thanks again for tracking these down; the reports made the fix straightforward to verify.

**@⁠holdmysocks** on GitHub · 2026-11-23 12:10 UTC · [original](https://github.com/holdmysocks/SixNG/pull/27#issuecomment-7100614225) Thanks a lot for reporting these, @⁠ifBars. All three cases were real: 1. small single-mip textures (like the 16×8 RGBA8 one) decoding blank, 2. the 64×64 BC7 cube losing its last 1×1 mip, 3. 3D volume textures being read as 2D arrays. They're fixed in https://git.gtahub.st/github/holdmysocks--SixNG/pulls/37. We implemented the fix from AMD's public addrlib Gfx10 swizzle tables (MIT) and our own measurements on the game files: - A single mip has no mip tail and starts at offset 0. Tile-mode-1 textures with mip field 1 hold one mip. - A cube's mip count is the mip field + copies − 1. - Volumes use the 3D `SW_4KB_S` pattern, with Z interleaved into each 4 KiB brick. The PR has the checks and their numbers. We can't merge #27 itself, sorry. Everything in this repo has to come from public, legitimately available material, and the volume table in #27 is sourced from another project's tools and an unpublished SDK. So we rebuilt the fix independently instead of taking the patch. Thanks again for tracking these down; the reports made the fix straightforward to verify.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.