Fit BC1's BCPack tables from the game's own texture stores #466
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!466
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-466"
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?
@zmelumian972 on GitHub · 2026-11-30 08:29 UTC · original
zmelumian972:bcpack-bc1-fit→main· +61117 −5449 · 210 files · 662 commits · closed without mergingBuilds on #465 (its commit is included here; review that one first).
Without
VICTORY_BCPACK_TABLES, every BCPack texture comes out as block noise (#385).victory bcpack-fitnow fits what BC1 needs from the player's own.ttpfstores and writes it tocache_dir/bcpack/. Runs decode BC1 requests with it when the format tables aren't set. BC3–BC7 still need the tables; in GTA VI's stores that's about 1,400 of the roughly 32,400 textures that use BCPack. The fitted file is derived data and never enters the repository.The fit learns from mips stored as one BC1 BCPack chunk whose next smaller mip is stored plain. The entropy layer uses Microsoft's published models, and with them every packed BC1 chunk in the title decodes. Blocks whose back-reference chain starts with no reference have exact endpoints. On those, each quadrant index symbol gets its 2x2 pattern from the next mip and from the edges it makes with neighbouring pixels. The patterns form a one-to-one table, solved as an assignment and refitted until it stops changing. Once the indices are known, each dictionary entry is searched per colour channel over the blocks whose chains start at it, then refined through the real BC1 palette, which switches to three colours when endpoint 0 is not above endpoint 1. Each entry samples at most 100 blocks per mip and 2,000 per store, so no single texture decides it.
Held out, fitted on half the stores and scored on the other half: decoded mips, shrunk to half size, against the game's stored next mip had a median of 36.5 dB (p10 30.3). Plain textures, the best this measure can score, reach 37.7 dB (p10 30.1). With an empty dictionary the median is 6.7 dB. Within the same packed textures, blocks whose chains start at a dictionary entry score MSE 23.0 against the next mip, and blocks with exact endpoints 17.9. Even the best value per texture for each entry only reaches about 19, so most of the remaining gap is in the blocks, not the tables. Fits on the two halves agree on 254 of 256 index-table entries. The full fit takes about 1 minute 40 seconds under Wine, two runs give byte-identical tables,, and
play.shandplay.ps1run it once with--if-needed.Testing: the fitter's tests pass, as do the BCPack tests in
victory-formatsand thedstorageBCPack tests under Wine. The asset policy check passes, and the Windows build compiles without warnings. Decoded textures matched their next mip visually. I couldn't check textures in game: on my RTX 5090 under Wine, scripted 150-second runs with and without the fitted tables both ended with exit code 5 (#221) before any textured scene. No screen recorder worked on that session, so there is no video.🤖 Generated with Claude Code
VICTORY_BCPACK_TABLES, textures turn to square noise and only one log line says why #385@zmelumian972 on GitHub · 2026-11-30 17:04 UTC · original
Superseded by the new main, which ships the full BCPack tables built in (
Tables::builtin). There are no tables left to fit from the game's texture stores.Pull request closed