DirectStorage: XCL_DSTORAGE_BCPACK_DUMP keeps refused BCPack sources #888

Closed
github-bot wants to merge 3 commits from gh-pr/888/head into gh-pr/888/base
Owner

@⁠Koro4e on GitHub · 2026-11-24 07:32 UTC · original
Koro4e:dstorage-bcpack-dump → main · +154 −1 · 1 files · 3 commits · closed without merging

A refused BCPack request's source bytes are the input any BCPack decoder implementation needs, and they were gone once the enqueue failed.

The new XCL_DSTORAGE_BCPACK_DUMP=n keeps the first n refused sources under data_root()/bcpack/ — NNN-modeM.bin plus a .meta line with the request fields (source/destination/intermediate sizes, swizzle, zlib, options). Both source kinds are readable at enqueue time: a memory range as execute reads it, a file through the title's own IDStorageFile.

Measured on the retail title 1.0.2.1 (Series X): a world load refuses 2048+ BCPack requests (BC1 1761, BC5 108, BC6H 1, BC7 178 in one run — 102 MB of texture data the title never receives). With the dump set to 200 the kept chunks decode past the rANS entropy layer with the community clean-room decoders (bcpack-rs, bcpack-decoder), which is where the block-layer work is.

Tested

  • cargo test -p xcl --lib -- --test-threads=1: 674 passed, 0 failed (the new test included).
  • The dump was exercised on a real Series X world load: 200 kept BC7 chunks (destination 65536 = 4096 blocks each, sources 49–64 KB) + .meta lines, all consumed past the entropy layer by the external clean-room decoders.

Not tested

  • The decoder itself: XCL still refuses BCPack requests; the dump only records their sources. Whether a future decoder consumes the dumps losslessly is out of scope here.
  • Requests whose source is neither readable memory nor one of the queue's own files: the dump skips them with a log line, and no kept-chunk run hit that path.
  • Series S: the dumps were taken in anaconda mode only.

Regression run

xcl-smoke v1

commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2

gpu: NVIDIA GeForce RTX 3060

title: 776581ed

seconds: 60

exit: 0x0

frames shown: 1613 (PresentX 1613)

presents per 2 s (last 3): 60 60 60

device removals: 0

crashes: 0

peak commit: 15300 MB
xcl-smoke v1

commit: b559b013bf076d32023b023eda19d9211b556d78

gpu: NVIDIA GeForce RTX 3060

title: 776581ed

seconds: 60

exit: 0x0

frames shown: 1643 (PresentX 1643)

presents per 2 s (last 3): 60 60 59

device removals: 0

crashes: 0

peak commit: 15211 MB

AI use
Written with an AI agent (free-pi); the author reviewed and ran it (cargo test -p xcl --lib, 674 passed).

