Add clean-room BCPack BC6H/BC7 decoders, external history loading, and strict-mode mip fallback #27
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!27
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-27"
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?
@LocranKing on GitHub · 2026-11-23 13:25 UTC · original
LocranKing:feat/bcpack-bc6h-bc7→main· +1786 −54 · 7 files · 1 commits · openAI-assisted.
Summary
Adds clean-room Xbox Series BCPack BC6H (codec
6) and BC7 (codec7) block rebuilders, externalbc6h/bc7history loading inBcpackHistory.Load(path), and strict-mode mip fallback inTtpfReaderso mixed-mip textures continue exporting and previewing their decodable mips when upper BCPack mips require external history.Follow-up to PR #7 (
BcpackDecoderBC1–BC5) and PR #22 (BcpackHistoryexternal tables), addressingItsNotRexed/LeonidaASSET-315/docs/textures.mdNext steps 1–2.What changed
Core/BcpackTablesBptc.cs(new): Public D3D11/Khronos BPTC partition/anchor tables, all 14 BC6H bit-packing plans, BC7 lane-15 signature rank table (286entries +10inferred ranks), de-interleave lookup tables, and empty defaultBc6hHistoryTable/Bc7HistoryTablecontainers. Zero unpublished game constants are embedded.Core/BcpackHistory.cs: ExtendsBcpackHistory.Load(path)to parse optionalbc6h(bc6h.json,"bc6h"key,"codec": "bc6h", or"endpointHistory"marker) andbc7(bc7.json,"bc7"key,"codec": "bc7", or"historyEndpoints"marker) sections matching upstreamLeonidatools/bcpack_tables_bptc.py(endpointConfirmedBits,indexConfirmedBits, flat and nested BC7 arrays, mid-range fill for0 < d < 8, andhistoryEndpointLastResort), while keeping BC1–BC5 parsing and error messages unchanged.Core/BcpackDecoder.cs: EnablesSupportsRebuild = truefor codecs6(BC6H) and7(BC7) and implementsRebuildBc6handRebuildBc7usingUInt128packing, fixed 256-entry ring buffers, periodicCancellationTokenchecks, and identical strict/provisional gating, confirmed-bit checks, anchor/p-bit consistency validation, and distinct unknown-block counting.Core/TtpfReader.cs:CreateDds: catchesBcpackProvisionalExceptionon refused upper mips (caching refused chunk keys to avoid redundant rANS decodes), falls back to the highest contiguous decodable mip chain with recomputed DDS header dimensions/pitch/size, and rethrows the originalBcpackProvisionalExceptiononly if no mip in the texture is decodable.DecodeTexturePreview/DecodeTexturePixels: falls back to coarser decodable mips when the selected preview mip is refused, and walks back upward (within the 16M pixel cap) when only upper mips are decodable (e.g., zlib/raw upper mips with a history-dependent BC6H/BC7 tail)."Remaining layouts"metadata string.Core/ArchiveReader.cs,README.md,README.txt: Updates BCPack BC6H/BC7 capability, external history, and lower-mip fallback notes.Verification
Only outcomes reported, no game data.
Environment: Windows 11 Build 26200 x64 · NVIDIA RTX 3060 Ti (driver 621.01) · .NET SDK 8.0.428 · Python 3.12.10.
TreatWarningsAsErrors=trueinCore):dotnet build Core\RpfPreview.Core.csproj -c Release: 0 warnings, 0 errors.dotnet build Tools\IndexBuilder\IndexBuilder.csproj -c Release: 0 warnings, 0 errors.ItsNotRexed/Leonidatools/rpf9dump(main, including--history/--allow-provisional) compiled against thisCore: 0 warnings, 0 errors.feat/bcpack-bc6h-bc7(all 14 BC6H modes, all 8 BC7 modes including rotations, index selection, shared/per-endpoint p-bits, mode 0 zero shortcut, fixeddocs/textures.mdstream, 31 strict/provisional/confirmedBits/anchor/p-bit/distinct-unknown-block cases verified against upstreamtools/bcpack.py, 11 malformed JSON validation cases, and a synthetic 5-texture RDS5/ETPF634 pool covering BC7+zlib fallback, BC6H+raw fallback, all-BC7 strict refusal, self-contained BC7 strict export, and reverse-mixed zlib-top + BC7-tail preview/export).16134b0: fails as expected (FAIL: BC6H codec 6 supported).1.0.2.1parity & fallback validation (aggregate counts only):268BC6H,5,167BC7;1,300.6 MiBdecoded) in 4 modes (strict/provisional × without/with locally self-calibrated history): 0 unexpected errors (1,556chunks decoded with local provisional history).tools/bcpack.py(SHA-256 of decoded bytes + sorted provisional label sets + exact refusal messages across all 4 modes):<= 64 KiBBC7 chunks (926chunks,102.2 MiB): 3,704 / 3,704 exact matches, 0 mismatches.106BC6H +350BC7 up to256 KiB, including100refused BC7 chunks): 1,824 / 1,824 exact matches, 0 mismatches.TtpfReader.CreateDdsstrict-mode comparison across all 3,270 BC6H/BC7-touching textures vs pre-PR16134b0:DecodeTexturePreview(192)andDecodeTexturePixels(0)with 0 failures.DecodeTexturePreview(192)andDecodeTexturePixels(0)with 0 failures.--limit 200): 2,633 textures exported (648 full-resolution BC6H/BC7).@breadbbbb on GitHub · 2026-11-23 22:28 UTC · original · requested changes
I reproduced an extraction regression on Windows with this head merged into main. In
ttdb_graphics.ttpf, slot 75 (BC7, DXGI 98),TtpfReader.CreateDdssuccessfully returned 11,172 bytes in strict mode.ArchiveReader.Openstill advertised 43,940 bytes for the entry. Extracting that one entry throughArchiveDocument.ExtractAsyncfailed with “Decoded member length does not match the archive index.”Please make the selected mip chain and its effective DDS size agree across catalog metadata, preview, and extraction. Keep the archive reader’s length check. A regression that opens a mixed-mip pool as an ArchiveDocument and compares the extracted DDS byte-for-byte with CreateDds would cover the desktop path.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.