ASSET-316: TtpfReader accepts external BCPack BC1-BC5 history tables #22
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/breadbbbb--rpf9-explorer!22
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/22/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?
@throny on GitHub · 2026-11-22 23:08 UTC · original
asset-316-bcpack-history-tables→main· +271 −21 · 3 files · 1 commits · merged 2026-11-23 01:25 UTCWhat was missing
Leonida's
tools/bcpack_history_calib.pywrites local BCPack initial-history tables (bc1.json..bc7.json), and Leonida's pure-Python decoder reads them with--history <path>.TtpfReadercould only use the built-in BC1/BC3/BC4/BC5 tables, so the C# path could not use calibrated tables (Leonidadocs/textures.md, "Next step" 2; item ASSET-316).What changed
Core/BcpackHistory.cs(new):BcpackHistory.Load(path)reads a folder ofbcN.jsonfiles or one JSON file with"bcN"sections. It follows the Python loader (tools/bcpack_tables_bptc.pyload_bc_history,tools/bcpack.py_resolve_bc_history):bcN.jsonin a folder, or a"bcN"key or"codec": "bcN"in a file. A codec without a section keeps the built-in table.confirmed/provisionaltables as a 256-element list or an index-keyed object, holding endpoint tuples of 6 (BC1), 8 (BC3), 2 (BC4) or 4 (BC5) integers. Values are converted like Python'sint().replaceset, the external entries stand alone.InvalidDataExceptionwith the Python messages; a missing path throwsFileNotFoundException.bc6h.json/bc7.jsonare ignored until the BC6H/BC7 rebuilders exist.BcpackDecoder.Decode/DecodeWithInfo: new overloads take aBcpackHistory?.TtpfReader.CreateDds/DecodeTexturePixels/DecodeTexturePreview: new overloads take aBcpackHistory?next toallowProvisional, and it is passed down throughReadMipandDecodeChunk.nulland use the built-in tables, so nothing changes for callers that don't pass a history.Tests
tests/Rpf9DumpDiagnostics(the C# test project its CI runs), in the companion PR.tests/test_bcpack.pyencoder against a synthetic history JSON. Every expected result is whattools/bcpack.pyreturns for the same chunk and table (bytes, provisional labels, or the refusal message). They cover:replace, the 256-list form, and a combined filebc1.json, and Python-styleint()valuesbc7.json(loads no table), and a null history decoding byte for byte like the built-in tables.bcpack_history_calib.py --limit 20(provisional entries only) and picked 34 BCPack textures from the 46 pools (2,618 candidates scanned; 2 of them change with these tables). Each texture was exported with Leonida'stools/ttpf_mips.py export --allow-provisional, with and without--history, and withTtpfReader.CreateDds(..., allowProvisional: true, history).TtpfReaderalways setsDDSD_MIPMAPCOUNT, the Python exporter only when there is more than one mip. That difference is the same without the tables.Core(through Leonida'stools/rpf9dumpandtests/Rpf9DumpDiagnostics) withTreatWarningsAsErrors=true: 0 warnings, 0 errors.AppandTools/IndexBuilderwere not built.Not done here
Loadreads all four tables at once, so a malformed table is reported before any decode.AI-assisted (Claude Code). No GPU needed (CPU-only decoding). Windows 11, .NET 8 target.
Companion Leonida PR: ItsNotRexed/Leonida#4050 (bumps the submodule, adds
rpf9dump ttpf --history, tests and docs).🤖 Generated with Claude Code
@breadbbbb on GitHub · 2026-11-23 01:24 UTC · original · approved these changes
Reviewed
d1fd04056f. The BC1/BC3/BC4/BC5 loader, precedence rules and optional API routing passed 4,196 independent assertions over generated streams and TTPF pools, plus 41 companion-exporter CLI checks. Supplied diagnostics and existing positional-default cancellation-token callers also passed. The combined Core, desktop app, IndexBuilder and pinned Leonida exporter build with zero warnings or errors.This approval covers the documented BC1/BC3/BC4/BC5 scope. The desktop still uses built-in tables, and BC6H/BC7 histories remain unsupported. No retail calibrated-history corpus was available to reproduce the author's native parity run. PR #23 remains separate.