Skip to content

bcpack: add standalone BC2/BC6H and exact BC1 reconstruction - #3293

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
wish131400:bcpack/standalone-all-formats
Nov 28, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
wish131400:bcpack/standalone-all-formats

Conversation

@wish131400

Copy link
Copy Markdown
Contributor

Change

BC2 and BC6H DirectStorage requests previously succeeded with blank destinations, and BC1's fitted reconstruction ignored index history. This adds standalone BC2/all fourteen BC6H modes and replaces BC1 with independent endpoint/index history plus exact format dictionaries/ranks. The fitted window and masks are removed. All seven formats share the existing atomic file/memory/zlib/page publication path; invalid formats and damaged streams fail without publishing blank or partial textures.

Fixes #3274. Related #1940 adds diagnostics separately; its inspector format list needs BC2/BC6H when the branches are integrated. This PR does not depend on it.

Normal runtime and regression tests require no GDK, BCPack.dll or external table file. New synthetic golden/storage checks are included in the PR build/test presets. README, startup documentation and docs/experiments/bcpack-standalone.md describe the capability, provenance, reproduction and limits.

Verification

Tested commit d049001ab9a906588f47868277b77e9a00e27053, based on main fd7ce57a63acdfc0a946c22c37ae7568b0b3ee4c. Windows 10 x64 build 19045, Ryzen 7 7700, MSVC 19.43, Python 3.14. No GPU tests were used for this CPU decoder change.

After ./tools/dev.ps1 and configuring each preset with INTAKE_PYTHON pointing to Python 3.14, the following build/test commands were run for both dev and release:

cmake --build --preset dev --target bcpack_formats_check startup_stub_consumer startup_stub_xcrdapi bcpack_encoder_check bcpack_lanes_check bcpack_lanes_control startup_storage_failure_counts startup_stub_acphal startup_stub_chad startup_stub_xapu startup_stub_xg_xs startup_stub_gameinput -j 6
ctest --preset dev --no-tests=error -R '^(bcpack_all_formats|bcpack_encoder_|bcpack_lanes_(scalar|avx2)|startup_bcpack_storage|startup_storage_failure_counts|startup_stubs$)' --output-on-failure

cmake --build --preset release --target bcpack_formats_check startup_stub_consumer startup_stub_xcrdapi bcpack_encoder_check bcpack_lanes_check bcpack_lanes_control startup_storage_failure_counts startup_stub_acphal startup_stub_chad startup_stub_xapu startup_stub_xg_xs startup_stub_gameinput -j 6
ctest --preset release --no-tests=error -R '^(bcpack_all_formats|bcpack_encoder_|bcpack_lanes_(scalar|avx2)|startup_bcpack_storage|startup_storage_failure_counts|startup_stubs$)' --output-on-failure

Results: 12/12 passed in Debug, 12/12 passed in Release; no CTest capability skips. The expected-failure controls returned failure as required.

python -B tests/bcpack_check.py
python -B tests/bcpack_symbols_check.py
python -B tests/bcpack_tables_check.py
python -B tests/bc7_blocks_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff --check

Results: 37 Python test methods passed; 3 optional external-reference methods skipped. The table JSON reference was absent (1 skip), and an optional external strict decoder was absent (2 skips). Documentation links, bidi and whitespace checks passed.

The golden fixture generates 12,330 synthetic streams, checks fixed independent oracle output hashes, compares reference/scalar/AVX2 bytes, and checks output guards. It exercises initial references 0–255, independent endpoint/index references, all BC6H modes/partitions, mapped BC7 controls, mixed modes and history wrap. Truncation, output misalignment, trailing input and invalid modes/formats are failure controls. The storage fixture checks 26 scenarios, including file/memory, outer zlib, cross-page destinations, missing grants, invalid formats and a bad final BC6H block after three valid blocks; following valid requests must succeed.

The unchanged synthetic_11 BC1 input's previous 512-byte golden was independently wrong in 491 bytes. Its first eight bytes were 85 31 64 d5 af be ff bf; the oracle gives 8d 73 0a 07 ea b8 fa be. The test now checks the complete corrected output; input and malformed-input controls remain intact.

Evidence and limits

  • Developer oracle: locally installed GDK BCPack 1.2603.3.0. An additional 312 successful synthetic compression/roundtrip cases matched byte for byte on all three paths. Oracle compression failures are not counted as passes.
  • Read-only local archive comparison: 105,845 chunks / 45 pools / 16,356,958,208 output bytes, all byte-for-byte equal on AVX2, with 882 distributed chunks also equal on reference/scalar. BC1 100,020; BC3 35; BC4 77; BC5 325; BC6H 268; BC7 5,120. There were no BC2 archive chunks; BC2 coverage is synthetic. No local payloads are included.
  • New constants are reconstructed with chosen synthetic lane streams through the oracle API, without reading its data section or fitting texture samples. The committed optional recovery tool reproduces the tables and storage goldens. Algorithms are original C++ and MIT; public BC6H bit descriptors adapt pinned MIT DirectXTex with its notice retained. Existing bcpack-rs/silicon-rans notices remain. The implementation notes disclose research sources and make no strict clean-room claim.
  • dumpbin /dependents out/build/release/XCRDAPI.dll lists only KERNEL32.dll; the runtime has no SDK decoder dependency.
  • This validates packed-block decoding for the stated inputs. GPU image output and full-application startup were not measured; finite coverage does not establish every possible compressed stream.

AI-assisted implementation and documentation. The local tests and comparisons above were executed, not inferred.

Checklist

  • One reviewable behavior: standalone BC1–BC7 reconstruction in DirectStorage.
  • Exact commands and observed results included.
  • Negative controls and malformed-input cases included.
  • README and runtime/experiment documentation updated.
  • No game files, dumps, distribution links, private SDK binaries/headers or secrets included.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Windows check on d049001a: built bcpack_formats_check, startup_stub_consumer and startup_stub_xcrdapi in Debug and Release. In each preset, ctest --preset <preset> --no-tests=error --output-on-failure -R '^(bcpack_all_formats|startup_bcpack_storage)' passed all three selected checks. That includes golden reconstruction, the deliberate golden mismatch, and the source-built file/memory/zlib/page storage matrix. The DirectStorage path stages the decoded output and reaches the destination only on successful decode; the fixture exercises bad final blocks and missing grants. The Python suites passed 37 methods with three optional reference skips. Docs-link and bidi checks passed. Windows 11 build 26200, MSVC 19.51. The checked-in fixture is source-built and these runs used no external decoder or local archive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete standalone BCPack decoding for BC1 through BC7 without an end-user GDK dependency

2 participants