DirectStorage: BCPack BC3, BC4 and BC5 block rebuilds, without their tables, not yet called #336

Closed
NiiRoZz wants to merge 5 commits from upstream-pr/340 into main
NiiRoZz commented 2026-11-23 23:50:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by NiiRoZz on 2026-11-23T23:50:21Z.


Stacked on #273 (itself on #208); only the top three commits belong here: 6fd5a60 (BC4), f58df2f (BC5), e02a003 (BC3).

Adds the block rebuild for the three remaining 12-lane BCPack modes, from #208's lanes and in the form of #273's bc1.rs. Each needs constants that no stream carries: the order of the 64 selector pairs (BC3 also the order of the 256 colour quadrants) and a built-in history of 255 endpoint sets that a stream's first blocks refer back to. XCL has no source for them it can take, so they are a Tables parameter: no table is shipped, nothing calls the new code, and DirectStorage refuses BC3 / BC4 / BC5 requests exactly as on main. It is here so that whoever has the tables only has to supply them.

No overlap found: #273 and #233 cover BC1 only.

What is in it

  • hle/bcpack/bc4.rs, bc5.rs, bc3.rs: lanes to blocks, one commit per mode. A block whose history entry is unknown fails with Error::History and nothing is written.
  • hle/bcpack/mod.rs: the modules and their docs.
  • hle/bcpack/tests.rs, tests/data/bcpack/generate.py, tests/data/bcpack/bc{3,4,5}-*: a synthetic fixture per mode, built with made-up tables by the generator's own per-texel assembly, and a hand-built case per mode that covers every field. The fixtures are 2 to 7 KB each.
  • Size: 518 changed lines, 252 of them the three decoders. It is one PR because the three share the fixture generator and the test scaffold, and none is of use before the others' tables exist either.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.35), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, Rust 1.100.0.
  • cargo test --release -p xcl --lib bcpack: 17 passed. cargo test --release -p xcl --lib dstorage: 13 passed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 665 passed, 0 failed, 40 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • What a retail title's streams say about the missing constants: every BC4 and BC5 chunk of the one checked predicts from the built-in history in its first blocks, so the pair order alone unlocks none of them; 8 of its 35 BC3 chunks never do.

Regression run

scripts/smoke.ps1 -Game <folder> -Seconds 60, release builds, no input (the title stays on its first menu), each run with the machine to itself. The new code is not called by the runtime, so the runs can only show that nothing else moved. The stack sits on #273's base (9ab7d76), so the two builds differ by more than these commits. gpu: is the first video controller Windows lists (#281 / #282 / #285); XCL's log names the RTX 5090 as its backend in both runs.

main:

xcl-smoke v1
commit: 3516080d53daac0f7749b5c02bc9b1e371479557
gpu: AMD Radeon(TM) Graphics
title: retail
seconds: 60
exit: 0x0
frames shown: 1358 (PresentX 1359)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14838 MB

PR:

xcl-smoke v1
commit: e02a0033071233a140dd3dfcb0286a3466e0159d
gpu: AMD Radeon(TM) Graphics
title: retail
seconds: 60
exit: 0x0
frames shown: 1347 (PresentX 1347)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15191 MB

Not tested

  • The tables: XCL has none, so no real stream is rebuilt by this PR.
  • Output against a console's, and any effect on a game: nothing calls the code.
  • Each commit on its own: the suite ran on the head only.

AI use

  • Claude Code with Claude Opus 5.5 wrote the code and the tests, Claude Fable 5.2 this description. The tests and runs above were made on my machine, and I have read the diff.
