Repository navigation
Conversation
… against tools/bcpack.py The DirectStorage worker refuses every BCPack request with E_NOTIMPL, and the retail title asks for modes 1, 5 and 7 (issue ProjectLeonida#14, comment 7135719755). This adds the decoder the request path will call, as a portable library (gta6rt_bcpack, no windows.h): - src/bcpack.{h,cpp}: the lane layer, a statement-by-statement port of tools/bcpack_calibration/src/model.rs (itself a port of _decode_lanes_raw), with a 64-bit coder state (it stays below 2^32; a negative one is refused as model.rs does), and the strict BC1, BC3, BC4 and BC5 rebuilds of blocks.rs / _bc1_blocks.._bc5_blocks. Errors are a Status, not a fallback. An optional History takes the user's calibrated entries (they win over the built-in ones, as _resolve_bc_history merges). Modes 6 and 7 return unsupported_codec until they are ported. - src/bcpack_tables.h: written by tools/bcpack_header.py from tools/bcpack_tables.py (confirmed history only, no provisional entry). - test/bcpack_test.cpp + test/bcpack_vectors.{py,h}: 120 lane cases and 90 whole-chunk cases from tests/test_bcpack.py's synthetic encoder (valid, corrupted, cut short, trailing byte, lane 1 set, history entries confirmed or not), each with the pure-Python decoder's answer; the C++ decoder gives the same lanes, the same blocks or the same class of refusal for all 210. - tests/test_bcpack_header.py: both generated headers are current, and no provisional entry reaches the table header. - docs/directstorage.md: the decoder exists; the wiring into execute_request waits for destination pages.
This was referenced Nov 24, 2026
2 of 4 tasks
KernelSmoker
approved these changes
Nov 24, 2026
KernelSmoker
left a comment
Contributor
There was a problem hiding this comment.
Reviewed exact head a371a73. Built the Linux CPU decoder target with GCC 16 in Fedora 45 and ran CTest: bcpack 1/1 passed. The generated-table test passed 3/3, and the no-game-data scan plus diff check passed. This is CPU decoder validation; no game data or GPU behavior is claimed. Hosted label status was queued when checked.
This was referenced Nov 24, 2026
Collaborator
|
Thanks for this stack.
AI-assisted (Claude Code, Claude Opus 5.5). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: RT-BCPACK-DECODER (#14 (comment))
What and why
The DirectStorage shim refuses every BCPack request with
E_NOTIMPL(execute_request,runtime/shims/dstorage.cpp),and the retail title asks for BCPack modes 1, 5 and 7 (@DesertGamer's count of refused requests, #14 comment
7135719755). This adds the decoder that path will call, as a portable library (
gta6rt_bcpack, nowindows.h), soit builds and tests on every OS. It does not touch
execute_request: every BCPack request measured also carries thedestination-pages bit, so the wiring waits for destination pages (@DadaCap), and @DesertGamer offered to do it.
runtime/src/bcpack.{h,cpp}: the lane layer is a statement-by-statement port oftools/bcpack_calibration/src/model.rs(itself a port of_decode_lanes_raw), with a 64-bit coder state insteadof model.rs's i128: a state below
RANS_Lis shifted a byte at a time until it reachesRANS_L, so it stays below2^32, and a negative one (only a corrupt stream makes one) is refused before any shift, as model.rs does. The
BC1, BC3, BC4 and BC5 rebuilds follow
blocks.rs/_bc1_blocks.._bc5_blocks, strict likebcpack.decode:a block that needs an unconfirmed built-in history entry is refused (
Status::unconfirmed_history), neverguessed. Where the Rust port hands a stream back to Python, this returns a
Status. An optionalHistorytakesthe user's calibrated entries, which win over the built-in ones (
_resolve_bc_history's merge).runtime/src/bcpack_tables.h: written bytools/bcpack_header.pyfromtools/bcpack_tables.py(rANS models,symbol-rank tables, confirmed history only).
tests/test_bcpack_header.pyfails if it goes stale or if aprovisional entry gets in.
runtime/test/bcpack_test.cppwithruntime/test/bcpack_vectors.{py,h}: 120 lane cases over all six modesand 90 whole-chunk cases over modes 1, 3, 4 and 5, from
tests/test_bcpack.py's synthetic encoder (valid,corrupted, cut short, a trailing byte, lane 1 set, history distances to no block, an earlier block or a built-in
entry), each with the pure-Python decoder's answer (
LEONIDA_BCPACK_NATIVE=0). No Python is needed at test time.docs/directstorage.md: the decoder exists; what is left is the wiring.Not in this PR: BC7 (mode 7, which the title uses) and BC6H; both return
unsupported_codecfor now and come nextunder the same claim. Swizzle (no request measured uses it) and physical pages are not touched.
Tested
bcpack_test: all 210 cases agree withtools/bcpack.py(79 lane streams accepted and 41 refused exactly asPython does, with the same symbols; 71 chunks decoded to the same bytes, 19 refused with the same class of error),
plus a chunk refused for its history decoding with a complete external table. Built with MSVC
/W4, no warning.tests/test_bcpack_header.py,tests/test_bcpack.py,tests/test_bcpack_tables.py,tests/test_tool_startup.py,tests/test_docs_links.py,tests/test_text_write_line_endings.py,scripts/check_no_game_data.pyon every newfile.
tests/test_tool_stdout_encoding.pylists onlytools/native_pso_hashes.py, which fails onmaintoo.ctest302 of 306 pass,bcpackincluded. The 4 failures are the same as on
mainhere (d3d12_clear,d3d12_execute_indirect_validation,d3d12_texture_tiles,d3d12_pipeline_library_host, all already reported in Coordinating who works on what #14).GPUs tested: n/a (CPU only)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.