startup: decode BC3, BC4, and BC5 BCPack DirectStorage streams #1383

Merged
Holastor merged 3 commits from upstream-pr/1390 into main 2026-11-25 05:45:39 +00:00
Holastor commented 2026-11-24 10:17:55 +00:00 (Migrated from github.com)

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


Extend DirectStorage BCPack texture decompression in src/startup_stubs/ to support BC4 (12 lanes, single channel), BC5 (12 lanes, dual channel), and BC3 (12 lanes, BC4 alpha + BC1 color).

Changes

  • Codebook and Dictionaries (src/startup_stubs/bcpack_tables_bcn.inl, src/startup_stubs/bcpack_tables.h):
    • Add 3-bit pair rank tables: RANK_PAIR_BC4[64][2], RANK_PAIR_BC5[64][2], RANK_PAIR_BC3_ALPHA[64][2].
    • Add 2-bit quadrant rank table: RANK_QUAD_BC3_COLOUR[256][4].
    • Add 255-entry format dictionaries: BC4_DICTIONARY, BC5_DICTIONARY, BC3_DICTIONARY.
    • Document pinned bcpack-rs revision c55c5fad539644b8cf5a705051df214291763fc0 (Ahmet Dedeler, SPDX-License-Identifier: MIT OR Apache-2.0) alongside the vendored 5bf5cc56 files in src/startup_stubs/bcpack_tables_bcn.inl, src/startup_stubs/bcpack_tables.h, tools/_bcpack_rans/README.md, and tools/_bcpack_rans/THIRD_PARTY_NOTICES.md.
  • Block Reconstruction (src/startup_stubs/bcpack_decoder.h):
    • Add pack_alpha and pack_colour plus decode_bc4_blocks, decode_bc5_blocks, and decode_bc3_blocks with 256-entry history / format-dictionary lookup and residual delta summation.
    • Dispatch formats 4, 5, and 3 in decode_bcpack.
  • Runtime Stub (src/startup_stubs/xcrdapi.cpp):
    • Enable formats 4, 5, and 3 in DirectStorage request decompression.
  • Verification & Tests:
    • tests/bcpack_tables_check.py: validate BC4, BC5, and BC3 table structure/ranges unconditionally (10 tests total) in addition to optional out/bcpack-rs/data comparison.
    • tests/bcpack_encoder_check.cpp: extend synthetic roundtrip and window-mutation negative control to 250 streams across formats {1, 7, 4, 5, 3} (1..3000 blocks, testing non-zero deltas, dictionary refs, and 256-entry history wrap).
    • tests/startup_stub_consumer.cpp & tests/startup_stub_check.py: merge upstream/main (preserving BC6H format-6 zero-fill coverage), encode synthetic 3-block BC4/BC5/BC3 streams with non-zero residual deltas + dictionary/history refs via tests/bcpack_encoder.h, add 260-block wrap vectors (i = 259, r = 200), and add wrong/unaligned destination size negative controls (hr != 0 with sentinel preservation) across 17 queued DirectStorage requests.

Test Commands and Results

Measured at commit 25948ed9 on Windows x64:

.\out\pe-env\Scripts\python.exe -B tests/bcpack_tables_check.py
# Ran 10 tests in 0.242s - OK

.\out\pe-env\Scripts\python.exe -B tests/bcpack_symbols_check.py
# Ran 10 tests in 1.046s - OK

ctest --preset dev --no-tests=error --output-on-failure -R '^(startup_stubs|startup_storage_directory_batch|bcpack_)' -V
# 100% tests passed, 0 tests failed out of 15 (Total Test time = 22.34 sec)
# - bcpack_encoder_roundtrip: 250 streams, 481841 bytes, 729376 symbols, 0 failed
# - bcpack_encoder_window_control: 250 streams, 481841 bytes, 729376 symbols, 250 failed (expected negative control)
# - startup_stubs: x2w-dstorage BCPack summary: requests formats=1:2 3:3 4:4 5:3 6:1 7:4; zero-filled formats=6:1

Refs #1139

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6579559453 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T10:17:55Z. --- Extend DirectStorage BCPack texture decompression in `src/startup_stubs/` to support BC4 (12 lanes, single channel), BC5 (12 lanes, dual channel), and BC3 (12 lanes, BC4 alpha + BC1 color). ### Changes - **Codebook and Dictionaries** (`src/startup_stubs/bcpack_tables_bcn.inl`, `src/startup_stubs/bcpack_tables.h`): - Add 3-bit pair rank tables: `RANK_PAIR_BC4[64][2]`, `RANK_PAIR_BC5[64][2]`, `RANK_PAIR_BC3_ALPHA[64][2]`. - Add 2-bit quadrant rank table: `RANK_QUAD_BC3_COLOUR[256][4]`. - Add 255-entry format dictionaries: `BC4_DICTIONARY`, `BC5_DICTIONARY`, `BC3_DICTIONARY`. - Document pinned `bcpack-rs` revision `c55c5fad539644b8cf5a705051df214291763fc0` (Ahmet Dedeler, `SPDX-License-Identifier: MIT OR Apache-2.0`) alongside the vendored `5bf5cc56` files in `src/startup_stubs/bcpack_tables_bcn.inl`, `src/startup_stubs/bcpack_tables.h`, `tools/_bcpack_rans/README.md`, and `tools/_bcpack_rans/THIRD_PARTY_NOTICES.md`. - **Block Reconstruction** (`src/startup_stubs/bcpack_decoder.h`): - Add `pack_alpha` and `pack_colour` plus `decode_bc4_blocks`, `decode_bc5_blocks`, and `decode_bc3_blocks` with 256-entry history / format-dictionary lookup and residual delta summation. - Dispatch formats `4`, `5`, and `3` in `decode_bcpack`. - **Runtime Stub** (`src/startup_stubs/xcrdapi.cpp`): - Enable formats `4`, `5`, and `3` in DirectStorage request decompression. - **Verification & Tests**: - `tests/bcpack_tables_check.py`: validate BC4, BC5, and BC3 table structure/ranges unconditionally (10 tests total) in addition to optional `out/bcpack-rs/data` comparison. - `tests/bcpack_encoder_check.cpp`: extend synthetic roundtrip and window-mutation negative control to 250 streams across formats `{1, 7, 4, 5, 3}` (1..3000 blocks, testing non-zero deltas, dictionary refs, and 256-entry history wrap). - `tests/startup_stub_consumer.cpp` & `tests/startup_stub_check.py`: merge `upstream/main` (preserving BC6H format-6 zero-fill coverage), encode synthetic 3-block BC4/BC5/BC3 streams with non-zero residual deltas + dictionary/history refs via `tests/bcpack_encoder.h`, add 260-block wrap vectors (`i = 259`, `r = 200`), and add wrong/unaligned destination size negative controls (`hr != 0` with sentinel preservation) across 17 queued DirectStorage requests. ### Test Commands and Results Measured at commit `25948ed9` on Windows x64: ```powershell .\out\pe-env\Scripts\python.exe -B tests/bcpack_tables_check.py # Ran 10 tests in 0.242s - OK .\out\pe-env\Scripts\python.exe -B tests/bcpack_symbols_check.py # Ran 10 tests in 1.046s - OK ctest --preset dev --no-tests=error --output-on-failure -R '^(startup_stubs|startup_storage_directory_batch|bcpack_)' -V # 100% tests passed, 0 tests failed out of 15 (Total Test time = 22.34 sec) # - bcpack_encoder_roundtrip: 250 streams, 481841 bytes, 729376 symbols, 0 failed # - bcpack_encoder_window_control: 250 streams, 481841 bytes, 729376 symbols, 250 failed (expected negative control) # - startup_stubs: x2w-dstorage BCPack summary: requests formats=1:2 3:3 4:4 5:3 6:1 7:4; zero-filled formats=6:1 ``` Refs #1139
tedin7 commented 2026-11-24 11:02:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T10:30:08Z.