**@⁠Koro4e** on GitHub · 2026-11-24 07:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/888) `Koro4e:dstorage-bcpack-dump` → `main` · +154 −1 · 1 files · 3 commits · closed without merging A refused BCPack request's source bytes are the input any BCPack decoder implementation needs, and they were gone once the enqueue failed. The new `XCL_DSTORAGE_BCPACK_DUMP=n` keeps the first `n` refused sources under `data_root()/bcpack/` — `NNN-modeM.bin` plus a `.meta` line with the request fields (source/destination/intermediate sizes, swizzle, zlib, options). Both source kinds are readable at enqueue time: a memory range as `execute` reads it, a file through the title's own `IDStorageFile`. Measured on the retail title 1.0.2.1 (Series X): a world load refuses 2048+ BCPack requests (BC1 1761, BC5 108, BC6H 1, BC7 178 in one run — 102 MB of texture data the title never receives). With the dump set to 200 the kept chunks decode past the rANS entropy layer with the community clean-room decoders ([bcpack-rs](https://github.com/Ahmet-Dedeler/bcpack-rs), [bcpack-decoder](https://github.com/Tim0219800/bcpack-decoder)), which is where the block-layer work is. **Tested** - `cargo test -p xcl --lib -- --test-threads=1`: 674 passed, 0 failed (the new test included). - The dump was exercised on a real Series X world load: 200 kept BC7 chunks (destination 65536 = 4096 blocks each, sources 49–64 KB) + `.meta` lines, all consumed past the entropy layer by the external clean-room decoders. **Not tested** - The decoder itself: XCL still refuses BCPack requests; the dump only records their sources. Whether a future decoder consumes the dumps losslessly is out of scope here. - Requests whose source is neither readable memory nor one of the queue's own files: the dump skips them with a log line, and no kept-chunk run hit that path. - Series S: the dumps were taken in `anaconda` mode only. **Regression run** ``` xcl-smoke v1 commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2 gpu: NVIDIA GeForce RTX 3060 title: 776581ed seconds: 60 exit: 0x0 frames shown: 1613 (PresentX 1613) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15300 MB ``` ``` xcl-smoke v1 commit: b559b013bf076d32023b023eda19d9211b556d78 gpu: NVIDIA GeForce RTX 3060 title: 776581ed seconds: 60 exit: 0x0 frames shown: 1643 (PresentX 1643) presents per 2 s (last 3): 60 60 59 device removals: 0 crashes: 0 peak commit: 15211 MB ``` **AI use** Written with an AI agent (free-pi); the author reviewed and ran it (`cargo test -p xcl --lib`, 674 passed).
A refused BCPack request's source bytes are the input any BCPack decoder
implementation needs, and they were gone once the enqueue failed. The new
XCL_DSTORAGE_BCPACK_DUMP=n keeps the first n refused sources under
data_root()/bcpack/ (NNN-modeM.bin plus a .meta line with the request
fields), reading both source kinds at enqueue time: a memory range as
execute does, a file through the title's own IDStorageFile.

Measured on GTA VI 1.0.2.1 (Series X): a world load refuses 2048+ BCPack
requests (BC1 1761, BC5 108, BC6H 1, BC7 178 in one run); with the dump
set to 200 the kept chunks decode past the rANS entropy layer with the
community clean-room decoders, which is where the block-layer work is.

AI use: written with an AI agent (free-pi); the author reviewed and ran
it (cargo test -p xcl --lib, 674 passed).
The bytes and their .meta now go to temporary names, the bytes are renamed into place, and the description follows them. A failure clears the temporaries and the slot, so a decoder never reads a .meta that describes bytes which are not there: a .bin held open without sharing kept its old 16 bytes while the .meta had already been replaced with source_size 64, and the log claimed the request was kept.

Assisted-by: DeepAI Code
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:35:43 +00:00
github-bot closed this pull request 2026-11-26 04:35:43 +00:00
Author
Owner

@⁠ettehn on GitHub · 2026-11-24 07:54 UTC · original

Reproduced a mismatched capture pair on native Windows at e1a9072. The request counter restarts at 1 in each process. In a private temp root I seeded 001-mode1.bin and its .meta with a 16-byte synthetic capture, held the .bin open without write sharing, and submitted a new 64-byte synthetic BC1 source. The helper logged “request 1 kept (64 bytes, mode 1)”. The .bin still held the old 16 bytes, but .meta had been replaced with source_size 64. A decoder using that pair would be testing the wrong input.

Checking the .bin write result and returning on error preserved the previous pair in this test (Windows error 32); checking the .meta write before logging success also keeps that failure visible. The original successful-dump test still passed with these local changes. This handles the reproduced failure; if both files must stay paired across repeated runs and partial writes, a fresh per-run directory and publishing metadata last would also avoid reusing old names. Synthetic inputs only.

OpenAI Codex (GPT-6.2 Astra) assisted with verification.

**@⁠ettehn** on GitHub · 2026-11-24 07:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/888#issuecomment-7125511248) Reproduced a mismatched capture pair on native Windows at e1a9072. The request counter restarts at 1 in each process. In a private temp root I seeded 001-mode1.bin and its .meta with a 16-byte synthetic capture, held the .bin open without write sharing, and submitted a new 64-byte synthetic BC1 source. The helper logged “request 1 kept (64 bytes, mode 1)”. The .bin still held the old 16 bytes, but .meta had been replaced with source_size 64. A decoder using that pair would be testing the wrong input. Checking the .bin write result and returning on error preserved the previous pair in this test (Windows error 32); checking the .meta write before logging success also keeps that failure visible. The original successful-dump test still passed with these local changes. This handles the reproduced failure; if both files must stay paired across repeated runs and partial writes, a fresh per-run directory and publishing metadata last would also avoid reusing old names. Synthetic inputs only. OpenAI Codex (GPT-6.2 Astra) assisted with verification.
Author
Owner

@⁠Koro4e on GitHub · 2026-11-24 09:25 UTC · original

Fixed, and the repro is a test now — pushed as 09c6a47.

The pair is written as one unit or not at all: dump_pair writes <stem>.bin.tmp and <stem>.meta.tmp, renames the bytes into place, and renames the description only after them. If any step fails it removes both temporaries and the slot's .bin/.meta, and the log says not kept (<err>); no pair left behind instead of claiming kept.

bcpack_dump_failure_leaves_no_meta_that_describes_missing_bytes is exactly your scenario: it seeds 001-mode1.bin with 16 bytes and a .meta, opens the .bin with share_mode(0), submits a 64-byte source, and asserts the bytes are untouched and no .meta remains (no temporaries either). It fails against b559b01 — the meta was replaced while the bin kept its 16 bytes — and passes now.

Library suite on this box: 671 passed, 3 failed. The three are the known GPU VRAM cascade (d3d12x::title_textures twice, d3d12x::vram::d32s8), unrelated to this change; they also fail on the branch without the fix.

**@⁠Koro4e** on GitHub · 2026-11-24 09:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/888#issuecomment-7127389052) Fixed, and the repro is a test now — pushed as 09c6a47. The pair is written as one unit or not at all: `dump_pair` writes `<stem>.bin.tmp` and `<stem>.meta.tmp`, renames the bytes into place, and renames the description only after them. If any step fails it removes both temporaries and the slot's `.bin`/`.meta`, and the log says `not kept (<err>); no pair left behind` instead of claiming `kept`. `bcpack_dump_failure_leaves_no_meta_that_describes_missing_bytes` is exactly your scenario: it seeds `001-mode1.bin` with 16 bytes and a `.meta`, opens the `.bin` with `share_mode(0)`, submits a 64-byte source, and asserts the bytes are untouched and no `.meta` remains (no temporaries either). It fails against b559b01 — the meta was replaced while the bin kept its 16 bytes — and passes now. Library suite on this box: 671 passed, 3 failed. The three are the known GPU VRAM cascade (`d3d12x::title_textures` twice, `d3d12x::vram::d32s8`), unrelated to this change; they also fail on the branch without the fix.
Author
Owner

@⁠Diskuss on GitHub · 2026-11-24 09:29 UTC · original

Tested on AMD Radeon RX 9070 XT (RDNA4) at 09c6a47190540f8a130acafcc29f7d1a4b6d84d1

Ryzen 7 5700X3D, 32 GB RAM, Windows 11 Pro build 26300.9974, driver 32.0.32015.7029, Rust 1.100.0 (0ef1bc386) msvc, DXC 1.9.2602.17, debug build.

So far this PR has only been tested on an RTX 3060. These are CPU-side unit tests, so the GPU model matters little. This adds an AMD / Windows 11 26300 full-suite run.

Tested (PR head 09c6a47 merged locally with main 077ce40; the branch was 9 commits behind main, merge was clean, nothing pushed):

  • cargo build --workspace: OK.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored. The 3 failures are the known #718 flake (placed_title_textures_share_vram_and_preserve_pixels plus 2 PoisonError knock-ons: transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory).
  • cargo test -p xcl --lib bcpack_dump -- --test-threads=1: 2 passed, 0 failed (bcpack_dump_failure_leaves_no_meta_that_describes_missing_bytes, bcpack_dump_keeps_the_source_bytes_and_meta_of_refused_requests).
  • SKIPPED: 0. Device removal (DXGI_ERROR_DEVICE_REMOVED): none.
  • Versus main (713 / 3 / 41): +2 passed, matching the 2 new tests; failed and ignored are unchanged.

Not tested: retail title / scripts/smoke.ps1 (no game files), release build.

Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.

Correction (hidden skips): "SKIPPED 0" above means no SKIPPED line appeared in the normal run. A -- --nocapture run on this machine shows that two tests skip silently, because the D3D12 debug layer is not installed (no Graphics Tools / d3d12SDKLayers.dll): e2e::test_title_draws_with_a_root_signature_under_the_debug_layer and texture_states::uploads_start_from_each_subresources_state. Neither is related to this change.

**@⁠Diskuss** on GitHub · 2026-11-24 09:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/888#issuecomment-7127476457) **Tested on AMD Radeon RX 9070 XT (RDNA4) at `09c6a47190540f8a130acafcc29f7d1a4b6d84d1`** Ryzen 7 5700X3D, 32 GB RAM, Windows 11 Pro build 26300.9974, driver 32.0.32015.7029, Rust 1.100.0 (0ef1bc386) msvc, DXC 1.9.2602.17, debug build. So far this PR has only been tested on an RTX 3060. These are CPU-side unit tests, so the GPU model matters little. This adds an AMD / Windows 11 26300 full-suite run. **Tested** (PR head 09c6a47 merged locally with main 077ce40; the branch was 9 commits behind main, merge was clean, nothing pushed): - `cargo build --workspace`: OK. - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 715 passed, 3 failed, 41 ignored. The 3 failures are the known #718 flake (`placed_title_textures_share_vram_and_preserve_pixels` plus 2 PoisonError knock-ons: `transitions_apply_when_their_list_is_submitted`, `d32s8_targets_take_their_own_size_of_video_memory`). - `cargo test -p xcl --lib bcpack_dump -- --test-threads=1`: 2 passed, 0 failed (`bcpack_dump_failure_leaves_no_meta_that_describes_missing_bytes`, `bcpack_dump_keeps_the_source_bytes_and_meta_of_refused_requests`). - SKIPPED: 0. Device removal (DXGI_ERROR_DEVICE_REMOVED): none. - Versus main (713 / 3 / 41): +2 passed, matching the 2 new tests; failed and ignored are unchanged. **Not tested**: retail title / `scripts/smoke.ps1` (no game files), release build. Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine. **Correction (hidden skips):** "SKIPPED 0" above means no `SKIPPED` line appeared in the normal run. A `-- --nocapture` run on this machine shows that two tests skip silently, because the D3D12 debug layer is not installed (no Graphics Tools / `d3d12SDKLayers.dll`): `e2e::test_title_draws_with_a_root_signature_under_the_debug_layer` and `texture_states::uploads_start_from_each_subresources_state`. Neither is related to this change.
Author
Owner

@⁠Koro4e on GitHub · 2026-11-24 09:31 UTC · original

Withdrawing this PR for now. The pair-atomicity fix for the repro above stays on the branch (09c6a47), so it can come back rebased once the block-layer work it feeds is ready.

**@⁠Koro4e** on GitHub · 2026-11-24 09:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/888#issuecomment-7127535866) Withdrawing this PR for now. The pair-atomicity fix for the repro above stays on the branch (`09c6a47`), so it can come back rebased once the block-layer work it feeds is ready.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 09:34 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head b559b01 onto main 077ce40, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 707 passed, 10 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). BCPack dump-keep tests green.

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.

**@⁠SlopTart** on GitHub · 2026-11-24 09:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/888#issuecomment-7127594245) Linux / AMD RDNA3 datapoint. **Merged state:** head `b559b01` onto main `077ce40`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **707 passed, 10 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). BCPack dump-keep tests green. **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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.