<!-- greyfinch-sync:ivall/xcl:issue:6571294720 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/340). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-23T23:50:21Z. --- Stacked on #273 (itself on #208); only the top three commits belong here: `6fd5a60` (BC4), `f58df2f` (BC5), `e02a003` (BC3). Adds the block rebuild for the three remaining 12-lane BCPack modes, from #208's lanes and in the form of #273's `bc1.rs`. Each needs constants that no stream carries: the order of the 64 selector pairs (BC3 also the order of the 256 colour quadrants) and a built-in history of 255 endpoint sets that a stream's first blocks refer back to. XCL has no source for them it can take, so they are a `Tables` parameter: no table is shipped, nothing calls the new code, and DirectStorage refuses BC3 / BC4 / BC5 requests exactly as on `main`. It is here so that whoever has the tables only has to supply them. No overlap found: #273 and #233 cover BC1 only. **What is in it** - `hle/bcpack/bc4.rs`, `bc5.rs`, `bc3.rs`: lanes to blocks, one commit per mode. A block whose history entry is unknown fails with `Error::History` and nothing is written. - `hle/bcpack/mod.rs`: the modules and their docs. - `hle/bcpack/tests.rs`, `tests/data/bcpack/generate.py`, `tests/data/bcpack/bc{3,4,5}-*`: a synthetic fixture per mode, built with made-up tables by the generator's own per-texel assembly, and a hand-built case per mode that covers every field. The fixtures are 2 to 7 KB each. - Size: 518 changed lines, 252 of them the three decoders. It is one PR because the three share the fixture generator and the test scaffold, and none is of use before the others' tables exist either. **Tested** - NVIDIA GeForce RTX 5090 (driver 621.35), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, Rust 1.100.0. - `cargo test --release -p xcl --lib bcpack`: 17 passed. `cargo test --release -p xcl --lib dstorage`: 13 passed. - `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): 665 passed, 0 failed, 40 ignored. SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64). - What a retail title's streams say about the missing constants: every BC4 and BC5 chunk of the one checked predicts from the built-in history in its first blocks, so the pair order alone unlocks none of them; 8 of its 35 BC3 chunks never do. **Regression run** `scripts/smoke.ps1 -Game <folder> -Seconds 60`, release builds, no input (the title stays on its first menu), each run with the machine to itself. The new code is not called by the runtime, so the runs can only show that nothing else moved. The stack sits on #273's base (`9ab7d76`), so the two builds differ by more than these commits. `gpu:` is the first video controller Windows lists (#281 / #282 / #285); XCL's log names the RTX 5090 as its backend in both runs. main: ``` xcl-smoke v1 commit: 3516080d53daac0f7749b5c02bc9b1e371479557 gpu: AMD Radeon(TM) Graphics title: retail seconds: 60 exit: 0x0 frames shown: 1358 (PresentX 1359) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14838 MB ``` PR: ``` xcl-smoke v1 commit: e02a0033071233a140dd3dfcb0286a3466e0159d gpu: AMD Radeon(TM) Graphics title: retail seconds: 60 exit: 0x0 frames shown: 1347 (PresentX 1347) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15191 MB ``` **Not tested** - The tables: XCL has none, so no real stream is rebuilt by this PR. - Output against a console's, and any effect on a game: nothing calls the code. - Each commit on its own: the suite ran on the head only. **AI use** - Claude Code with Claude Opus 5.5 wrote the code and the tests, Claude Fable 5.2 this description. The tests and runs above were made on my machine, and I have read the diff.
ivall commented 2026-11-24 07:04:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-24T00:04:07Z.


Thanks - not merged for now: it is stacked on #273 / #208, whose BC1 tables come from bcpack-rs's estimates made from retail data, and that provenance question is still open on the maintainer's side; on its own the new code is not called yet. It stays open until #208 / #273 are decided.

<!-- greyfinch-sync:ivall/xcl:comment:7117667402 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/340#issuecomment-7117667402). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T00:04:07Z. --- Thanks - not merged for now: it is stacked on #273 / #208, whose BC1 tables come from bcpack-rs's estimates made from retail data, and that provenance question is still open on the maintainer's side; on its own the new code is not called yet. It stays open until #208 / #273 are decided.
Kalmarv commented 2026-11-24 07:05:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T02:33:36Z.


@NiiRoZz, a note for your stack: #208 and #273 are rebased onto main 9ce2070, now 42c90e0 and ce8839b (was 34c0ee5 and 5f12643). The commits themselves are unchanged (git range-diff shows = for both), so git rebase --onto ce8839b 5f12643 should move your three commits across.

🤖 Claude Opus 5.5

<!-- greyfinch-sync:ivall/xcl:comment:7120264006 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/340#issuecomment-7120264006). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-24T02:33:36Z. --- @NiiRoZz, a note for your stack: #208 and #273 are rebased onto `main` `9ce2070`, now `42c90e0` and `ce8839b` (was `34c0ee5` and `5f12643`). The commits themselves are unchanged (`git range-diff` shows `=` for both), so `git rebase --onto ce8839b 5f12643` should move your three commits across. 🤖 Claude Opus 5.5
ethandepstein-del commented 2026-11-24 07:06:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-24T05:05:54Z.


Independent NVIDIA RTX 5080 build/test run and code review at head e02a0033071233a140dd3dfcb0286a3466e0159d.

Code Review

  • Clean parameterized BC3/BC4/BC5 block-rebuild scaffolding over caller-supplied Tables (no proprietary tables checked in, not yet wired into live DirectStorage calls). Straightforward extension of #208/#273.

Tested

  • Environment: NVIDIA GeForce RTX 5080 (16 GB, driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09), debug build.
  • Command: cargo build --workspace && cargo test --workspace -- --test-threads=4
  • Result: 665 passed, 0 failed, 40 ignored (0 new warnings).
  • PR-specific tests (14/14 ok):
    • hle::bcpack::tests::bc3_block_rebuild, bc3_fixture_decodes_to_its_blocks
    • hle::bcpack::tests::bc4_block_rebuild, bc4_fixture_decodes_to_its_blocks
    • hle::bcpack::tests::bc5_block_rebuild, bc5_fixture_decodes_to_its_blocks
    • Stacked #208/#273 tests: bc1_block_rebuild, bc1_fixtures_decode_to_their_blocks, fitted_bc1_tables_are_well_formed, fixtures_decode_to_their_lanes, model_matches_the_patent_excerpt, damaged_streams_end_cleanly, random_streams_round_trip_in_every_model, hle::dstorage::tests::bcpack_bc1_requests_are_unpacked_alone_and_after_zlib
    • Plus 3/3 related hle::dstorage::tests::bcpack_* tests.
  • SKIPPED (4):
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64)
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
    • test_title_draws_with_a_root_signature_under_the_debug_layer (no d3d12SDKLayers.dll)
    • uploads_start_from_each_subresources_state (no D3D12 debug layer (0x887A002D))

