Repository navigation
fix(bcpack): standalone BC1-BC7 decoding across runtimes and assets - #2567
wish131400 wants to merge 3 commits into
Conversation
Fix the Rust BC7 dictionary reader and lane scheduling, add BC2, and replace the legacy production C++/Python rebuilders with fixed format dictionaries. Vendor Xbox2Windows d049001 with preserved notices and C++20 portability. Remove automatic calibration/history use from runtime and asset builds; isolate explicit offline research tools and document existing PR overlap. Validation: 1,076 committed synthetic goldens, 15,402 GDK comparisons per implementation, 168 GDK compressor roundtrips, 308 related Python tests (3 skips), 42 Rust tests (5 ignored), portable CTest, and 546 DirectStorage checks. Full Windows runtime/game rendering was not tested. AI-assisted: Codex.
|
The full Windows runtime builds at I checked the production decoder library and queue objects from that build using the PR’s committed synthetic BC1–BC7 expected outputs:
The queue checks covered 19 fixtures per codec, in both modes, for 1,099,776 output bytes. I selected inputs smaller than their destination, as the queue requires for compressed requests. The smaller-output examples were checked through the decoder library. A local client submitted the requests and waited for completion before comparing bytes. I built the stock DirectStorage test executable; these execution counts are from the local client. GPU rendering and game performance remain unmeasured here. AI-assisted with OpenAI Codex (GPT-6). |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the core Rust, C++, DirectStorage shim, vendored third_party/x2w-bcpack decoder, Python standalone integration, and license/notice files, and tested merged onto main (493867366) with full Windows runtime enabled (MSVC 19.44, Ninja Release, Windows SDK 10.0.26100.0) and Rust 1.100.1.
Code review notes
- Rust (
d3d12/crates/leonida-formats/src/bcpack.rs): fixing the BC7 dictionary record offset (reading all 32i16indices per entry), replacing the lane loop withStreamLaneper-lane output budgets and terminal-state checks, adding nonzero-tail rejection, and implementing 15-lane BC2 reconstruction are all clean and well-bounded. - C++ & DirectStorage (
third_party/x2w-bcpack/bcpack_decoder.h,runtime/src/bcpack.cpp,runtime/shims/dstorage.cpp): runtime AVX2 dispatch checks CPUID leaf 7, POPCNT, OSXSAVE, AVX,_xgetbv(0) & 0x6, and calls_mm256_zeroupper();X2W_BCPACK_LANE_TESTSstays confined tobcpack_testso there is no ODR mismatch ingta6rt_bcpack; attribution (LICENSE-MIT,THIRD_PARTY_NOTICES.md) and provenance/overlap notes (docs/bcpack-standalone.md) are clear. (Minor non-blocking observation:Lane::targetcastsoutput_size / 8touint32_t, which is always safe for DirectStorage's 32-bitDestinationSizeand only theoretical for direct C++ calls above 32 GiB.) - Python & assets (
tools/bcpack.py,tools/bcpack_standalone.py,tools/ttpf_assets.py): fixed tables cleanly replace production fitting/calibration while keeping offline research isolated intools/bcpack_research.pyand invalidating old stamps viaDECODER_SOURCES. - Maintainer coordination on the documented overlapping PRs (#1044, #1103, #1935, #1974, #1715, #2512, etc.) remains a policy/merge-order decision, and this PR documents those overlaps transparently.
Tests run
- Full Windows runtime build (
cmake --build <build> --target bcpack_test dstorage_test gta6rt): built cleanly withLEONIDA_BUILD_WINDOWS_RUNTIME=ON. ctest --output-on-failure -R "^(bcpack|dstorage)$": 2/2 passed (bcpack,dstorage5.99 s).bcpack_test.exe tests/fixtures/bcpack-standalone.txt: 1076 independent goldens on every supported CPU path (reference, scalar, AVX2); all 128 models; malformed input guards passed.cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-formats: 42 passed, 0 failed, 5 ignored (5.48 s).- Python unit suites (
test_bcpack.py,test_bcpack_standalone.py,test_bcpack_history_calib.py,test_bcpack_native.py,test_bcpack_tables.py,test_bcpack_tool.py,test_calibrated_texture_extra.py,test_make_game_assets_pools.py,test_ttpf_assets.py,test_ttpf_mips.py,test_docs_links.py,test_ctest_registration.py): 275 passed (14 skipped, 0 failures, 20.84 s). python -I tools/gen_bcpack_standalone_tables.py --check: verified.python -I scripts/check_no_game_data.py: clean.
AI-assisted (Antigravity, Gemini).
|
@wish131400 — Same-input Red → Green: main’s strict Python and native C++ production decoders each matched 44 of the 1,076 committed golden rows and rejected 1,032. The merged decoders matched 1,076/1,076, including 49/49 BC2 and 334/334 BC7. Pure Python and the optional native entropy path both matched. For the same synthetic BC2 and BC7 texture pools, main could not publish a new DDS; merged exported all five mips, 5,456 expected payload bytes per DDS. Linux Python/export/research suites: 299 passed, one C# tool-dependent skip. Portable C++ BCPack CTest: 1/1. Wine BCPack and DirectStorage CTests: 2/2, including 546 DirectStorage checks. An independent 22-request shim control had 15 failures on main and zero on merged. The C++ path here was scalar/reference, not the MSVC AVX2 path. Physical gfx906 / RADV Mesa 26.0.8: sampled 16 decoded 8×8 textures spanning BC1–BC7, including signed and unsigned BC6H. Compared to sampling separately uploaded golden blocks, 1,024/1,024 RGBA texels were bit-exact. A BC1 color change affected only the intended 4×4 block. Zero Khronos validation errors or sync hazards. This checks GPU use of the CPU-decoded BC blocks, not GPU BCPack decompression. No Rust results claimed. Minor documentation mismatch: the module overview in AI-assisted. |
Preserve upstream DirectStorage vector CLI validation and atomic writes alongside independent goldens. Guard the standalone table generator stdout and correct the assets calibration overview.
|
Updated to
Validation on Windows x64 / MSVC 19.43: C++ BCPack CTest passed (1,076 goldens on all supported CPU paths); Rust 42 passed, five ignored; DirectStorage 546 checks with zero failures; related Python 308 tests, four skips, zero failures; full translator regression 507 files / 6,410 tests / zero failed files. Docs links (17) and CTest registration (seven) pass, as do generated-table checks, compilation, formatting of changed Rust files, game-data screening and whitespace checks. CPU-only local refresh; no game or GPU run. For the remaining tool/documentation CI failures, I reran all eight affected test files on an unmodified checkout of the same main commit. Both checkouts have the same ten failing tests; the new generator is no longer in the stdout guard failure list. No tests were disabled. Main's own CI is also failing: https://github.com/ProjectLeonida/mandy/actions/runs/46138636141 . Previous runtime CI GPU failures are outside the decoder tests and are not claimed fixed here. The upstream conflict-label workflow currently reports HTTP 403 / installation API rate limiting, so the label can lag behind GitHub's actual mergeability calculation. AI-assisted: Codex. |
GrahamboJangles
left a comment
There was a problem hiding this comment.
Independent review pass (overnight shift; verification from a Windows x64 checkout, Python 3.14.9).
Claim protocol: verified. BCPACK-STANDALONE-BC1-BC7 appears exactly once as a claiming: line in #1608 and once as done: … -> #2567; gh pr list --search "BCPACK-STANDALONE" returns only this PR — no claim squatting. Body declares AI-assisted: yes — Codex and GPUs tested: n/a honestly, and provenance is explicit (not clean-room; GDK used only as an oracle for synthetic inputs).
Local grounding at the PR head cb947eac0: ran the six Python bcpack suites unmodified:
tests/test_bcpack_standalone.py: 3 tests OK in ~4.2 s — the committed 1,076 goldens decode byte-exact through the pure-Python path (native entropy skipped: no wheels here). Thelen(cases) == 1076assertion fired, so the fixture count is real.test_bcpack20 OK;test_bcpack_native12 skipped (native module absent);test_bcpack_tables34 OK;test_bcpack_tool18 OK (1 skip);test_bcpack_history_calib19 OK. Total: 106 tests, 0 failures.
Delta vs fresh main 54b2a81e9: on an origin/main checkout the same suite has a red — tests/test_bcpack_history_calib.py::test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive fails (AssertionError: 1 != 2), and test_bcpack_standalone.py does not exist on main at all. At the PR head that file is green. Note the greenness partly comes from removing five test methods from test_bcpack_history_calib.py (the macOS case/accents pool-dedup test among them — net 24→19 tests in that file). Since open PR #1538 (BCPACK-CALIB-DEDUP-PATH-GUARD) also owns pool dedup/guard coverage, maintainers should confirm no dedup-guard coverage is silently lost when the calibration path is pared down.
Merge status needs work — flagged. GitHub reports this PR CONFLICTING / DIRTY against current main. The refresh merged main at 4a54aedcb, but main has since merged, after that point: #2512 (assets BCPack strict history, merged 2026-11-29T08:14:19Z), #1422 (bcpack_tool hardening, merged 2026-11-28T20:15:13Z) and #1013 (assets pools parallel) — I confirmed none of their head commits are ancestors of pr2567 (git merge-base --is-ancestor → false for all three). A local preview merge (pr2567 ← origin/main @ 54b2a81e9) conflicts in 14 files: README.md, docs/directstorage.md, make_game.py, runtime/CMakeLists.txt, runtime/shims/dstorage.cpp, runtime/src/bcpack.cpp, runtime/src/bcpack.h, runtime/test/dstorage_test.cpp, tests/test_bcpack_history_calib.py, tests/test_ttpf_assets.py, tools/bcpack_calibration/README.md, tools/bcpack_tool.py, tools/gen_bcpack_runtime_tables.py, tools/ttpf_assets.py. The PR needs a second refresh onto current main — and since #2512 (previously listed as an open overlap) has now landed, the "production needs no external history" claim has to be reconciled against main's merged strict-history asset path before this can merge.
CI on head: passes windows, semantic-tests, translator-tests, viewer-tests, change-scope, no-game-data; fails linux-gpu-tools, macos, macos-python, stdlib-tests-linux (+ one unnamed check job). Consistent with the body's honest "not globally green; main's CI also fails" statement — the passing jobs are the decoder-relevant ones.
Verdict: decoder work is solid — I independently reproduced the goldens end-to-end in pure Python at the head, and the local suite is 0-failure. Not approving from my side while the merge state is CONFLICTING: request-change is the refresh-onto-current-main plus the #2512 reconciliation. Commented review, no merge action taken.
|
Mechanical note, no review: this branch conflicts with
This is the heaviest of the five: 49 files changed, 10130 insertions and 2033 deletions, and 1320 commits behind. A rebase here is real work, not a formality. So a rebase is all it needs - the change itself may well be fine, I have not looked at its content, only at whether git can apply it. Written with an AI assistant. |
|
Tried
AI-assisted (Claude Code). |
GrahamboJangles
left a comment
There was a problem hiding this comment.
Follow-up re-check after the reconcile push (head cb947ea -> 7078256), 2026-11-30.
Merge reconciliation verified. The new merge commit 7078256 has second parent b8bd371, which is on current main (e1fe82f), and #2512's head (a23d691) is now an ancestor of the PR head. GitHub reports the PR MERGEABLE against main; the 14-file conflict from the previous head is resolved. The head is ~20 commits behind current main, but since b8bd371 is on main, the merge-into-main effect is exactly the diff I analyzed locally.
Local verification at the new head (Windows, Python 3.14, unmodified suites, checkout of head 7078256):
- All six Python bcpack suites: 121 tests, 0 failures. The five pre-existing suites run 118/118 at the head; current main runs the same 118, 0 failures — zero test regression vs fresh main. The new standalone suite adds 3 tests including the 1,076 synthetic goldens decoding byte-exact via the pure-Python path.
- The pool-dedup test (tests/test_bcpack_history_calib.py::test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive) that was red on main at main@54b2a81e9 yesterday is green on current main, and stays green at this head.
Semantic-tests CI failure at the new head is inherited, not introduced. Reproduced locally with scripts/run_semantic_tests.py tests/semantic on both tiers: identical result on the PR head and on a fresh main checkout — "529 files, 6526 tests, 1 files failed" both times. The single failing file is tests/semantic/test_interp_computed_ij_fallback.py with two failures on both tiers: test_p1lv_f16_computed_ij_uses_interpolated_attribute_not_vsrc2 (AssertionError: 17407 != 17408) and test_perspective_fixture_branch_and_f16_halves (0.07745361328125 != 0.0775146484375). Nothing in this PR touches interp fallback; main's CI is red the same way.
One semantic note for maintainers. Vs current main the PR's net effect is 50 files, +10,234/-2,322. In runtime/src/bcpack.cpp, bcpack.h, shims/dstorage.cpp and their test, the PR is a net deletion (~633 lines removed vs the four files' current main state): it replaces the history-dependent bcpack implementation — including what #2512 (ASSETS-BCPACK-STRICT-HISTORY) landed on main — with the x2w-bcpack standalone decoder. #2512's head is contained and main's bcpack suites stay green at the head, so nothing measurable breaks; but #2512 had landed by the time the original body was written only as an open overlap, so please confirm deleting the strict-history decode path is the intended supersession rather than an oversight.
CI at 7078256: windows, linux-gpu-tools, translator-tests, viewer-tests, change-scope, no-game-data pass; check, macos, macos-python, semantic-tests, stdlib-tests-linux fail, all inherited from main as shown above. With the conflicts resolved and no test regression vs fresh main, the main remaining risk is the #2512 supersession question above.
|
Independent check on Windows (not the author), at
Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Rust 1.98.1 pinned. AI-assisted: yes (opencode). |
Claim: BCPACK-STANDALONE-BC1-BC7.
Depends on: no unmerged PRs. Updated by a normal merge of
mainatb8bd3711160b829d3b17d2e0faf468f1d405b4ee; published decoder history is preserved.What and why
The original Rust decoder misread BC7 dictionary indices after entry zero and rejected valid BC1/BC4 lane schedules. The legacy C++/Python production paths used incomplete or fitted initial dictionaries, and BC2 was missing. This PR supplies fixed-dictionary BC1-BC7 decoding in the Rust D3D12 runtime, C++ DirectStorage shim and Python assets exporter, without requiring a GDK installation, calibration profile or history sidecar.
d049001ab9a906588f47868277b77e9a00e27053(#3293), preserving notices and scalar/CPU-checked AVX2 dispatch.bcpack_research.py. Legacy quality/history arguments cannot change production output.Development included implementation inspection and synthetic GDK API queries; this is not presented as a strict clean-room implementation. No SDK binaries, private headers, disassembly, game payloads or title-derived fixtures/reports are included. GDK was a local oracle for synthetic inputs; shipped code and tests require neither GDK nor game files. The original independent audit of 15,402 synthetic streams per implementation and 168 synthetic compressor roundtrips is documented in
docs/bcpack-standalone.md; this merge reruns the committed regression fixtures and integration suites below.Reconciliation with current main
This merge resolves the conflicts while retaining main's runtime installation staging/rollback, crash-monitor target, current README status and unrelated DirectStorage I/O diagnostics.
Historical overlaps #1044 / #1103, #1935 / #1974 and #1628 remain documented in
docs/bcpack-standalone.md. This PR does not claim their separate legacy performance work as applied to the replacement decoder.Validation after this merge
Windows x64, MSVC 19.43, Python 3.14; no game files or GPU commands used:
leonida-formats: 42 passed, 5 existing ignored, 0 failed.mainatb8bd371116. No translator implementation or semantic fixture is changed by this PR.--check, Python compilation,make_game.py --help, changed Rust formatting, line-ending tests, repository game-data screening and whitespace checks relative to current main passed.The broad portable runtime build hits missing newer D3D12 barrier constants in main's unchanged
d3d12_state_map_testwith the locally installed Windows SDK 10.0.22621. The standalone BCPack target builds/tests independently, and the modified DirectStorage sources compile and pass directly. No full Windows runtime/game/GPU image or frame-rate result is claimed for this refresh. Finite synthetic tests do not prove every possible input bit sequence.Independent results at the original decoder head: Windows verification, Linux/gfx906 verification. Those results belong to their contributors and are not GPU/game tests of this merge.
GPUs tested: n/a; profile Z, CPU/synthetic validation only.
AI-assisted: yes, Codex.
Checklist