mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #976] [CLOSED] RT-BCPACK-DECODER: a runtime BCPack decoder, BC1/BC3/BC4/BC5, checked against tools/bcpack.py #1013
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1013
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/976
Author: @iFeyz
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:feat/bcpack-decoder📝 Commits (1)
a371a73RT-BCPACK-DECODER: a runtime BCPack decoder, BC1/BC3/BC4/BC5, checked against tools/bcpack.py📊 Changes
10 files changed (+2413 additions, -1 deletions)
View changed files
📝
docs/directstorage.md(+7 -1)📝
runtime/CMakeLists.txt(+15 -0)➕
runtime/src/bcpack.cpp(+556 -0)➕
runtime/src/bcpack.h(+64 -0)➕
runtime/src/bcpack_tables.h(+594 -0)➕
runtime/test/bcpack_test.cpp(+98 -0)➕
runtime/test/bcpack_vectors.h(+667 -0)➕
runtime/test/bcpack_vectors.py(+224 -0)➕
tests/test_bcpack_header.py(+48 -0)➕
tools/bcpack_header.py(+140 -0)📄 Description
Claimed in the coordination issue as: RT-BCPACK-DECODER (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136759575)
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 #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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.