Skip to content

ttpf_mips: 3D SW_4KB_S volumes use AMD's bit order for 2-, 4- and 16-byte elements - #2645

Merged
ItsNotRexed merged 6 commits into
ItsNotRexed:mainfrom
Amzi-01:ttpf-volume-patterns
Nov 23, 2026
Merged

ItsNotRexed merged 6 commits into
ItsNotRexed:mainfrom
Amzi-01:ttpf-volume-patterns

Conversation

@Amzi-01

@Amzi-01 Amzi-01 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

tools/ttpf_mips.py's VOLUME_PATTERNS_4K (3D SW_4KB_S intra-tile bit order) and the matching tile extents in tools/tex_headers.py's _VOLUME_4K_TILE were wrong for 2-, 4- and 16-byte elements. This sets them to AMD's.

Source. Mesa src/amd/addrlib/src/gfx10/gfx10SwizzlePattern.h, GFX10_SW_4K_S3_PATINFO (nibble01 + nibble2 entries for 1/2/4/8/16 bpe); GFX10_SW_4K_S3_RBPLUS_PATINFO gives the same rows, and rpf9-explorer's VolumePatterns already has them. Rows 0 (1 B) and 3 (8 B) already matched. The old rows 1, 2 and 4 occur in no GFX10 pattern in that header. The tile extents follow from the bit counts: 2 B 16×8×16 → 8×16×16, 4 B 8×8×16 → 8×16×8, 16 B 8×4×8 → 4×8×8.

Effect on the 1.0.2.1 corpus (3 volumes, counts only):

