Repository navigation
fix(bcpack): standalone BC1-BC7 decoding across runtimes and assets - #2567
wish131400 wants to merge 2 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. |
Claimed in the coordination issue as: BCPACK-STANDALONE-BC1-BC7.
Depends on: no unmerged PRs; initially based on
main(493867366), now updated by mergingmainat4a54aedcbwithout rewriting the published decoder commit. Overlapping/conflicting proposals are listed below and indocs/bcpack-standalone.mdfor maintainer coordination.What and why
The Rust decoder reads BC7 dictionary indices at the wrong offset after entry zero, and its lane scheduler rejects valid BC1/BC4 streams. The legacy C++/Python production decoders have incomplete or fitted initial dictionaries, and all three paths omit BC2. On an independent 15,402-stream synthetic audit, the original Rust path produced 514 different BC7 outputs among 774 BC7 cases; the legacy paths rejected most dictionary-dependent cases.
This change provides fixed-dictionary BC1–BC7 decoding in the D3D12 Rust runtime, C++ DirectStorage shim and Python assets exporter:
d049001ab9a906588f47868277b77e9a00e27053(#3293), with preserved source/license notices and C++20 portability. Check CPU/OS support before AVX2 dispatch; retain scalar decoding.bcpack_research.py; they remain usable and tested. Legacy quality/history arguments are accepted for compatibility and cannot change production output.Provenance is explicit: development included implementation inspection and synthetic GDK API queries, so this is not presented as a strict clean-room implementation. No SDK DLLs, private headers, disassembly, game payloads or title-derived fixtures/logs are included. The shipped decoder and tests need neither GDK nor game files. The GDK was only a local oracle for synthetic inputs.
Existing PR overlap
This is a replacement proposal based on main, not a stack on the earlier decoder series:
These overlaps require maintainer coordination; no claim is made that those unmerged changes were applied or that their separate hardening/performance work has been completed by this PR.
Tested
Windows x64, MSVC 19.43; the integration checks below were rerun after merging
main4a54aedcb(headcb947eac0):cargo test -p leonida-formats: 42 passed, 5 existing ignored, 0 failed.python -I scripts/run_semantic_tests.py tests/semantic -j 12: 507 files, 6,410 tests, 0 files failed.runtime/test/dstorage_test.cppwith the modified shim: 546 checks, 0 failures, including BC2 and plain/zlib requests.tests/test_docs_links.py: 17 passed. Generated-table--check,compileall,make_game.py --help, formatting of the changed Rust files, whole-repository game-data screening andgit diff --checkpassed.Portable CMake used
LEONIDA_BUILD_WINDOWS_RUNTIME=OFFandLEONIDA_VULKAN_HEADERS_FETCH=ON. The full Windows runtime build requires Windows SDK 10.0.26100; this machine selects 10.0.22621, so the modified DirectStorage shim was compiled/tested directly instead. No game launch, GPU image comparison or frame-rate benchmark was performed. Finite synthetic tests do not prove every possible bit sequence.The refresh preserves main's DirectStorage vector generator CLI validation and atomic-write behavior (two tests passed), fixes the new table generator's stdout guard, and corrects
make_game.py's stale calibration recommendation. CTest registration: seven tests passed.Eight remaining failing tool/documentation test files were rerun on a separate unmodified checkout of
main4a54aedcb. Both checkouts reported the same ten failing tests, including the same ten unrelated CLI tools missing stdout guards. The new generator is no longer among the failures. No tests were skipped or disabled to hide those baseline failures. Main's own CI run also reports failures; this PR does not claim globally green CI. The previous runtime CI also reported GPU failures outside BCPack (cs_imgatomic_extand macOSvk_bindless_dimensions); those remain separate from the passing decoder checks.Independent results at the original decoder head are linked in the Windows verification and Linux/gfx906 verification. Those results belong to their contributors, not this local refresh.
GPUs tested: n/a — CPU/synthetic validation only; no GPU/driver result claimed.
AI-assisted: yes — Codex.
Checklist
mainat4a54aedcb; published history preserved with a normal merge and push.