Skip to content

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

Closed
Yeetbot159 wants to merge 4 commits into
xcl-dev:mainfrom
Yeetbot159:dstorage-bcpack-4-wire
Closed

Yeetbot159 wants to merge 4 commits into
xcl-dev:mainfrom
Yeetbot159:dstorage-bcpack-4-wire

Conversation

@Yeetbot159

Copy link
Copy Markdown

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

ettehn commented Nov 24, 2026

Copy link
Copy Markdown

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

ettehn commented Nov 24, 2026

Copy link
Copy Markdown

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

@SlopTart

Copy link
Copy Markdown

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.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@ivall

ivall commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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

@ivall ivall closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants