DirectStorage: unpack BCPack requests (BC1, BC3-BC7) instead of refusing them #944

Closed
Yeetbot159 wants to merge 4 commits from upstream-pr/950 into main
Yeetbot159 commented 2026-11-24 09:24:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Yeetbot159 on 2026-11-24T09:24:05Z.


Overlap: #905 covers the same ground (all BCPack modes plus the dstorage.rs wiring, in the same hle/bcpack module). This is an alternative split of the same VIctory code into small stacked PRs, opened as drafts so the two can be compared. If #905 is preferred, please close these.

Stacked on #949; only the top commit belongs here.

Stacked on PR 3; only the top commit belongs here. Open as a draft.

dstorage.rs refused every BCPack request (E_DECOMPRESSION). Now Request::check accepts BC1 and
BC3-BC7, and execute unpacks them after the optional zlib stage, into the destination (a part block
at the end is handled by unpacking whole blocks and keeping the destination size). BC2 and modes 8-15
are still refused, counted and filled as before, so the XCL_DSTORAGE_BCPACK_FILL stopgap and the
report counters keep working for those. Semantics follow VIctory's handling of a retail title:
intermediate_size is the size of the BCPack stream for zlib + BCPack.

Behaviour changes to check: zlib + BCPack with intermediate_size == 0 now returns E_DESTINATION_SIZE
(it was E_DECOMPRESSION; the stream size is not knowable); a bad stream returns E_DECOMPRESSION
and logs once under "BCPack".

What is in it: hle/dstorage.rs (check, execute, tables cache, module docs, tests)
Statements that are now out of date: HANDOFF.md ~line 656 ("BCPack … refused"); not edited, per AGENTS.md.

Tested: not run yet (draft until it is). Author-side: dstorage.rs is Windows-only and was NOT compiled or run; only a
syntax parse was done (no syntax errors). Treat as untested until you have built it.
Regression run: not run yet (draft until it is) (required)
Not tested: the success path through execute (the tests cover the validation matrix and a bad
stream; a valid stream needs real data); AMD / NVIDIA; the retail title.
AI use: Claude (Sonnet 5.5): wrote the change and tests, not compiled.

<!-- greyfinch-sync:ivall/xcl:issue:6578629415 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/950). Originally posted by [Yeetbot159](https://github.com/Yeetbot159) on 2026-11-24T09:24:05Z. --- > **Overlap:** #905 covers the same ground (all BCPack modes plus the `dstorage.rs` wiring, in the same `hle/bcpack` module). This is an alternative split of the same VIctory code into small stacked PRs, opened as drafts so the two can be compared. If #905 is preferred, please close these. Stacked on #949; only the top commit belongs here. Stacked on PR 3; only the top commit belongs here. **Open as a draft.** `dstorage.rs` refused every BCPack request (E_DECOMPRESSION). Now `Request::check` accepts BC1 and BC3-BC7, and `execute` unpacks them after the optional zlib stage, into the destination (a part block at the end is handled by unpacking whole blocks and keeping the destination size). BC2 and modes 8-15 are still refused, counted and filled as before, so the `XCL_DSTORAGE_BCPACK_FILL` stopgap and the report counters keep working for those. Semantics follow VIctory's handling of a retail title: `intermediate_size` is the size of the BCPack stream for zlib + BCPack. Behaviour changes to check: zlib + BCPack with `intermediate_size == 0` now returns E_DESTINATION_SIZE (it was E_DECOMPRESSION; the stream size is not knowable); a bad stream returns E_DECOMPRESSION and logs once under "BCPack". **What is in it:** `hle/dstorage.rs` (check, execute, tables cache, module docs, tests) **Statements that are now out of date:** `HANDOFF.md` ~line 656 ("BCPack … refused"); not edited, per AGENTS.md. **Tested:** **not run yet** (draft until it is). Author-side: `dstorage.rs` is Windows-only and was NOT compiled or run; only a syntax parse was done (no syntax errors). Treat as untested until you have built it. **Regression run:** **not run yet** (draft until it is) (required) **Not tested:** the success path through `execute` (the tests cover the validation matrix and a bad stream; a valid stream needs real data); AMD / NVIDIA; the retail title. **AI use:** Claude (Sonnet 5.5): wrote the change and tests, not compiled.
ettehn commented 2026-11-24 10:04:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-24T09:29:47Z.


BC7 byte-parity issue on 4bada6b (in the decoder this PR wires into DirectStorage). A minimal synthetic input is 1,024 bytes of 0x01, BC7, 16 output bytes: both decoders succeed but XCL differs from the VIctory reference. Across fills 0–63 and output lengths of 1, 4 and 16 blocks, 85 of the 156 accepted BC7 cases differed.

In the BC7 dictionary reader, offsets 52–53 are being consumed as the first signed index. Skipping that u16, reading 31 indices into the flattened 32 slots, and leaving the last slot zero fixed all 85 differences locally. With that change all 1,056 accepted cases across the six supported formats matched byte-for-byte, with 96 jointly rejected. The same table layout is covered in #856 and already used in #905. No retail input required.

Verification assisted by OpenAI Codex (GPT-6.2 Astra).

<!-- greyfinch-sync:ivall/xcl:comment:7127495398 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/950#issuecomment-7127495398). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-24T09:29:47Z. --- BC7 byte-parity issue on `4bada6b` (in the decoder this PR wires into DirectStorage). A minimal synthetic input is 1,024 bytes of `0x01`, BC7, 16 output bytes: both decoders succeed but XCL differs from the VIctory reference. Across fills 0–63 and output lengths of 1, 4 and 16 blocks, 85 of the 156 accepted BC7 cases differed. In the BC7 dictionary reader, offsets 52–53 are being consumed as the first signed index. Skipping that u16, reading 31 indices into the flattened 32 slots, and leaving the last slot zero fixed all 85 differences locally. With that change all 1,056 accepted cases across the six supported formats matched byte-for-byte, with 96 jointly rejected. The same table layout is covered in #856 and already used in #905. No retail input required. Verification assisted by OpenAI Codex (GPT-6.2 Astra).
ettehn commented 2026-11-24 10:04:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-24T09:33:17Z.


One separate build blocker surfaced when moving the BC7 control into the actual DirectStorage request path. At 4bada6b, xcl inherits workspace edition 2021, but bcpack/mod.rs uses two && let Some(...) chains (self.latch.take() and lane.out.take()). Cargo rejects both before the Windows tests run. My earlier standalone codec comparison used edition 2024.

Rewriting those two expressions as nested if/if let preserved short-circuiting and built under the existing workspace edition. With that and the dictionary offset correction, all 15 targeted DirectStorage tests passed on Windows, including a local memory-request test checking the 16 output bytes against the reference and both adjacent sentinel bytes.

Verification assisted by OpenAI Codex (GPT-6.2 Astra).

<!-- greyfinch-sync:ivall/xcl:comment:7127573998 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/950#issuecomment-7127573998). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-24T09:33:17Z. --- One separate build blocker surfaced when moving the BC7 control into the actual DirectStorage request path. At `4bada6b`, `xcl` inherits workspace edition 2021, but `bcpack/mod.rs` uses two `&& let Some(...)` chains (`self.latch.take()` and `lane.out.take()`). Cargo rejects both before the Windows tests run. My earlier standalone codec comparison used edition 2024. Rewriting those two expressions as nested `if`/`if let` preserved short-circuiting and built under the existing workspace edition. With that and the dictionary offset correction, all 15 targeted DirectStorage tests passed on Windows, including a local memory-request test checking the 16 output bytes against the reference and both adjacent sentinel bytes. Verification assisted by OpenAI Codex (GPT-6.2 Astra).
upstream-sync closed this pull request 2026-11-24 11:05:12 +00:00
SlopTart commented 2026-11-24 11:05:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T10:38:04Z.


Compile-blocked in rebuild: this PR merges the same && let chains into crates/xcl/src/hle/bcpack/mod.rs (errors at lines 353/451 after merge onto 9aec53d) while the workspace is edition = "2021", so the lane fails to build before any test runs. Full detail in my comment on #947 (same failure across the whole #947-#950 stack).

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7129041142 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/950#issuecomment-7129041142). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-24T10:38:04Z. --- Compile-blocked in rebuild: this PR merges the same `&& let` chains into `crates/xcl/src/hle/bcpack/mod.rs` (errors at lines 353/451 after merge onto `9aec53d`) while the workspace is `edition = "2021"`, so the lane fails to build before any test runs. Full detail in my comment on #947 (same failure across the whole #947-#950 stack). **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
ivall commented 2026-11-24 11:05:52 +00:00 (Migrated from github.com)

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


#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.

<!-- greyfinch-sync:ivall/xcl:comment:7129079256 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/950#issuecomment-7129079256). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T10:39:48Z. --- #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.

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!944
No description provided.