Changes: the two tables (with a comment naming the addrlib source), docs/textures_arrays.md (the #901 row and a note on the correction), and tests/test_ttpf_mips.py VolumePatternTest: pins the table to addrlib's rows, checks every row uses each X/Y/Z bit once from bit 0, and checks _VOLUME_4K_TILE and volume_surface_layout follow from the bit counts. On main the pin test fails (the existing round-trip test can't catch it: it re-tiles with the same table).

Tested: python -I tests/test_ttpf_mips.py 66/66 OK; tests/test_tex_headers.py 60/60 OK; tests/test_docs_links.py OK. No GPU needed. No game data committed.

Claim: in #2516. AI-assisted (Claude Code).

🤖 Generated with Claude Code

…byte elements

VOLUME_PATTERNS_4K rows 1, 2 and 4 and the matching tile extents in
tex_headers._VOLUME_4K_TILE matched no GFX10 pattern in Mesa addrlib. They
now follow GFX10_SW_4K_S3_PATINFO (the RbPlus table is identical, and so is
rpf9-explorer's VolumePatterns): 2-byte tiles are 8x16x16, 4-byte 8x16x8,
16-byte 4x8x8. In the 1.0.2.1 corpus this changes the one R16_FLOAT volume
(ttdb_graphics ItsNotRexed#901): adjacent-Y voxel differences fall from 0.357 to 0.067 of
the random-pair level, adjacent-Z from 0.029 to 0.007, and the check's 3D
Z-diff from 0.023623 to 0.004238 (29.3x below the 2D control instead of 5.3x).
The two 8-byte volumes are unchanged. New VolumePatternTest pins the table to
addrlib's rows and checks the extents follow from it; it fails on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kacper-serewis

Copy link
Copy Markdown
Contributor

Independent CPU validation on Windows, retail 1.0.2.1. Scanned all 357,115 descriptors in 57 TTPF pools and found three dimension-3 descriptors, each with one mip. Compared the complete voxel payload after the 148-byte DDS header from Python texture_dds against TtpfReader.CreateDds built from pinned rpf9-explorer e293917.

On the 2-byte volume, 65,525 of 65,536 voxels differed on parent 49475796 and zero differed on head b43a9dad. Both 8-byte controls matched on both revisions (65,536 and 32,768 voxels). All 163,840 head voxels matched byte for byte. The DDS headers differed between implementations on both revisions. The retail corpus exercises one of the three corrected rows and contains no 4- or 16-byte volumes. AI-assisted.

@TurboSosiska304

Copy link
Copy Markdown

Verified b43a9da on CachyOS Linux, Python 3.14.10.

  • python3 -I tests/test_ttpf_mips.py: 66 tests OK.
  • python3 -I tests/test_tex_headers.py: 60 tests OK.
  • python3 -I tests/test_calibrated_texture_extra.py: 24 tests OK (another consumer of these tables).

Checks: all five VOLUME_PATTERNS_4K rows use each X, Y and Z bit exactly once from bit 0, and the new tile extents are 4096 bytes each (8x16x16x2, 8x16x8x4, 4x8x8x16), consistent with a 4 KB tile. The new unit test hard-codes the same rows it compares against, so that part is self-consistent; I could not decode addrlib's pattern indices here to confirm the rows independently.

Negative control: not applicable, no translator change.

Not run: the corpus Z-diff numbers in the docs (no game data available).

No functional issues found.

@evilclanker9000

evilclanker9000 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Reproduced b43a9da merged onto main (clean git merge-tree) with my own Xbox Series 1.0.2.1 copy, on Windows 11 / Python 3.12. ttpf_mips.py check ttdb_graphics.ttpf <i>, main's tool against the merged one:

volume format volume_3d_z_diff main merged
#901 (2-byte) 54 0.023623 0.004238
#575 (8-byte) 10 0.036721 0.036721
#200 (8-byte) 10 0.016793 0.016793

These are exactly your numbers; only the 2-byte volume moves. ttpf_mips.py scan over all 46 data/ttdb pools gives identical console output and JSON. pytest tests/test_ttpf_mips.py tests/test_tex_headers.py on the merged tree: 126 passed, 219 subtests. AI-assisted check (Claude Code), Vonsek3.

radv-tinker and others added 4 commits November 23, 2026 00:27
The preflight asked for all 300 GB of the assets stage free unless xma.done said the exports were finished, so a
build stopped part-way through the assets (279 GB written, 280 GB free) refused to resume. tree_bytes() sums what
is already under <work>/assets and the preflight subtracts it. Two tests: the subtraction and tree_bytes itself.

Tested: python3 -I tests/test_make_game_preflight.py (67 tests); a real resume on Fedora 43 that had been refused.
AI-assisted.
…piling alone

Modules over --large-module-bytes compiled one at a time with every other thread waiting. On the translated
corpus that is 695 modules (the ray-tracing compute shaders, ~14k RDNA2 instructions each, ~4.9 MB of SPIR-V),
about 12 s and 2 GB each on RADV GFX1201, so the pipelines stage spent hours mostly single-threaded.

large_module_gate.h lets large modules in while 512 bytes per SPIR-V byte fits 3/4 of the memory available at
start (Linux: MemAvailable and the cgroup v2 memory.max room up the tree; Windows: ullAvailPhys), one always
admitted when none is in, small modules never held back. Unknown memory keeps the old exclusive gate, as does
--large-parallel 1. malloc_trim(0) after each large module returns what glibc kept in per-thread arenas.

40 modules (27 large), Mesa shader cache off, RX 9070 XT / Mesa 25.3.6: 297 s -> 83 s on 6 threads (7.1 -> 8.3 GB
peak), 56 s on 12 threads (15.1 GB).

Tested: large_module_gate_test (Linux, and the clang-cl build under Proton), ctest on Linux (40 passed, 2
skipped), vk_pipeline_check over 40 real modules in three modes, and the pipelines stage over the corpus with the
gate: 26,000+ of 26,503 modules in 15 min, none failed. The largest module (26 MB of SPIR-V) was still compiling
alone on RADV after 25 min, as it would under the old gate. AI-assisted.
…k-memory-budget

vk_pipeline_check: large modules share a memory budget instead of compiling alone
…flight-resume

make_game: count assets already exported when a stopped build resumes
@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 67dfec16 (head, base 03b09a0) on NVIDIA GeForce RTX 3060 Ti, driver 580.173.02, Linux (kernel 6.18), Python 3.13: pass.

  • pytest tests/test_ttpf_mips.py: 72 passed, 96 subtests passed. The same test file with the base's tools/: 1 failed, test_ttpf_mips.py:2411, VOLUME_PATTERNS_4K against the Mesa SW_4KB_S table. So the new test catches the old order.
  • ctest: 48/48 passed, including the new large_module_gate test.
  • scripts/run_gpu_tests.py: 164/210 passed, 46 skipped, 0 failed.

No game files, so I couldn't run ttpf_mips.py check on real volumes. AI-assisted (Claude Code).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 67dfec1 (merge base 03b09a0) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass

Tested the PR head merged with current main 7b7d73f8 (clean merge, not pushed). Runtime harnesses built from main 7b7d73f8 (rebuilt with the PR merged), llvm-mc 21, Python 3.13, Vulkan SDK 1.4.363, Linux native.

Check main 7b7d73f8 this PR
run_gpu_tests.py native 170/217 passed, 47 skipped 170/217 passed, 47 skipped
run_gpu_tests.py with LEONIDA_W64_EMULATE=1 201/217 passed, 16 skipped 201/217 passed, 16 skipped
failed (native / emulated) 0 / 0 0 / 0
tests/semantic/regen_fixtures.py --check ok ok
pytest tests/test_ttpf_mips.py tests/test_shader_checks.py tests/test_run_gpu_tests.py tests/test_cf_diff.py 162 passed, 315 subtests passed (3 shared files) 234 passed, 411 subtests passed in 13.30s

Line-by-line against my main run (results that differ from main):

  • native:
    • none
  • emulated:
    • none

Not run: vk_pipeline_check (changed by the PR; needs game files / args) and the full unittest discover -s tests/semantic; only the test files this PR touches plus the shared checker tests ran. large_module_gate_test (new in the PR) built and printed large_module_gate: ok. No other GPU vendor, no Windows. No game files.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 67dfec1 merged with main 98fa503 (merged tree 7f408ee48b) on native Windows 11, Python 3.13.1: pass. tests/test_ttpf_mips.py 72 tests OK, including the three new VolumePatternTest tests. CPU-only change, so no GPU is involved; I did not run it on the game copy.

Control: main's tools/ttpf_mips.py and tools/tex_headers.py with the PR's test file: 1 failure (test_patterns_are_amds_sw_4k_s3), 72 run. The other two new tests pass either way (they check the rows against each other, not against Mesa).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 67dfec1 merged with main 98fa503 on Linux (Python 3.12.16): pass. tests/test_ttpf_mips.py 1/1 file ok (72 tests). Negative control with main's tools/ttpf_mips.py and tools/tex_headers.py: the file fails (1 failure).

@lunarminus

Copy link
Copy Markdown

Tested 67dfec16 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • The merge onto d0835dd9 is clean and changes 4 files: tools/ttpf_mips.py, tools/tex_headers.py, tests/test_ttpf_mips.py and docs/textures_arrays.md. The runtime/, make_game.py and docs/pipeline_check.md changes in the GitHub diff come from main and are already in d0835dd9, so the runtime test programs are d0835dd9's build.
  • python -I tests/test_ttpf_mips.py: 72 tests OK. tests/test_tex_headers.py: 64 OK. tests/test_calibrated_texture_extra.py: 24 OK. tests/test_docs_links.py: 6 OK.
  • Negative control: the PR's tests/test_ttpf_mips.py with d0835dd9's tools/ fails 1 of 72 tests, test_patterns_are_amds_sw_4k_s3.
  • Cross-check: the new VOLUME_PATTERNS_4K rows are the same as VolumePatterns in the rpf9-explorer submodule at e293917, in both Core/RageTextureDecoder.cs and Core/TtpfReader.cs.
  • scripts/run_gpu_tests.py, native: 196/210 passed, 14 skipped, 0 failed. With LEONIDA_W64_EMULATE=1: 196/210 passed, 14 skipped, 0 failed. In both modes the PASS/FAIL/SKIP result of every test is the same as d0835dd9 without the PR. The PR adds no GPU fixtures.
  • Not run: ttpf_mips.py check on real volumes (no game files).

AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit d5af57f into ItsNotRexed:main Nov 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.