Not tested

  • D3D12 debug layer, AMD/wave64 hardware, and retail titles / real BCPack assets.

AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7122620990 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/340#issuecomment-7122620990). Originally posted by [ethandepstein-del](https://github.com/ethandepstein-del) on 2026-11-24T05:05:54Z. --- Independent NVIDIA RTX 5080 build/test run and code review at head `e02a0033071233a140dd3dfcb0286a3466e0159d`. ### Code Review - Clean parameterized BC3/BC4/BC5 block-rebuild scaffolding over caller-supplied `Tables` (no proprietary tables checked in, not yet wired into live DirectStorage calls). Straightforward extension of `#208`/`#273`. ### Tested - **Environment:** NVIDIA GeForce RTX 5080 (16 GB, driver `617.42` / `32.0.16.1742`), Windows 11 Pro 25H2 (`26200.9974`), `rustc 1.100.0 (0ef1bc386 2026-11-09)`, debug build. - **Command:** `cargo build --workspace && cargo test --workspace -- --test-threads=4` - **Result:** **665 passed, 0 failed, 40 ignored** (0 new warnings). - **PR-specific tests (14/14 `ok`):** - `hle::bcpack::tests::bc3_block_rebuild`, `bc3_fixture_decodes_to_its_blocks` - `hle::bcpack::tests::bc4_block_rebuild`, `bc4_fixture_decodes_to_its_blocks` - `hle::bcpack::tests::bc5_block_rebuild`, `bc5_fixture_decodes_to_its_blocks` - Stacked `#208`/`#273` tests: `bc1_block_rebuild`, `bc1_fixtures_decode_to_their_blocks`, `fitted_bc1_tables_are_well_formed`, `fixtures_decode_to_their_lanes`, `model_matches_the_patent_excerpt`, `damaged_streams_end_cleanly`, `random_streams_round_trip_in_every_model`, `hle::dstorage::tests::bcpack_bc1_requests_are_unpacked_alone_and_after_zlib` - Plus 3/3 related `hle::dstorage::tests::bcpack_*` tests. - **SKIPPED (4):** - `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` (`no wave64`) - `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` (`no wave64`) - `test_title_draws_with_a_root_signature_under_the_debug_layer` (`no d3d12SDKLayers.dll`) - `uploads_start_from_each_subresources_state` (`no D3D12 debug layer (0x887A002D)`) ### Not tested - D3D12 debug layer, AMD/wave64 hardware, and retail titles / real BCPack assets. **AI use:** Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment.
MesshM commented 2026-11-24 07:06:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:15:58Z.


Test run of e02a0033071233a140dd3dfcb0286a3466e0159d on AMD RDNA4. I merged it onto current main 6025201 locally (clean merge), so the tree tested includes the stack under it (#273, #208).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 718 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 677 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the bcpack tests pass, the BC3 / BC4 / BC5 rebuild ones included.

Review: Only an RDNA4 data point: per the maintainer's note above this stack is not being merged for now, and I reviewed nothing beyond confirming it builds and passes here.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

<!-- greyfinch-sync:ivall/xcl:comment:7122783873 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/340#issuecomment-7122783873). Originally posted by [MesshM](https://github.com/MesshM) on 2026-11-24T05:15:58Z. --- Test run of `e02a0033071233a140dd3dfcb0286a3466e0159d` on AMD RDNA4. I merged it onto current `main` `6025201` locally (clean merge), so the tree tested includes the stack under it (#273, #208). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **718 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 677 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; the `bcpack` tests pass, the BC3 / BC4 / BC5 rebuild ones included. **Review:** Only an RDNA4 data point: per the maintainer's note above this stack is not being merged for now, and I reviewed nothing beyond confirming it builds and passes here. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
upstream-sync closed this pull request 2026-11-24 11:04:41 +00:00
ivall commented 2026-11-24 11:05:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-24T10:39:32Z.


#905 is merged (67a3735): DirectStorage now unpacks BCPack BC1, BC3, BC4, BC5, BC6H and BC7 with the format's exact tables, so this PR is superseded. Thanks – BC3, BC4 and BC5 are decoded there with their tables.

<!-- greyfinch-sync:ivall/xcl:comment:7129073357 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/340#issuecomment-7129073357). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T10:39:32Z. --- #905 is merged (67a3735): DirectStorage now unpacks BCPack BC1, BC3, BC4, BC5, BC6H and BC7 with the format's exact tables, so this PR is superseded. Thanks – BC3, BC4 and BC5 are decoded there with their tables.

Pull request closed

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
xcl-dev/xcl!336
No description provided.