Commit Graph

1 Commits

Author SHA1 Message Date
7bde974af5 runtime: port VIctory's BCPack decoder (gta6rt_bcpack, leonida_bcpack_decode)
BCPack is the console's DirectStorage codec for BC1-BC7 block streams.
src/bcpack.h and src/bcpack.cpp port victory-formats' bcpack.rs
(GPL-3.0-or-later, Marvisak and contributors) and the table loading
around bcpack::decode in victory-hle's dstorage.rs. src/bcpack_decode.h
declares leonida_bcpack_decode, the entry point the DirectStorage port
calls; the definition here replaces that branch's stub. Drop
bcpack_decode_stub.cpp when merging: a static library member is only
pulled in for unresolved symbols, so a stub left in gta6rt's sources
would win without a link error.

The format tables are not under the project's license and are never
committed: they are read on first use from LEONIDA_BCPACK_TABLES, else
bcpack-tables.bin next to the executable, and refused unless their
SHA-256 is the one VIctory's Initialize-FormatTables.ps1 pins; without
them every BCPack request fails. Decoding allocates nothing and shares
nothing mutable, so worker threads may decode at once.

Checked against VIctory's decoder (Rust, release build) on all 105,845
BCPack chunks of the user's texture pools (BC1 100,020, BC3 35, BC4 77,
BC5 325, BC6H 268, BC7 5,120; 12.1 GB packed, 16.4 GB decoded): every
output is byte-identical. One core, every 10th chunk, decode calls only:
59-61 MB/s out for the port against 57 MB/s for VIctory's build (BC1
64-66 against 62, BC7 29-30 against 27; Ryzen 5 7600X, MSVC 2022,
RelWithDebInfo).

bcpack_test (CTest bcpack) needs no game data or tables: SHA-256
vectors, table parsing and loading, VIctory's fixed BC4 stream, and
streams it encodes itself against tables of its own. bcpack_tables
repeats the checks on the real tables (SKIP, exit 77, without them) and
pins the hashes of the blocks VIctory's decoder makes of the streams it
builds; VIctory's reference_chunks test passes on those streams.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:30:15 -05:00