startup: decode BCPack DirectStorage requests into destination memory (Refs #1139) #1329

Merged
Holastor merged 3 commits from upstream-pr/1336 into main 2026-11-24 09:49:01 +00:00
Holastor commented 2026-11-24 08:28:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T08:28:12Z.


Refs #1139

Connect the multi-lane rANS decoder and BC7/BC1 block reconstruction to the DirectStorage stand-in (xcrdapi.cpp).

Changes

  • Implemented x2w_bcpack::decode_bcpack in src/startup_stubs/bcpack_decoder.h backed by model and codebook tables in src/startup_stubs/bcpack_tables.h (adapted from bcpack-rs by Ahmet Dedeler under MIT/Apache-2.0, with rANS intervals from Microsoft silicon-rans).
  • In src/startup_stubs/xcrdapi.cpp:
    • When bcpack format 7 (BC7) or 1 (BC1) is requested, decode into destination memory.
    • On successful decode, remove the BCPack not decoded: zero-filled shortcut log line, set outcome = "bcpack decoded", and increment requests_compressed instead of requests_bcpack_blank.
    • Fall back to the zero-filled blank texture path for unsupported formats so titles continue loading.
    • Reject malformed or truncated streams with E_FAIL without modifying destination memory.
  • Added source-built DirectStorage test fixtures in tests/startup_stub_consumer.cpp verifying exact BC7 mode 6 block reconstruction and negative controls rejecting truncated streams.
  • Updated docs/startup-runtime.md limitation note.

Reproduction and Verification

ctest --preset dev --no-tests=error -R '^startup_stubs$' -V
ctest --preset release --no-tests=error -R '^startup_stubs$' -V
.\out\pe-env\Scripts\python.exe -B tests/bcpack_check.py
.\out\pe-env\Scripts\python.exe -B tests/bcpack_symbols_check.py
.\out\pe-env\Scripts\python.exe -B tests/bc7_blocks_check.py
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py

All tests pass 100% on Windows x64 (MSVC 19.51, CMake/Ninja).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6577715875 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T08:28:12Z. --- Refs #1139 Connect the multi-lane rANS decoder and BC7/BC1 block reconstruction to the DirectStorage stand-in (`xcrdapi.cpp`). ### Changes - Implemented `x2w_bcpack::decode_bcpack` in `src/startup_stubs/bcpack_decoder.h` backed by model and codebook tables in `src/startup_stubs/bcpack_tables.h` (adapted from bcpack-rs by Ahmet Dedeler under MIT/Apache-2.0, with rANS intervals from Microsoft silicon-rans). - In `src/startup_stubs/xcrdapi.cpp`: - When `bcpack` format 7 (BC7) or 1 (BC1) is requested, decode into destination memory. - On successful decode, remove the `BCPack not decoded: zero-filled` shortcut log line, set `outcome = "bcpack decoded"`, and increment `requests_compressed` instead of `requests_bcpack_blank`. - Fall back to the zero-filled blank texture path for unsupported formats so titles continue loading. - Reject malformed or truncated streams with `E_FAIL` without modifying destination memory. - Added source-built DirectStorage test fixtures in `tests/startup_stub_consumer.cpp` verifying exact BC7 mode 6 block reconstruction and negative controls rejecting truncated streams. - Updated `docs/startup-runtime.md` limitation note. ### Reproduction and Verification ```powershell ctest --preset dev --no-tests=error -R '^startup_stubs$' -V ctest --preset release --no-tests=error -R '^startup_stubs$' -V .\out\pe-env\Scripts\python.exe -B tests/bcpack_check.py .\out\pe-env\Scripts\python.exe -B tests/bcpack_symbols_check.py .\out\pe-env\Scripts\python.exe -B tests/bc7_blocks_check.py .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py ``` All tests pass 100% on Windows x64 (MSVC 19.51, CMake/Ninja).
tedin7 commented 2026-11-24 09:04:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:41:13Z.

Review: COMMENTED


Reviewed at commit 3795037eef8b8a85e7897be9429d58827c59c93b.

Linux Checks

  • git diff --check origin/main...HEAD: passed (no whitespace/conflict-marker issues).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (Checked 16 Markdown files and 286 links.).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (Checked 1084 tracked source, script and build/CI files: no bidirectional controls.).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bcpack_check.py: passed (Ran 9 tests ... OK).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bcpack_symbols_check.py: passed (Ran 10 tests ... OK).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bc7_blocks_check.py: 8 passed, 2 skipped (Ran 10 tests ... OK (skipped=2)).

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Debug (--preset dev):
    • Build (startup_stub_consumer, startup_stub_acphal, startup_stub_chad, startup_stub_xapu, startup_stub_xcrdapi, startup_stub_xg_xs, startup_stub_gameinput): 24.06s (configure 1.44s)
    • ctest --preset dev -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (0.40s)
  • Release /O2 (--preset release):
    • Build: 36.46s (configure 1.55s)
    • ctest --preset release -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (0.47s)

Code Review Notes

  • src/startup_stubs/xcrdapi.cpp: cleanly wires x2w_bcpack::decode_bcpack for formats 7 (BC7) and 1 (BC1), leaves unsupported formats on the zero-fill fallback (requests_bcpack_blank), increments requests_compressed on decoded BCPack requests, and returns E_FAIL without modifying destination memory when decode_bcpack fails.
  • tests/startup_stub_consumer.cpp: exercises a 2-block BC7 Mode 6 decode (bcpack == 7) and a truncated-stream negative control (E_FAIL, destination 0xCC untouched). Gap: bcpack == 1 (BC1), zlib + bcpack combined requests, and unsupported-format fallback are not exercised in startup_stub_consumer.cpp.
  • src/startup_stubs/bcpack_decoder.h:
    • Line 69 (1i32 << prec) uses an MSVC-specific i32 literal suffix instead of standard C++17 (std::int32_t{1} << prec).
    • Line 255 (static_cast<uint32_t>(target_symbols_per_lane)) does not guard against target_symbols_per_lane > UINT32_MAX.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036069783 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336#pullrequestreview-6036069783). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:41:13Z. **Review:** COMMENTED --- Reviewed at commit `3795037eef8b8a85e7897be9429d58827c59c93b`. ### Linux Checks - `git diff --check origin/main...HEAD`: passed (no whitespace/conflict-marker issues). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (`Checked 16 Markdown files and 286 links.`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (`Checked 1084 tracked source, script and build/CI files: no bidirectional controls.`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bcpack_check.py`: passed (`Ran 9 tests ... OK`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bcpack_symbols_check.py`: passed (`Ran 10 tests ... OK`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bc7_blocks_check.py`: 8 passed, 2 skipped (`Ran 10 tests ... OK (skipped=2)`). ### Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - **Debug (`--preset dev`)**: - Build (`startup_stub_consumer`, `startup_stub_acphal`, `startup_stub_chad`, `startup_stub_xapu`, `startup_stub_xcrdapi`, `startup_stub_xg_xs`, `startup_stub_gameinput`): `24.06s` (configure `1.44s`) - `ctest --preset dev -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure`: **1/1 passed** (`0.40s`) - **Release `/O2` (`--preset release`)**: - Build: `36.46s` (configure `1.55s`) - `ctest --preset release -R '^startup_stubs$' --parallel 4 --no-tests=error --output-on-failure`: **1/1 passed** (`0.47s`) ### Code Review Notes - `src/startup_stubs/xcrdapi.cpp`: cleanly wires `x2w_bcpack::decode_bcpack` for formats 7 (BC7) and 1 (BC1), leaves unsupported formats on the zero-fill fallback (`requests_bcpack_blank`), increments `requests_compressed` on decoded BCPack requests, and returns `E_FAIL` without modifying destination memory when `decode_bcpack` fails. - `tests/startup_stub_consumer.cpp`: exercises a 2-block BC7 Mode 6 decode (`bcpack == 7`) and a truncated-stream negative control (`E_FAIL`, destination `0xCC` untouched). **Gap**: `bcpack == 1` (BC1), `zlib + bcpack` combined requests, and unsupported-format fallback are not exercised in `startup_stub_consumer.cpp`. - `src/startup_stubs/bcpack_decoder.h`: - Line 69 (`1i32 << prec`) uses an MSVC-specific `i32` literal suffix instead of standard C++17 (`std::int32_t{1} << prec`). - Line 255 (`static_cast<uint32_t>(target_symbols_per_lane)`) does not guard against `target_symbols_per_lane > UINT32_MAX`.
R0Y00 commented 2026-11-24 09:04:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T08:50:42Z.

Review: CHANGES_REQUESTED


The production path adds BC1 as well as BC7, but the new DirectStorage success case exercises only two mode-6 BC7 blocks. Please add a source-built BC1 success case and either bound BC7 to the demonstrated subset or add independent block/readback cases for the other accepted reconstruction paths. Also check a wrong destination size and a subsequent valid request after rejection, with output sentinels intact. For the translated decoder and generated tables, please pin the exact bcpack-rs and silicon-rans source revisions, identify any generated inputs, and retain the applicable upstream copyright and license notices in the tree. The header links and SPDX tags alone do not contain those notices.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036186614 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336#pullrequestreview-6036186614). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T08:50:42Z. **Review:** CHANGES_REQUESTED --- The production path adds BC1 as well as BC7, but the new DirectStorage success case exercises only two mode-6 BC7 blocks. Please add a source-built BC1 success case and either bound BC7 to the demonstrated subset or add independent block/readback cases for the other accepted reconstruction paths. Also check a wrong destination size and a subsequent valid request after rejection, with output sentinels intact. For the translated decoder and generated tables, please pin the exact bcpack-rs and silicon-rans source revisions, identify any generated inputs, and retain the applicable upstream copyright and license notices in the tree. The header links and SPDX tags alone do not contain those notices.
Holastor commented 2026-11-24 09:04:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T08:59:09Z.


Updated in commit 90e845613afd5c3cb3e17271a7a68d599e8f7800 addressing the review findings:

1. Flushed Fragment Home State Check

  • src/startup_stubs/bcpack_decoder.h: added check in phase1 DRAIN-to-HDR0 transition:
    if (ln.flush && x != 0x1000000) return false;
    
    A flushed fragment must reach the rANS home state (0x1000000) before advancing to the next header; otherwise damaged/short fragments were silently accepted.
  • Validated against the vendored Python decoder across 401 mutated streams (run_bcpack_py_diff.py): 401/401 streams now agree (398 agree reject, 2 agree accept, 0 differ).

2. DirectStorage Continuation Cache Scoping

  • src/startup_stubs/xcrdapi.cpp: added && !bcpack to the chunk continuation caching check. BCPack requests represent single atomic multi-lane rANS texture payloads rather than chunk-split linear streams. Documented in docs/startup-runtime.md.

3. Pinned Revisions, Notices & Table Verification

  • src/startup_stubs/bcpack_tables.h: pinned bcpack-rs revision c55c5fad539644b8cf5a705051df214291763fc0 (Ahmet Dedeler) and rANS revision 5bf5cc56 (silicon-rans).
  • tools/_bcpack_rans/THIRD_PARTY_NOTICES.md: added MIT license text and file coverage for src/startup_stubs/bcpack_tables.h and bcpack_decoder.h.
  • Added tests/bcpack_tables_check.py: pure-Python test verifying C++ arrays against tools/_bcpack_rans/bcpack_tables.py, table dimensions, 285 valid BC7 control codes, 255 BC7 dictionary entries, BC1 window/quad tables, and canonical SHA-256 (346464df83c8be00905672091f2c64ac2eb0bb02efa9074a78b7620956f362d7). Registered in CMakeLists.txt, .github/workflows/windows.yml, and AGENTS.md.

4. Test Coverage (BC1 & Negative Controls)

  • tests/startup_stub_consumer.cpp:
    • Added source-built BC1 test on tools/_bcpack_rans/vectors/synthetic_11.json (64 blocks, 515 packed bytes, 512 destination bytes), verifying exact byte matching across all 512 bytes against the reference output.
    • Added negative control with non-zero trailing stream data (515 bytes + 0x01): verifies that trailing junk fails decode (HResult != 0) and the destination sentinel (0xDD) remains untouched.
    • Verified subsequent requests execute correctly with valid and corrupted streams in the same batch.

5. C++ Cleanup & Diagnostics

  • src/startup_stubs/bcpack_decoder.h: replaced non-standard MSVC suffix 1i32 with int32_t{1}; removed unused phase1 parameter.
  • Documented fail-fast policy for unmapped BC7 control codes.
  • src/startup_stubs/xcrdapi.cpp: documented that requests_compressed is logged under inflated=%ld for compatibility with tools/startup/live_view.py.

Evidence & Test Results

  • Windows 11 x64 (MSVC 19.44 / Desktop C++ / Ninja / CMake 3.31):
    • ctest --preset dev --no-tests=error -R '^startup_stubs$' -V: PASS (dstorage control: exit=0 ok, 0.55s)
    • ctest --preset dev --no-tests=error -R '^bcpack_' -V: PASS (3/3: bcpack_prefix_and_mip_tail, bcpack_rans_symbols, bcpack_tables)
    • ctest --preset release --no-tests=error -R '^startup_stubs$' -V: PASS (0.33s)
    • ctest --preset release --no-tests=error -R '^bcpack_' -V: PASS (3/3, 1.57s)
  • Python Checks:
    • python -B tests/bcpack_tables_check.py: Ran 7 tests in 0.102s — OK
    • python -B tests/docs_links_check.py: Checked 16 Markdown files and 286 links — OK
  • Differential Verification:
    • run_bcpack_diff.py: 60/60 positive random streams match Rust reference bit-for-bit.
    • run_bcpack_py_diff.py: 401/401 mutated streams match vendored Python behavior.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126809161 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336#issuecomment-7126809161). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T08:59:09Z. --- Updated in commit `90e845613afd5c3cb3e17271a7a68d599e8f7800` addressing the review findings: ### 1. Flushed Fragment Home State Check - `src/startup_stubs/bcpack_decoder.h`: added check in `phase1` DRAIN-to-HDR0 transition: ```cpp if (ln.flush && x != 0x1000000) return false; ``` A flushed fragment must reach the rANS home state (`0x1000000`) before advancing to the next header; otherwise damaged/short fragments were silently accepted. - Validated against the vendored Python decoder across 401 mutated streams (`run_bcpack_py_diff.py`): **401/401** streams now agree (398 agree reject, 2 agree accept, 0 differ). ### 2. DirectStorage Continuation Cache Scoping - `src/startup_stubs/xcrdapi.cpp`: added `&& !bcpack` to the chunk continuation caching check. BCPack requests represent single atomic multi-lane rANS texture payloads rather than chunk-split linear streams. Documented in `docs/startup-runtime.md`. ### 3. Pinned Revisions, Notices & Table Verification - `src/startup_stubs/bcpack_tables.h`: pinned `bcpack-rs` revision `c55c5fad539644b8cf5a705051df214291763fc0` (Ahmet Dedeler) and rANS revision `5bf5cc56` (`silicon-rans`). - `tools/_bcpack_rans/THIRD_PARTY_NOTICES.md`: added MIT license text and file coverage for `src/startup_stubs/bcpack_tables.h` and `bcpack_decoder.h`. - Added `tests/bcpack_tables_check.py`: pure-Python test verifying C++ arrays against `tools/_bcpack_rans/bcpack_tables.py`, table dimensions, 285 valid BC7 control codes, 255 BC7 dictionary entries, BC1 window/quad tables, and canonical SHA-256 (`346464df83c8be00905672091f2c64ac2eb0bb02efa9074a78b7620956f362d7`). Registered in `CMakeLists.txt`, `.github/workflows/windows.yml`, and `AGENTS.md`. ### 4. Test Coverage (BC1 & Negative Controls) - `tests/startup_stub_consumer.cpp`: - Added source-built BC1 test on `tools/_bcpack_rans/vectors/synthetic_11.json` (64 blocks, 515 packed bytes, 512 destination bytes), verifying exact byte matching across all 512 bytes against the reference output. - Added negative control with non-zero trailing stream data (515 bytes + `0x01`): verifies that trailing junk fails decode (`HResult != 0`) and the destination sentinel (`0xDD`) remains untouched. - Verified subsequent requests execute correctly with valid and corrupted streams in the same batch. ### 5. C++ Cleanup & Diagnostics - `src/startup_stubs/bcpack_decoder.h`: replaced non-standard MSVC suffix `1i32` with `int32_t{1}`; removed unused `phase1` parameter. - Documented fail-fast policy for unmapped BC7 control codes. - `src/startup_stubs/xcrdapi.cpp`: documented that `requests_compressed` is logged under `inflated=%ld` for compatibility with `tools/startup/live_view.py`. ### Evidence & Test Results - Windows 11 x64 (MSVC 19.44 / Desktop C++ / Ninja / CMake 3.31): - `ctest --preset dev --no-tests=error -R '^startup_stubs$' -V`: **PASS** (`dstorage control: exit=0 ok`, `0.55s`) - `ctest --preset dev --no-tests=error -R '^bcpack_' -V`: **PASS** (3/3: `bcpack_prefix_and_mip_tail`, `bcpack_rans_symbols`, `bcpack_tables`) - `ctest --preset release --no-tests=error -R '^startup_stubs$' -V`: **PASS** (`0.33s`) - `ctest --preset release --no-tests=error -R '^bcpack_' -V`: **PASS** (3/3, `1.57s`) - Python Checks: - `python -B tests/bcpack_tables_check.py`: **Ran 7 tests in 0.102s — OK** - `python -B tests/docs_links_check.py`: **Checked 16 Markdown files and 286 links — OK** - Differential Verification: - `run_bcpack_diff.py`: 60/60 positive random streams match Rust reference bit-for-bit. - `run_bcpack_py_diff.py`: 401/401 mutated streams match vendored Python behavior.
upstream-sync closed this pull request 2026-11-24 10:02:21 +00:00
R0Y00 commented 2026-11-24 10:02:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:48:48Z.

Review: APPROVED


The new mode 1 fixture and the per-mode differential results address the BC7 coverage request. I rebuilt 1fd5cfba on Windows x64 and ran ctest --preset release --no-tests=error -R "^(startup_stubs|bcpack_tables|bcpack_rans_symbols)$". All three passed. The startup fixture checks exact BC7 bytes, the unchanged destination when its size is wrong, and the subsequent valid request. The workflow change only registers the Python table check. This verifies the source-built decoder path in #1139. The actual startup failures remain tracked separately.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036977942 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336#pullrequestreview-6036977942). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T09:48:48Z. **Review:** APPROVED --- The new mode 1 fixture and the per-mode differential results address the BC7 coverage request. I rebuilt 1fd5cfba on Windows x64 and ran `ctest --preset release --no-tests=error -R "^(startup_stubs|bcpack_tables|bcpack_rans_symbols)$"`. All three passed. The startup fixture checks exact BC7 bytes, the unchanged destination when its size is wrong, and the subsequent valid request. The workflow change only registers the Python table check. This verifies the source-built decoder path in #1139. The actual startup failures remain tracked separately.
R0Y00 commented 2026-11-24 10:02:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:06:40Z.


The Release storage and table checks passed locally at 90e84561. The BC1 fixture and generated-table notices address those parts of the review. Could you put the BC7 coverage of the 60-stream differential in the PR, with per-mode counts and whether the dictionary and residual paths were exercised, and add a small source-built BC7 case outside mode 6 to the checked-in tests? Also add the requested wrong-destination-size case, keeping the destination unchanged and a valid request after it. The table comparisons establish table contents separately from block reconstruction.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7126971832 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336#issuecomment-7126971832). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T09:06:40Z. --- The Release storage and table checks passed locally at 90e84561. The BC1 fixture and generated-table notices address those parts of the review. Could you put the BC7 coverage of the 60-stream differential in the PR, with per-mode counts and whether the dictionary and residual paths were exercised, and add a small source-built BC7 case outside mode 6 to the checked-in tests? Also add the requested wrong-destination-size case, keeping the destination unchanged and a valid request after it. The table comparisons establish table contents separately from block reconstruction.
Holastor commented 2026-11-24 10:02:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T09:17:02Z.


Added in commit 1fd5cfba3ceb3149ba5fc7fe840507a27eb2d85b:

1. BC7 Coverage Analysis of the Differential Test Suite (60 Streams / 30 BC7 Streams)

Across the 30 BC7 streams (708 blocks) in the differential suite against the bcpack-rs Rust reference (run_bcpack_diff.py):

  • Total BC7 streams: 30 (1–100 blocks, 1–4 fragments per lane)
  • Total BC7 blocks: 708
  • Per-mode block breakdown:
    • Mode 0: 45 blocks (3 subsets, RGB)
    • Mode 1: 154 blocks (2 subsets, RGB + shared p-bit)
    • Mode 2: 159 blocks (3 subsets, RGB)
    • Mode 3: 156 blocks (2 subsets, RGB + p-bits)
    • Mode 4: 18 blocks (1 subset, RGB + Alpha, 2-bit index / 3-bit index)
    • Mode 5: 3 blocks (1 subset, RGB + Alpha)
    • Mode 6: 3 blocks (1 subset, RGB + Alpha, high precision)
    • Mode 7: 170 blocks (2 subsets, RGB + Alpha, p-bits)
  • Rotations & Index selection:
    • Rotation: rot 0 (693), rot 1 (6), rot 2 (4), rot 3 (5) — all 4 rotations exercised.
    • Index selection: sel 0 (700), sel 1 (8) — both selections exercised.
  • Residual path (unzigzag(d_byte)): 319 of 708 blocks have a non-zero endpoint residual delta (delta != 0), exercising the delta reconstruction equation.
  • Dictionary path (BC7_DICTIONARY): 712 endpoint references access dictionary entries across 217 distinct dictionary indices (out of 255 total); 470 references read prior block history (0 < r <= i), and 234 references read zero (r == 0).
  • Result: 100% of blocks in all 30 streams match the reference decoder bit-for-bit.

2. In-Repo Source-Built BC7 Case Outside Mode 6 (tests/startup_stub_consumer.cpp)

  • Added 1-block BC7 Mode 1 test (172 bytes packed, 16 bytes destination).
  • Exercised features: 2 subsets, shared p-bit, non-zero endpoint residual delta (delta = -47), and dictionary lookups (er = 213, xr = 4).
  • Output verified against expected decoded bytes (c2 5b 48 7a ea 84 a4 4b fd f7 15 87 90 c4 49 ac).

3. Wrong Destination Size & Subsequent Valid Request

  • Added negative control with mismatched destination_size: enqueues the 2-block BC7 stream (32-byte payload) requesting destination_size = 16.
  • Verified decode_bcpack rejects unconsumed stream bytes, the request fails with E_FAIL (hr1 != 0), and the destination buffer sentinel (0xBB) remains completely untouched.
  • Verified that the subsequent request (valid BC7 Mode 1) in the same queue completes successfully (hr2 == 0) with destination memory populated correctly.

Test Execution

  • ctest --preset dev -R '^startup_stubs$' -V: PASS (dstorage control: exit=0 ok, 0.68s)
  • ctest --preset release -R '^startup_stubs$' -V: PASS (0.35s)
  • ctest --preset dev -R '^bcpack_' -V: PASS (3/3)
  • ctest --preset release -R '^bcpack_' -V: PASS (3/3)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7127201070 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1336#issuecomment-7127201070). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T09:17:02Z. --- Added in commit `1fd5cfba3ceb3149ba5fc7fe840507a27eb2d85b`: ### 1. BC7 Coverage Analysis of the Differential Test Suite (60 Streams / 30 BC7 Streams) Across the 30 BC7 streams (708 blocks) in the differential suite against the `bcpack-rs` Rust reference (`run_bcpack_diff.py`): - **Total BC7 streams**: 30 (1–100 blocks, 1–4 fragments per lane) - **Total BC7 blocks**: 708 - **Per-mode block breakdown**: - Mode 0: 45 blocks (3 subsets, RGB) - Mode 1: 154 blocks (2 subsets, RGB + shared p-bit) - Mode 2: 159 blocks (3 subsets, RGB) - Mode 3: 156 blocks (2 subsets, RGB + p-bits) - Mode 4: 18 blocks (1 subset, RGB + Alpha, 2-bit index / 3-bit index) - Mode 5: 3 blocks (1 subset, RGB + Alpha) - Mode 6: 3 blocks (1 subset, RGB + Alpha, high precision) - Mode 7: 170 blocks (2 subsets, RGB + Alpha, p-bits) - **Rotations & Index selection**: - Rotation: rot 0 (693), rot 1 (6), rot 2 (4), rot 3 (5) — all 4 rotations exercised. - Index selection: sel 0 (700), sel 1 (8) — both selections exercised. - **Residual path (`unzigzag(d_byte)`)**: **319 of 708 blocks** have a non-zero endpoint residual delta (`delta != 0`), exercising the delta reconstruction equation. - **Dictionary path (`BC7_DICTIONARY`)**: **712 endpoint references** access dictionary entries across **217 distinct dictionary indices** (out of 255 total); 470 references read prior block history (`0 < r <= i`), and 234 references read zero (`r == 0`). - **Result**: 100% of blocks in all 30 streams match the reference decoder bit-for-bit. ### 2. In-Repo Source-Built BC7 Case Outside Mode 6 (`tests/startup_stub_consumer.cpp`) - Added 1-block BC7 Mode 1 test (172 bytes packed, 16 bytes destination). - Exercised features: 2 subsets, shared p-bit, non-zero endpoint residual delta (`delta = -47`), and dictionary lookups (`er = 213`, `xr = 4`). - Output verified against expected decoded bytes (`c2 5b 48 7a ea 84 a4 4b fd f7 15 87 90 c4 49 ac`). ### 3. Wrong Destination Size & Subsequent Valid Request - Added negative control with mismatched `destination_size`: enqueues the 2-block BC7 stream (32-byte payload) requesting `destination_size = 16`. - Verified `decode_bcpack` rejects unconsumed stream bytes, the request fails with `E_FAIL` (`hr1 != 0`), and the destination buffer sentinel (`0xBB`) remains completely untouched. - Verified that the subsequent request (valid BC7 Mode 1) in the same queue completes successfully (`hr2 == 0`) with destination memory populated correctly. ### Test Execution - `ctest --preset dev -R '^startup_stubs$' -V`: **PASS** (`dstorage control: exit=0 ok`, `0.68s`) - `ctest --preset release -R '^startup_stubs$' -V`: **PASS** (`0.35s`) - `ctest --preset dev -R '^bcpack_' -V`: **PASS** (3/3) - `ctest --preset release -R '^bcpack_' -V`: **PASS** (3/3)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1329
No description provided.