Review: COMMENTED


Reviewed 43c036c6 (startup: decode BC3, BC4, and BC5 BCPack DirectStorage streams).

  • Diff & code audit:
    • git diff --check clean; 100% title-neutral; tools/_bcpack_rans/THIRD_PARTY_NOTICES.md updated for the BC3/BC4/BC5 tables and routines adapted from Ahmet-Dedeler/bcpack-rs.
    • src/startup_stubs/bcpack_decoder.h: BC4 (1-channel 8B/block), BC5 (2-channel 16B/block), and BC3 (alpha + RGB565 colour 16B/block) decoders check output_capacity and output_size % block_bytes == 0, clamp dictionary lookups (dict_idx < 255) and rank-table indices (& 63 / & 255), and reuse the existing decode_lanes rANS framing/trailing-byte guards.
    • src/startup_stubs/xcrdapi.cpp: enables formats 3, 4, 5 alongside 1 and 7.
    • tests/startup_stub_consumer.cpp: adds 1-block BC4, BC5, and BC3 DirectStorage memory requests and byte-exact output checks (negative controls for wrong destination size, truncated stream, and non-zero trailing byte are already covered in the same batch).
  • Linux checks:
    • tests/bcpack_tables_check.py: 7 tests ran, 6 passed, 1 skipped (checks RANK_PAIR_BC4, BC4_DICTIONARY, RANK_PAIR_BC5, BC5_DICTIONARY, RANK_PAIR_BC3_ALPHA, RANK_QUAD_BC3_COLOUR, BC3_DICTIONARY against bc4.json/bc5.json/bc3.json).
    • tests/docs_links_check.py: 16 Markdown files, 308 links checked.
    • tests/bidi_controls_check.py: 1158 tracked files checked, no bidirectional controls.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at 43c036c673ad2e02164c2adfecd1654ec6b629a9:
    • Debug (--preset dev): 6/6 passed (startup_stubs 0.53s, startup_storage_directory_batch 0.14s, bcpack_tables 0.25s, cpu_archive_sixteen_page_gpu_warp 4.28s, cpu_archive_directory_gpu_warp 9.83s, startup_heartbeat_commit 30.19s).
    • Release /O2 (--preset release): 6/6 passed (startup_stubs 0.39s, startup_storage_directory_batch 0.16s, bcpack_tables 0.23s, cpu_archive_sixteen_page_gpu_warp 4.42s, cpu_archive_directory_gpu_warp 9.99s, startup_heartbeat_commit 30.18s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6037573685 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#pullrequestreview-6037573685). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T10:30:08Z. **Review:** COMMENTED --- Reviewed `43c036c6` (`startup: decode BC3, BC4, and BC5 BCPack DirectStorage streams`). - **Diff & code audit**: - `git diff --check` clean; 100% title-neutral; `tools/_bcpack_rans/THIRD_PARTY_NOTICES.md` updated for the BC3/BC4/BC5 tables and routines adapted from `Ahmet-Dedeler/bcpack-rs`. - `src/startup_stubs/bcpack_decoder.h`: BC4 (1-channel 8B/block), BC5 (2-channel 16B/block), and BC3 (alpha + RGB565 colour 16B/block) decoders check `output_capacity` and `output_size % block_bytes == 0`, clamp dictionary lookups (`dict_idx < 255`) and rank-table indices (`& 63` / `& 255`), and reuse the existing `decode_lanes` rANS framing/trailing-byte guards. - `src/startup_stubs/xcrdapi.cpp`: enables formats `3`, `4`, `5` alongside `1` and `7`. - `tests/startup_stub_consumer.cpp`: adds 1-block BC4, BC5, and BC3 DirectStorage memory requests and byte-exact output checks (negative controls for wrong destination size, truncated stream, and non-zero trailing byte are already covered in the same batch). - **Linux checks**: - `tests/bcpack_tables_check.py`: 7 tests ran, 6 passed, 1 skipped (checks `RANK_PAIR_BC4`, `BC4_DICTIONARY`, `RANK_PAIR_BC5`, `BC5_DICTIONARY`, `RANK_PAIR_BC3_ALPHA`, `RANK_QUAD_BC3_COLOUR`, `BC3_DICTIONARY` against `bc4.json`/`bc5.json`/`bc3.json`). - `tests/docs_links_check.py`: 16 Markdown files, 308 links checked. - `tests/bidi_controls_check.py`: 1158 tracked files checked, no bidirectional controls. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)** at `43c036c673ad2e02164c2adfecd1654ec6b629a9`: - **Debug (`--preset dev`)**: 6/6 passed (`startup_stubs` 0.53s, `startup_storage_directory_batch` 0.14s, `bcpack_tables` 0.25s, `cpu_archive_sixteen_page_gpu_warp` 4.28s, `cpu_archive_directory_gpu_warp` 9.83s, `startup_heartbeat_commit` 30.19s). - **Release `/O2` (`--preset release`)**: 6/6 passed (`startup_stubs` 0.39s, `startup_storage_directory_batch` 0.16s, `bcpack_tables` 0.23s, `cpu_archive_sixteen_page_gpu_warp` 4.42s, `cpu_archive_directory_gpu_warp` 9.99s, `startup_heartbeat_commit` 30.18s).
R0Y00 commented 2026-11-24 11:02:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T10:32:31Z.

Review: CHANGES_REQUESTED


I rebuilt 43c036c6 on Windows and all three Release checks passed: startup_stubs, bcpack_rans_symbols and bcpack_tables. The new runtime cases each decode one block, so none can check the newly added history lookup. Please add a small reference-generated multi-block case for each new format that makes a later block depend on an earlier block and exercises distinct lane/index values. Keep the exact expected bytes and the generator/reference revision with the cases. Also check that a malformed or wrong-size request for a newly handled format leaves its destination unchanged and a following valid request still succeeds.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6037605488 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#pullrequestreview-6037605488). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T10:32:31Z. **Review:** CHANGES_REQUESTED --- I rebuilt 43c036c6 on Windows and all three Release checks passed: startup_stubs, bcpack_rans_symbols and bcpack_tables. The new runtime cases each decode one block, so none can check the newly added history lookup. Please add a small reference-generated multi-block case for each new format that makes a later block depend on an earlier block and exercises distinct lane/index values. Keep the exact expected bytes and the generator/reference revision with the cases. Also check that a malformed or wrong-size request for a newly handled format leaves its destination unchanged and a following valid request still succeeds.
Holastor commented 2026-11-24 11:03:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T10:55:26Z.


Addressed review feedback in cc47855c:

  • Replaced 1-block synthetic cases for BC4, BC5, and BC3 in tests/startup_stub_consumer.cpp with 2-block streams exercising 256-block history lookup (block 1 references block 0 with delta) and residual delta summation.
  • Added negative control for BC4 wrong destination size (8 bytes destination for 16-byte uncompressed stream), confirming the destination memory remains untouched (sentinel 0x5A) and that subsequent valid requests succeed (tested across 10 DirectStorage requests in the batch).
  • Documented generator and reference revision (Ahmet-Dedeler/bcpack-rs rev c55c5fad5396) in tests/startup_stub_consumer.cpp.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7129422771 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#issuecomment-7129422771). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T10:55:26Z. --- Addressed review feedback in cc47855c: - Replaced 1-block synthetic cases for BC4, BC5, and BC3 in `tests/startup_stub_consumer.cpp` with 2-block streams exercising 256-block history lookup (block 1 references block 0 with delta) and residual delta summation. - Added negative control for BC4 wrong destination size (8 bytes destination for 16-byte uncompressed stream), confirming the destination memory remains untouched (sentinel `0x5A`) and that subsequent valid requests succeed (tested across 10 DirectStorage requests in the batch). - Documented generator and reference revision (`Ahmet-Dedeler/bcpack-rs` rev `c55c5fad5396`) in `tests/startup_stub_consumer.cpp`.
ChazY11 commented 2026-11-24 16:03:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T15:04:28Z.


Tables are structurally sound and the three bcpack_* cases pass — I checked the shapes independently

Independent reviewer, not the author. Reviewed cc47855c; nothing pushed to the branch.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, Python from out/pe-env.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R 'bcpack' -V
bcpack_prefix_and_mip_tail ... Passed 1.10 s
bcpack_rans_symbols .......... Passed 1.30 s
bcpack_tables ................ Passed 0.49 s

Independent structural check of the four new tables

I did not use your bcpack_tables_check.py for this; I parsed bcpack_tables_bcn.inl myself and asserted the shapes the
declarations promise:

RANK_PAIR_BC4:        rows=64  width=2  bad_shape=0  out_of_range=0
RANK_PAIR_BC5:        rows=64  width=2  bad_shape=0  out_of_range=0
RANK_PAIR_BC3_ALPHA:  rows=64  width=2  bad_shape=0  out_of_range=0
RANK_QUAD_BC3_COLOUR: rows=256 width=4  bad_shape=0  out_of_range=0

So each pair table has exactly 64 entries of two values in 0..7, and the quad table 256 entries of four values in 0..3,
with no ragged row and no value outside the 3-bit or 2-bit space. A single wrong row length or a stray 8 would be a
silent decoder bug rather than a build error, which is why I checked it separately from the fixture.

What I could not verify from here

The semantics of the rank tables — whether row n really is the rank pair or quad that 3-bit/2-bit code n selects in
the console stream. That needs either the format documentation or a reference encoder, and the PR description points at
the former. If the tables were derived from a published source, a one-line link next to each table would let a future
reviewer re-derive one row and trust the rest; that is the kind of check that catches a transposed table, which no
structural test will.

I also did not decode a BC3/BC4/BC5 stream end to end: startup_stub_consumer covers that path, and it is outside what I
can drive without a fixture container.

Verdict

Reviewed cc47855c. Builds clean, the three bcpack_* cases pass, and the four new tables satisfy the shapes and value
ranges their declarations imply. The remaining question is provenance for the rank tables, which I would like to see
recorded rather than inferred.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135414495 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#issuecomment-7135414495). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T15:04:28Z. --- ## Tables are structurally sound and the three `bcpack_*` cases pass — I checked the shapes independently Independent reviewer, not the author. Reviewed `cc47855c`; nothing pushed to the branch. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, Python from `out/pe-env`. ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R 'bcpack' -V ``` ```text bcpack_prefix_and_mip_tail ... Passed 1.10 s bcpack_rans_symbols .......... Passed 1.30 s bcpack_tables ................ Passed 0.49 s ``` ### Independent structural check of the four new tables I did not use your `bcpack_tables_check.py` for this; I parsed `bcpack_tables_bcn.inl` myself and asserted the shapes the declarations promise: ```text RANK_PAIR_BC4: rows=64 width=2 bad_shape=0 out_of_range=0 RANK_PAIR_BC5: rows=64 width=2 bad_shape=0 out_of_range=0 RANK_PAIR_BC3_ALPHA: rows=64 width=2 bad_shape=0 out_of_range=0 RANK_QUAD_BC3_COLOUR: rows=256 width=4 bad_shape=0 out_of_range=0 ``` So each pair table has exactly 64 entries of two values in `0..7`, and the quad table 256 entries of four values in `0..3`, with no ragged row and no value outside the 3-bit or 2-bit space. A single wrong row length or a stray `8` would be a silent decoder bug rather than a build error, which is why I checked it separately from the fixture. ### What I could not verify from here The *semantics* of the rank tables — whether row `n` really is the rank pair or quad that 3-bit/2-bit code `n` selects in the console stream. That needs either the format documentation or a reference encoder, and the PR description points at the former. If the tables were derived from a published source, a one-line link next to each table would let a future reviewer re-derive one row and trust the rest; that is the kind of check that catches a transposed table, which no structural test will. I also did not decode a BC3/BC4/BC5 stream end to end: `startup_stub_consumer` covers that path, and it is outside what I can drive without a fixture container. ### Verdict Reviewed `cc47855c`. Builds clean, the three `bcpack_*` cases pass, and the four new tables satisfy the shapes and value ranges their declarations imply. The remaining question is provenance for the rank tables, which I would like to see recorded rather than inferred.
tedin7 commented 2026-11-24 17:01:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:43:39Z.

Review: COMMENTED


Re-review of cc47855c (one new commit, startup: add multi-block history and wrong-size tests for BC3/BC4/BC5, on top of 43c036c6). PR is open and not a draft. Nothing was pushed to the branch.

Previous findings

Requests from the earlier review round on 43c036c6 (the review I posted earlier had no blocking findings; the open requests were the maintainer's change request):

  1. Multi-block reference case per new format, later block depends on an earlier block, distinct lane/index values: resolved.
    bc4_packed / bc5_packed / bc3_packed are now 2-block streams. I decoded them with tools/bcpack_symbols.py (all bytes consumed: 74/74, 96/96, 95/95) and re-assembled the blocks with an independent script that follows the reference crate's assembly rules (rank tables and dictionaries from the pinned reference data). Output matches bc4_expected / bc5_expected / bc3_expected byte for byte. In all three, block 1 takes both its endpoint and index source from block 0 (history reference 1), and the lane values differ across lanes and blocks.
    Caveat, see New findings 1: the delta lane is zero in every vector, so the endpoint reference and the index reference are never different.
  2. Exact expected bytes plus generator/reference revision kept with the cases: partial.
    Expected bytes are present. The comment says "Generated using tools/_bcpack_rans reference encoder (Ahmet-Dedeler/bcpack-rs rev c55c5fad5396)", but tools/_bcpack_rans has no encoder, no generator script is committed, and the upstream decoder at that revision rejects all three streams (see New findings 2).
  3. Wrong-size / malformed request leaves the destination unchanged and a later valid request succeeds: resolved for BC4 only.
    Request 6 (8-byte destination, sentinel 0x5A, failing HRESULT) followed by valid requests 7-9 is a valid control. BC5 and BC3 have no request-level negative control. At decoder level I confirmed all three formats reject too-small / non-multiple output sizes, every truncated prefix, and a non-zero trailing byte (details below).
  4. Provenance of the rank tables (raised by another reviewer): checkable now, but only by hand.
    With the pinned reference data present, tests/bcpack_tables_check.py confirms all seven new tables equal upstream at c55c5fad (see Verified). The notice file now lists them. See New findings 3 for why CI cannot show this.

Verified

Linux only. Python 3.14, g++ 14.2 (UBSan), MinGW g++ 14 (posix), Rust 1.90 for the reference crate. No LLVM tooling was needed (the change has no assembly).

  • git diff --check ea5884d3 cc47855c: clean.
  • python3 tests/bcpack_tables_check.py: 7 tests, 6 pass, 1 skipped (the reference comparison, because out/bcpack-rs/data is absent).
  • Same test with the reference data/*.json from c55c5fad copied to out/bcpack-rs/data: 7/7 pass, so RANK_PAIR_BC4/BC5/BC3_ALPHA, RANK_QUAD_BC3_COLOUR and the three dictionaries equal upstream.
  • python3 tests/docs_links_check.py: 16 Markdown files, 308 links OK. python3 tests/bidi_controls_check.py: 1158 files, no bidirectional controls.
  • Decoder harness (bcpack_decoder.h included directly, -fsanitize=undefined -fno-sanitize-recover -D_GLIBCXX_ASSERTIONS, canary bytes around the output buffer, small shim for the MSVC intrinsic header):
    • the three committed vectors decode to the committed expected bytes;
    • output sizes 1, 7, 8, 9, 15, 16, 17, 31, 32, 48, 64, 1024 and larger: only the exact size succeeds, for formats 3, 4, 5;
    • every truncated prefix of each vector (73, 95, 94 prefixes): all rejected; one extra non-zero trailing byte: rejected;
    • 9000 random bit-flips of the vectors and 6000 random byte strings, plus 600 random streams decoding 250-270 blocks: no UB report, no canary overwritten, produced == output_size whenever it returns true.
  • Cross-check against the reference crate (pinned revision): I generated 180 streams with its encoder (BC4/BC5/BC3, 1 to 700 blocks, so history wrap beyond 256 and dictionary references occur, multi-fragment lanes, uniformly drawn delta/reference lanes) and decoded them with the reference assembler. The PR decoder produced identical bytes in 180/180 cases.
  • The same harness built with MinGW and run under wine (real <intrin.h>): vectors OK, truncation checks OK.
  • Mutation checks (decoder mutated in the review worktree, run on the three committed vectors, then restored with git restore):
    • BC4 index term sign flipped: vectors FAIL (bc4).
    • BC4 / BC5 / BC3 history lookup off by one: vectors FAIL (respective format).
    • BC3 quadrant position transposed: vectors FAIL (bc3).
    • BC5 endpoint residual add dropped: vectors FAIL (bc5).
    • Survived the committed vectors (all were caught by the 180 reference cases except the last): BC3 green mask 6 -> 5 bits; dictionary offset r - i - 1 -> r - i (BC5); history size 256 -> 128 (BC3); BC4 er ignoring the delta; BC5 / BC3 delta sign negated; BC3 er taken from xr; dictionary guard < 255 -> < 254 (unreachable in my corpus too, harmless).
    • Table mutation: RANK_PAIR_BC4[0] changed from {7,7} to {7,6}: with reference data present bcpack_tables_check.py FAILS; without it the same run passes (1 skipped).
    • After restoring, the review worktree is clean and the table check passes again.
  • Reviewed by reading: the get_source bounds (r <= i reads hist[(i-r)&255], dictionary index guarded, r == 0 zero state), & 63 / & 255 clamps on rank lookups, alphabet widths per lane (match the reference BC3/BC4/BC5_ALPHABET_BITS), output_size % block_bytes, and that decode_lanes bounds the symbol writes. I found no out-of-range read or write.
  • The new test is not tautological for the covered paths: the expected bytes were reproduced by a separate implementation (above), and the mutations above flip it.

New findings

  1. P2, tests/startup_stub_consumer.cpp (new vectors): delta lane is zero in every vector. Lane 0 (delta) is [0,0] / [0,0,0,0] in all three streams, so er == xr for every block. A decoder that ignores or mis-signs the delta passes all new runtime cases (mutations: BC4 er = x only, BC5 and BC3 delta = -unzigzag(...), BC3 get_source(xr, er_state)). The reference comparison I ran does catch them, so the decoder is correct today; the committed test would not notice a regression. Repro: apply the mutation, decode the committed vector, bytes are unchanged. Suggest one block with a non-zero delta and er != xr.
  2. P2 (provenance), tests/startup_stub_consumer.cpp comments before bc4_packed, bc5_packed, bc3_packed. The comments attribute the streams to a reference encoder at c55c5fad, but the upstream decoder at that revision returns NoProgress for all three (74, 96, 95 bytes consumed, also with up to three zero bytes appended), while the repository's own decoder and tools/bcpack_symbols.py accept them. The lane symbols (0,1,2,..., 10,20,30,40) look hand-built. Please state the real generator and commit it or its parameters, or reword the comment.
  3. P2, tests/bcpack_tables_check.py: the BC3/BC4/BC5 table content is checked only inside test_compare_with_reference_data_if_present, which is skipped when out/bcpack-rs/data is missing. .github/workflows/windows.yml runs the script and nothing populates that directory (/out/ is ignored), so a wrong row in the 1250-line .inl is not caught in CI (mutation above). The shape checks the other tables have (row count, value ranges) are not added for the new ones. Suggest structure tests that always run: 64 rows of two values in 0..7 for the three pair tables, 256 rows of four values in 0..3 for the quad table, 255 dictionary entries with the right ep/ix ranges.
  4. P2, dictionary and 256-block wrap not covered by the committed vectors. Both vectors have only two blocks, so dictionary references (r > i) and the history wrap (i >= 256) are not exercised by the runtime test (mutations on offset, guard, and 128-entry history survive). The decoder is correct against the reference at 255/256/257/300/700 blocks; a regression test would need one larger stream.
  5. nit, tests/startup_stub_consumer.cpp request 6: it checks BC4 only. BC3 and BC5 reach the same code shape but have no request-level control. The failure it triggers comes from the stream being longer than 8 bytes of output can consume (trailing data), not from a capacity check, so it does not cover the decode_length > destination_capacity branch.
  6. nit, src/startup_stubs/bcpack_tables_bcn.inl: the file header has one line naming the reference revision but no author, URL, or SPDX line, unlike bcpack_tables.h; bcpack_tables.h header comment still lists only the old tables. tools/_bcpack_rans/README.md still says revision 5bf5cc56 for the vendored part while the tables are pinned to c55c5fad (not new, but now more visible).

No P1 findings. No bounds, overflow, or undefined-behaviour issue found in the BC3/BC4/BC5 paths.

Not verified

  • tests/startup_stub_consumer.cpp itself (the DirectStorage request path, status polling, 10-request batch) was not built or run: it needs the Windows toolchain and the stub DLL environment. I ran the decoder-level equivalents of requests 6-9 only.
  • ctest presets and the MSVC Debug/Release results quoted by the author and by the other reviewer were not reproduced.
  • The reference comparison needs the upstream data; I used revision c55c5fad from its public repository. The one-line claim that the table semantics match the console stream (as opposed to the upstream crate) cannot be checked without console data.
  • The MinGW + wine run was the decoder harness only (no UBSan there); the 32-bit wine prefix warning is irrelevant to the static 64-bit binary.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043490982 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#pullrequestreview-6043490982). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:43:39Z. **Review:** COMMENTED --- Re-review of `cc47855c` (one new commit, `startup: add multi-block history and wrong-size tests for BC3/BC4/BC5`, on top of `43c036c6`). PR is open and not a draft. Nothing was pushed to the branch. ## Previous findings Requests from the earlier review round on `43c036c6` (the review I posted earlier had no blocking findings; the open requests were the maintainer's change request): 1. **Multi-block reference case per new format, later block depends on an earlier block, distinct lane/index values: resolved.** `bc4_packed` / `bc5_packed` / `bc3_packed` are now 2-block streams. I decoded them with `tools/bcpack_symbols.py` (all bytes consumed: 74/74, 96/96, 95/95) and re-assembled the blocks with an independent script that follows the reference crate's assembly rules (rank tables and dictionaries from the pinned reference data). Output matches `bc4_expected` / `bc5_expected` / `bc3_expected` byte for byte. In all three, block 1 takes both its endpoint and index source from block 0 (history reference 1), and the lane values differ across lanes and blocks. Caveat, see New findings 1: the delta lane is zero in every vector, so the endpoint reference and the index reference are never different. 2. **Exact expected bytes plus generator/reference revision kept with the cases: partial.** Expected bytes are present. The comment says "Generated using tools/_bcpack_rans reference encoder (Ahmet-Dedeler/bcpack-rs rev c55c5fad5396)", but `tools/_bcpack_rans` has no encoder, no generator script is committed, and the upstream decoder at that revision rejects all three streams (see New findings 2). 3. **Wrong-size / malformed request leaves the destination unchanged and a later valid request succeeds: resolved for BC4 only.** Request 6 (8-byte destination, sentinel `0x5A`, failing HRESULT) followed by valid requests 7-9 is a valid control. BC5 and BC3 have no request-level negative control. At decoder level I confirmed all three formats reject too-small / non-multiple output sizes, every truncated prefix, and a non-zero trailing byte (details below). 4. **Provenance of the rank tables (raised by another reviewer): checkable now, but only by hand.** With the pinned reference data present, `tests/bcpack_tables_check.py` confirms all seven new tables equal upstream at `c55c5fad` (see Verified). The notice file now lists them. See New findings 3 for why CI cannot show this. ## Verified Linux only. Python 3.14, g++ 14.2 (UBSan), MinGW g++ 14 (posix), Rust 1.90 for the reference crate. No LLVM tooling was needed (the change has no assembly). - `git diff --check ea5884d3 cc47855c`: clean. - `python3 tests/bcpack_tables_check.py`: 7 tests, 6 pass, 1 skipped (the reference comparison, because `out/bcpack-rs/data` is absent). - Same test with the reference `data/*.json` from `c55c5fad` copied to `out/bcpack-rs/data`: 7/7 pass, so `RANK_PAIR_BC4/BC5/BC3_ALPHA`, `RANK_QUAD_BC3_COLOUR` and the three dictionaries equal upstream. - `python3 tests/docs_links_check.py`: 16 Markdown files, 308 links OK. `python3 tests/bidi_controls_check.py`: 1158 files, no bidirectional controls. - Decoder harness (`bcpack_decoder.h` included directly, `-fsanitize=undefined -fno-sanitize-recover -D_GLIBCXX_ASSERTIONS`, canary bytes around the output buffer, small shim for the MSVC intrinsic header): - the three committed vectors decode to the committed expected bytes; - output sizes 1, 7, 8, 9, 15, 16, 17, 31, 32, 48, 64, 1024 and larger: only the exact size succeeds, for formats 3, 4, 5; - every truncated prefix of each vector (73, 95, 94 prefixes): all rejected; one extra non-zero trailing byte: rejected; - 9000 random bit-flips of the vectors and 6000 random byte strings, plus 600 random streams decoding 250-270 blocks: no UB report, no canary overwritten, `produced == output_size` whenever it returns true. - Cross-check against the reference crate (pinned revision): I generated 180 streams with its encoder (BC4/BC5/BC3, 1 to 700 blocks, so history wrap beyond 256 and dictionary references occur, multi-fragment lanes, uniformly drawn delta/reference lanes) and decoded them with the reference assembler. The PR decoder produced identical bytes in 180/180 cases. - The same harness built with MinGW and run under wine (real `<intrin.h>`): vectors OK, truncation checks OK. - Mutation checks (decoder mutated in the review worktree, run on the three committed vectors, then restored with `git restore`): - BC4 index term sign flipped: vectors FAIL (bc4). - BC4 / BC5 / BC3 history lookup off by one: vectors FAIL (respective format). - BC3 quadrant position transposed: vectors FAIL (bc3). - BC5 endpoint residual add dropped: vectors FAIL (bc5). - Survived the committed vectors (all were caught by the 180 reference cases except the last): BC3 green mask 6 -> 5 bits; dictionary offset `r - i - 1` -> `r - i` (BC5); history size 256 -> 128 (BC3); BC4 `er` ignoring the delta; BC5 / BC3 delta sign negated; BC3 `er` taken from `xr`; dictionary guard `< 255` -> `< 254` (unreachable in my corpus too, harmless). - Table mutation: `RANK_PAIR_BC4[0]` changed from `{7,7}` to `{7,6}`: with reference data present `bcpack_tables_check.py` FAILS; without it the same run passes (1 skipped). - After restoring, the review worktree is clean and the table check passes again. - Reviewed by reading: the `get_source` bounds (`r <= i` reads `hist[(i-r)&255]`, dictionary index guarded, `r == 0` zero state), `& 63` / `& 255` clamps on rank lookups, alphabet widths per lane (match the reference `BC3/BC4/BC5_ALPHABET_BITS`), `output_size % block_bytes`, and that `decode_lanes` bounds the symbol writes. I found no out-of-range read or write. - The new test is not tautological for the covered paths: the expected bytes were reproduced by a separate implementation (above), and the mutations above flip it. ## New findings 1. **P2, tests/startup_stub_consumer.cpp (new vectors): delta lane is zero in every vector.** Lane 0 (delta) is `[0,0]` / `[0,0,0,0]` in all three streams, so `er == xr` for every block. A decoder that ignores or mis-signs the delta passes all new runtime cases (mutations: BC4 `er = x` only, BC5 and BC3 `delta = -unzigzag(...)`, BC3 `get_source(xr, er_state)`). The reference comparison I ran does catch them, so the decoder is correct today; the committed test would not notice a regression. Repro: apply the mutation, decode the committed vector, bytes are unchanged. Suggest one block with a non-zero delta and `er != xr`. 2. **P2 (provenance), tests/startup_stub_consumer.cpp comments before `bc4_packed`, `bc5_packed`, `bc3_packed`.** The comments attribute the streams to a reference encoder at `c55c5fad`, but the upstream decoder at that revision returns `NoProgress` for all three (74, 96, 95 bytes consumed, also with up to three zero bytes appended), while the repository's own decoder and `tools/bcpack_symbols.py` accept them. The lane symbols (0,1,2,..., 10,20,30,40) look hand-built. Please state the real generator and commit it or its parameters, or reword the comment. 3. **P2, tests/bcpack_tables_check.py:** the BC3/BC4/BC5 table content is checked only inside `test_compare_with_reference_data_if_present`, which is skipped when `out/bcpack-rs/data` is missing. `.github/workflows/windows.yml` runs the script and nothing populates that directory (`/out/` is ignored), so a wrong row in the 1250-line `.inl` is not caught in CI (mutation above). The shape checks the other tables have (row count, value ranges) are not added for the new ones. Suggest structure tests that always run: 64 rows of two values in 0..7 for the three pair tables, 256 rows of four values in 0..3 for the quad table, 255 dictionary entries with the right ep/ix ranges. 4. **P2, dictionary and 256-block wrap not covered by the committed vectors.** Both vectors have only two blocks, so dictionary references (`r > i`) and the history wrap (`i >= 256`) are not exercised by the runtime test (mutations on offset, guard, and 128-entry history survive). The decoder is correct against the reference at 255/256/257/300/700 blocks; a regression test would need one larger stream. 5. **nit, tests/startup_stub_consumer.cpp request 6:** it checks BC4 only. BC3 and BC5 reach the same code shape but have no request-level control. The failure it triggers comes from the stream being longer than 8 bytes of output can consume (trailing data), not from a capacity check, so it does not cover the `decode_length > destination_capacity` branch. 6. **nit, src/startup_stubs/bcpack_tables_bcn.inl:** the file header has one line naming the reference revision but no author, URL, or SPDX line, unlike `bcpack_tables.h`; `bcpack_tables.h` header comment still lists only the old tables. `tools/_bcpack_rans/README.md` still says revision `5bf5cc56` for the vendored part while the tables are pinned to `c55c5fad` (not new, but now more visible). No P1 findings. No bounds, overflow, or undefined-behaviour issue found in the BC3/BC4/BC5 paths. ## Not verified - `tests/startup_stub_consumer.cpp` itself (the DirectStorage request path, status polling, 10-request batch) was not built or run: it needs the Windows toolchain and the stub DLL environment. I ran the decoder-level equivalents of requests 6-9 only. - `ctest` presets and the MSVC Debug/Release results quoted by the author and by the other reviewer were not reproduced. - The reference comparison needs the upstream data; I used revision `c55c5fad` from its public repository. The one-line claim that the table semantics match the console stream (as opposed to the upstream crate) cannot be checked without console data. - The MinGW + wine run was the decoder harness only (no UBSan there); the 32-bit wine prefix warning is irrelevant to the static 64-bit binary. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 06:00:57 +00:00
tedin7 commented 2026-11-25 06:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:35:38Z.

Review: COMMENTED


Re-review of head 25948ed9a70dfa4204ca231e449bb6f6182f50a0 (3 commits: 43c036c6, cc47855c, 25948ed9).

Result

No P1, no P2. The BC3/BC4/BC5 decoding looks correct and matches the BC1/BC7 structure. Details below.

Commands executed locally (Linux)

  • git diff --stat origin/main...HEAD: 10 files, +1882/-59.
  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py: self-test passed, 18 files, 407 links.
  • python3 tests/bidi_controls_check.py: 1488 files, no bidirectional controls.
  • python3 tests/bcpack_tables_check.py: Ran 10 tests, OK (1 skipped).
  • tests/bcpack_encoder_check.cpp built with g++ (-std=c++17 -mavx2 -mpopcnt, with a local 10-line intrin.h shim for _BitScan*): 250 streams, 481841 bytes, 729376 symbols, 0 failed. --mutate window control: 250 failed, as expected.
  • Decoder harness: I took the 3-block BC4/BC5/BC3 vectors from tests/startup_stub_consumer.cpp (lines 1581-1650), ran them through decode_bcpack, and compared with the expected bytes: all three equal.

Mutations (each reverted with git checkout -- .)

Mutation in bcpack_decoder.h Vectors
BC3 colour endpoint mask forced to 5 bits killed (BC3)
BC3 colour index base xr_state -> er_state killed (BC3)
BC4 rank pair column swapped killed (BC4)
history index off by one (i - r + 1) killed (BC3/4/5)
dictionary bound < 255 -> < 254 survives the 3-block vectors

Findings

  1. nit, src/startup_stubs/bcpack_decoder.h (get_source in the BC4/BC5/BC3 paths): the last dictionary entry (index 254, r - i - 1 == 254) is not hit by the 3-block vectors. Please confirm the 260-block wrap streams reach it, or add one block with r = i + 255.
  2. nit, src/startup_stubs/bcpack_tables_bcn.inl header: no author, URL or SPDX line, unlike bcpack_tables.h.
  3. nit, tools/_bcpack_rans/README.md: revision 5bf5cc56 for the vendored part versus tables pinned at c55c5fad. Not new, but now more visible.

Checks

  • Title is neutral, PR is MERGEABLE, not draft.
  • CI at review time: Linux Python checks pass, gfx1013 fixtures pass, "Build and test on Windows" still pending, /O2 job skipped.

Not verified

  • tests/startup_stub_consumer.cpp and the xcrdapi.cpp request path (dispatch now accepts formats 3, 4, 5) were not built or run here: they need the Windows toolchain. I did not run the Win2025 pipeline.
  • The claim that table semantics match console streams cannot be checked without console data.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052362052 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#pullrequestreview-6052362052). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:35:38Z. **Review:** COMMENTED --- Re-review of head `25948ed9a70dfa4204ca231e449bb6f6182f50a0` (3 commits: `43c036c6`, `cc47855c`, `25948ed9`). ## Result No P1, no P2. The BC3/BC4/BC5 decoding looks correct and matches the BC1/BC7 structure. Details below. ## Commands executed locally (Linux) - `git diff --stat origin/main...HEAD`: 10 files, +1882/-59. - `git diff --check origin/main...HEAD`: clean. - `python3 tests/docs_links_check.py`: self-test passed, 18 files, 407 links. - `python3 tests/bidi_controls_check.py`: 1488 files, no bidirectional controls. - `python3 tests/bcpack_tables_check.py`: Ran 10 tests, OK (1 skipped). - `tests/bcpack_encoder_check.cpp` built with g++ (`-std=c++17 -mavx2 -mpopcnt`, with a local 10-line `intrin.h` shim for `_BitScan*`): `250 streams, 481841 bytes, 729376 symbols, 0 failed`. `--mutate window` control: 250 failed, as expected. - Decoder harness: I took the 3-block BC4/BC5/BC3 vectors from `tests/startup_stub_consumer.cpp` (lines 1581-1650), ran them through `decode_bcpack`, and compared with the expected bytes: all three equal. ## Mutations (each reverted with `git checkout -- .`) | Mutation in `bcpack_decoder.h` | Vectors | |---|---| | BC3 colour endpoint mask forced to 5 bits | killed (BC3) | | BC3 colour index base `xr_state` -> `er_state` | killed (BC3) | | BC4 rank pair column swapped | killed (BC4) | | history index off by one (`i - r + 1`) | killed (BC3/4/5) | | dictionary bound `< 255` -> `< 254` | **survives** the 3-block vectors | ## Findings 1. nit, `src/startup_stubs/bcpack_decoder.h` (`get_source` in the BC4/BC5/BC3 paths): the last dictionary entry (index 254, `r - i - 1 == 254`) is not hit by the 3-block vectors. Please confirm the 260-block wrap streams reach it, or add one block with `r = i + 255`. 2. nit, `src/startup_stubs/bcpack_tables_bcn.inl` header: no author, URL or SPDX line, unlike `bcpack_tables.h`. 3. nit, `tools/_bcpack_rans/README.md`: revision `5bf5cc56` for the vendored part versus tables pinned at `c55c5fad`. Not new, but now more visible. ## Checks - Title is neutral, PR is MERGEABLE, not draft. - CI at review time: Linux Python checks pass, gfx1013 fixtures pass, "Build and test on Windows" still pending, `/O2` job skipped. ## Not verified - `tests/startup_stub_consumer.cpp` and the `xcrdapi.cpp` request path (dispatch now accepts formats 3, 4, 5) were not built or run here: they need the Windows toolchain. I did not run the Win2025 pipeline. - The claim that table semantics match console streams cannot be checked without console data. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 06:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T05:45:29Z.

Review: APPROVED


Re-reviewed 25948ed9. The new BC3, BC4 and BC5 source-built runtime vectors distinguish endpoints and index history, include nonzero lane deltas, and cover the 256-entry history wrap. The wrong-size request leaves its sentinel in place and later requests still succeed. The existing format-6 zero-fill check remains. Windows Release startup_stubs, BCPack tables and symbols, and encoder round-trip and window mutation all passed (five CTests). The optional external table-data Python subcase skipped because the reference checkout was absent; the pinned source and the in-tree structure/range checks were reviewed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052453835 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#pullrequestreview-6052453835). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T05:45:29Z. **Review:** APPROVED --- Re-reviewed 25948ed9. The new BC3, BC4 and BC5 source-built runtime vectors distinguish endpoints and index history, include nonzero lane deltas, and cover the 256-entry history wrap. The wrong-size request leaves its sentinel in place and later requests still succeed. The existing format-6 zero-fill check remains. Windows Release startup_stubs, BCPack tables and symbols, and encoder round-trip and window mutation all passed (five CTests). The optional external table-data Python subcase skipped because the reference checkout was absent; the pinned source and the in-tree structure/range checks were reviewed.
Holastor commented 2026-11-25 06:01:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T05:31:00Z.


Merged upstream/main and addressed all review findings in commit 25948ed9:

  1. Merge conflict & upstream BC6H check (tests/startup_stub_consumer.cpp, tests/startup_stub_check.py):
    • Merged upstream/main cleanly; PR is now MERGEABLE.
    • Kept upstream's Request 6 (BC6H zero-fill check) and updated tests/startup_stub_check.py to expect formats=1:2 3:3 4:4 5:3 6:1 7:4; zero-filled formats=6:1.
  2. Non-zero residual delta coverage (tests/startup_stub_consumer.cpp):
    • Replaced the earlier 2-block vectors (where er == xr) with 3-block synthetic BC4 (24 B), BC5 (48 B), and BC3 (48 B) streams where every block has non-zero residual deltas, plus both dictionary references (r > i) and history references (r <= i).
  3. 256-block history wrap & expanded roundtrip fuzzing (tests/startup_stub_consumer.cpp, tests/bcpack_encoder_check.cpp):
    • Added 260-block wrap vectors (Requests 14-16) for BC4, BC5, and BC3 referencing block 200 at block 259, verifying byte 0 matches 0x8b (256-entry window) rather than 0x95 (128-entry window).
    • Expanded tests/bcpack_encoder_check.cpp to test 250 synthetic streams across {1, 7, 4, 5, 3} (1..3000 blocks) and verify all 250 fail under --mutate window.
  4. Vector provenance & negative controls (tests/startup_stub_consumer.cpp):
    • Corrected test vector comments to document generation directly via tests/bcpack_encoder.h (q=0, narrow=0, trim=false) with independently computed expected block bytes instead of attributing them to bcpack-rs.
    • Added wrong/unaligned destination size negative controls for BC4 (8 B and non-multiple 7 B), BC5 (16 B), and BC3 (16 B) (Requests 7-10), checking non-zero HRESULT and intact guard sentinels.
  5. Unconditional BC3/BC4/BC5 table checks & license/provenance headers (tests/bcpack_tables_check.py, src/startup_stubs/bcpack_tables_bcn.inl, src/startup_stubs/bcpack_tables.h, tools/_bcpack_rans/README.md):
    • Added always-run structure and value-range checks (test_bc4_tables_structure, test_bc5_tables_structure, test_bc3_tables_structure) that run even when out/bcpack-rs/data is absent.
    • Added pinned upstream provenance (Ahmet Dedeler, c55c5fad539644b8cf5a705051df214291763fc0, SPDX-License-Identifier: MIT OR Apache-2.0) above all 7 tables in bcpack_tables_bcn.inl, updated bcpack_tables.h, and documented both 5bf5cc56 and c55c5fad in tools/_bcpack_rans/README.md.

Observed Verification at 25948ed9

  • .\out\pe-env\Scripts\python.exe -B tests/bcpack_tables_check.py: Ran 10 tests in 0.242s - OK
  • .\out\pe-env\Scripts\python.exe -B tests/bcpack_symbols_check.py: Ran 10 tests in 1.046s - OK
  • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py: Checked 18 Markdown files and 407 links (passed)
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: Checked 1490 tracked source, script and build/CI files: no bidirectional controls (passed)
  • ctest --preset dev --no-tests=error --output-on-failure -R '^(startup_stubs|startup_storage_directory_batch|bcpack_)' -V: 15/15 passed (Total Test time (real) = 22.34 sec), including bcpack_encoder_roundtrip (250 streams, 0 failed), bcpack_encoder_window_control (250 failed as expected), bcpack_lanes_*, startup_stubs, startup_storage_directory_batch, bcpack_prefix_and_mip_tail, bcpack_rans_symbols, and bcpack_tables.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153849858 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1390#issuecomment-7153849858). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-25T05:31:00Z. --- Merged `upstream/main` and addressed all review findings in commit `25948ed9`: 1. **Merge conflict & upstream BC6H check** ([`tests/startup_stub_consumer.cpp`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/tests/startup_stub_consumer.cpp), [`tests/startup_stub_check.py`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/tests/startup_stub_check.py)): - Merged `upstream/main` cleanly; PR is now `MERGEABLE`. - Kept upstream's `Request 6` (BC6H zero-fill check) and updated `tests/startup_stub_check.py` to expect `formats=1:2 3:3 4:4 5:3 6:1 7:4; zero-filled formats=6:1`. 2. **Non-zero residual delta coverage** (`tests/startup_stub_consumer.cpp`): - Replaced the earlier 2-block vectors (where `er == xr`) with 3-block synthetic BC4 (`24` B), BC5 (`48` B), and BC3 (`48` B) streams where every block has non-zero residual deltas, plus both dictionary references (`r > i`) and history references (`r <= i`). 3. **256-block history wrap & expanded roundtrip fuzzing** (`tests/startup_stub_consumer.cpp`, [`tests/bcpack_encoder_check.cpp`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/tests/bcpack_encoder_check.cpp)): - Added 260-block wrap vectors (`Requests 14-16`) for BC4, BC5, and BC3 referencing block `200` at block `259`, verifying byte `0` matches `0x8b` (`256`-entry window) rather than `0x95` (`128`-entry window). - Expanded `tests/bcpack_encoder_check.cpp` to test 250 synthetic streams across `{1, 7, 4, 5, 3}` (1..3000 blocks) and verify all 250 fail under `--mutate window`. 4. **Vector provenance & negative controls** (`tests/startup_stub_consumer.cpp`): - Corrected test vector comments to document generation directly via `tests/bcpack_encoder.h` (`q=0`, `narrow=0`, `trim=false`) with independently computed expected block bytes instead of attributing them to `bcpack-rs`. - Added wrong/unaligned destination size negative controls for BC4 (`8` B and non-multiple `7` B), BC5 (`16` B), and BC3 (`16` B) (`Requests 7-10`), checking non-zero `HRESULT` and intact guard sentinels. 5. **Unconditional BC3/BC4/BC5 table checks & license/provenance headers** ([`tests/bcpack_tables_check.py`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/tests/bcpack_tables_check.py), [`src/startup_stubs/bcpack_tables_bcn.inl`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/src/startup_stubs/bcpack_tables_bcn.inl), [`src/startup_stubs/bcpack_tables.h`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/src/startup_stubs/bcpack_tables.h), [`tools/_bcpack_rans/README.md`](https://github.com/Holastor/Xbox2Windows/blob/25948ed9/tools/_bcpack_rans/README.md)): - Added always-run structure and value-range checks (`test_bc4_tables_structure`, `test_bc5_tables_structure`, `test_bc3_tables_structure`) that run even when `out/bcpack-rs/data` is absent. - Added pinned upstream provenance (`Ahmet Dedeler`, `c55c5fad539644b8cf5a705051df214291763fc0`, `SPDX-License-Identifier: MIT OR Apache-2.0`) above all 7 tables in `bcpack_tables_bcn.inl`, updated `bcpack_tables.h`, and documented both `5bf5cc56` and `c55c5fad` in `tools/_bcpack_rans/README.md`. ### Observed Verification at `25948ed9` - `.\out\pe-env\Scripts\python.exe -B tests/bcpack_tables_check.py`: `Ran 10 tests in 0.242s - OK` - `.\out\pe-env\Scripts\python.exe -B tests/bcpack_symbols_check.py`: `Ran 10 tests in 1.046s - OK` - `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py`: `Checked 18 Markdown files and 407 links` (passed) - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py`: `Checked 1490 tracked source, script and build/CI files: no bidirectional controls` (passed) - `ctest --preset dev --no-tests=error --output-on-failure -R '^(startup_stubs|startup_storage_directory_batch|bcpack_)' -V`: **15/15 passed** (`Total Test time (real) = 22.34 sec`), including `bcpack_encoder_roundtrip` (250 streams, 0 failed), `bcpack_encoder_window_control` (250 failed as expected), `bcpack_lanes_*`, `startup_stubs`, `startup_storage_directory_batch`, `bcpack_prefix_and_mip_tail`, `bcpack_rans_symbols`, and `bcpack_tables`.
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!1383
No description provided.