DirectStorage: bound BCPack record scratch memory #1078
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1078
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1078"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TG0000 on GitHub · 2026-11-24 11:22 UTC · original
TG0000:perf/bcpack-stream-records→main· +252 −96 · 1 files · 2 commits · openBCPack now reconstructs tiles from batches of at most 64 records. The decoder used to keep all intermediate records until the input was consumed. The bounded buffer is 2 KiB on the stack and the existing reconstruction history stays on the heap.
What is in it
crates/xcl/src/hle/bcpack/victory.rskeeps lane read-ahead across batches, handles zero symbols directly, and retains the error precedence for malformed streams. Regression tests check exact bytes for all six widths, batch boundaries, and invalid input.28760f3), same file:batch_boundaries_match_the_previous_decoderand the// shortcut:note, which still applies toRecordStream::fill_batch, back.Tested
cargo test --release --locked --workspace --no-fail-fast -- --test-threads=4 --show-outputreported 741 passed, 3 failed, and 41 ignored. All three new tests passed. Two tests reported GPU skips because the D3D12 debug layer was unavailable.decoded_blocks_match_the_previous_decoder(128 bytes of each format) and the test below.28760f3):cargo test -p xcl --lib hle::bcpack: 10 passed, 0 failed.batch_boundaries_match_the_previous_decodercompares FNV-1a hashes ofbc1-700-2(63, 64, 65, 127, 128 and 129 blocks, and 700 blocks hashed per batch of 64) and ofbc1-8192-3with the output ofmain(47efa2e) for the same fixtures. They are synthetic (tests/data/bcpack/generate.py), no game data. It fails when the first record of each full batch is skipped, when the last one is dropped and when the last one is repeated (three builds); the constant-databatch_boundaries_preserve_lane_read_aheadpasses with the repeat.cargo clippy -p xcl --lib --tests: no warning on the changed lines. Not covered byte for byte past block 64: the formats with two symbols per block, because the only fixture over 64 blocks for them,bc7-700-2, has block errors; their lane stage is checked byfixtures_decode_to_their_lanes. Same machine as above.8cb6ba1) the 45-second RX 6800 smoke comparison showed 954 frames on main and 922 and 1027 on head. The selected runs exited cleanly with zero crashes and device removals.Regression run
On the head
28760f3and on main47efa2e(its merge base): one release build and one run each, from clean trees at those commits, the same title and 45 s. Other builds and tests ran on the PC during both runs, so the frame counts are not a timing comparison. Head: 1034 frames, main: 1027; peak commit 15131 MB against 15264 MB; no device removal and no crash.main:
PR:
Earlier runs, on
8cb6ba1(before the review follow-up), main then PR:Not tested
Gameplay FPS, retail BCPack throughput, NVIDIA GPUs, and Wine.
AI use
Codex with GPT 6.2 Sol implemented the patch, added the tests, ran validation, and drafted this description. Claude Code with Claude Sonnet 5.5 wrote the review follow-up commit (the boundary test and the restored note) and updated this description for it.
@pvfreis on GitHub · 2026-11-24 14:06 UTC · original
Follow-up at
28760f3. I read the diff only; nothing was built or run here.batch_boundaries_match_the_previous_decoder(victory.rs:1122-1156) checksbc1-700-2at 63-65 and 127-129 blocks, each batch of 64 over 700 blocks, andbc1-8192-3, so a record dropped or repeated at a batch end now fails it. I did not recompute the hashes. The 64-block hash and the first per-batch hash of the 700-block decode are the same value, as they should be. The two-symbol formats past block 64 are still not covered byte for byte, and the description now says so.main's run is named as library-only, and the benchmark as outside the diff.// shortcut:note is back abovefill_batch(victory.rs:293-296). The symbol-lookup change stays in the first commit, as you chose.PR checksnow fails at28760f3because the Regression run block names8cb6ba1, and the check wants anxcl-smokeblock made on28760f3.CIshowsaction_requiredat this head, so it has not run yet.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@fromthemoonx on GitHub · 2026-11-24 12:16 UTC · original · edited 2026-11-24 14:18 UTC
Rerun on the new head
28760f362331607e9103ee5f2f0e35ef24754c8e(same machine, debug; the follow-up addsbatch_boundaries_match_the_previous_decoderonly):cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 745 passed, 0 failed, 41 ignoredmain930e8b4(no conflict): 755 passed, 0 failed, 41 ignoredfill_batchstarting each batch atpos = 1(the first record of every batch skipped),batch_boundaries_match_the_previous_decoderfails, and so do three older tests (fixtures_decode_to_their_lanes,decoded_blocks_match_the_previous_decoder,truncated_lane_stream_takes_precedence_over_invalid_block). I did not try the dropped and repeated last record.hle::bcpack+hle::dstoragetests, 10 runs: 10 of 10 passed (24 each)The first run, on
8cb6ba1, follows unchanged.NVIDIA run, since Not tested lists NVIDIA. The change is CPU-side; this machine also has the D3D12 debug layer, so the two GPU tests your run skipped ran here.
Tested
stable-x86_64-pc-windows-msvc; DXC 1.9.2602.178cb6ba1a508a504a5fb23166db037f8d9ee32ed1, which is on currentmain47efa2e(so also the merged result):cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 744 passed, 0 failed, 41 ignoredcargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4: 744 passed, 0 failed, 41 ignoredplaced_title_textures_share_vram_and_preserve_pixelsand the two on its lock) pass here, andtest_title_draws_with_a_root_signature_under_the_debug_layeranduploads_start_from_each_subresources_stateranstreaming_tests::decoded_blocks_match_the_previous_decoder,batch_boundaries_preserve_lane_read_ahead,truncated_lane_stream_takes_precedence_over_invalid_blockhle::bcpack+hle::dstoragetests (the BCPack fixtures, junk / truncated streams, and the DirectStorage BCPack paths), 10 runs: 10 of 10 passed (23 tests each)gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwarexcl_testtitle.exe), also hadlist_x::tests::cross_queue_cycle_and_same_queue_fifo_do_not_deadlockfail once withE_OUTOFMEMORYwhile the machine was busy compiling. The clean rerun above passed it, and it doesn't touch BCPack.Not tested
AI use
@Royalflamejlh on GitHub · 2026-11-24 15:17 UTC · original
Linux (Wine + vkd3d-proton) + NVIDIA check: the tests of the current head
28760f3pass under Wine, and in one 100 s run of a retail title with8cb6ba1, the head before it, every BCPack request still unpacked (2,442 requests, 0 failed), as onmainin the run beside it (2,379, 0 failed).Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch. RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to
x86_64-pc-windows-gnu(rustc 1.98.0),XCL_NETWORK=0,XCL_PSO_PRELOAD=0. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s throughXCL_PRESS_AT. Each head merged ontomain67a3735+ #684 (e56dbc3) without conflicts; 1 run of the base and 1 of8cb6ba1.28760f3adds a test and a comment to8cb6ba1and no decoder code, so I did not repeat the run.Tested
cargo test --release -p xcl --lib bcpackunder Wine, with28760f3merged: 14 passed, 0 failed,batch_boundaries_match_the_previous_decoderamong them (13 of 13 on8cb6ba1).bcpack_unpackedinreport.json67a3735+ #6848cb6ba1The request counts differ by a few percent between any two runs here, because a run is cut at 100 s while the world is still loading; I did not compare the unpacked bytes of the two builds.
Not tested: the decoder's memory use or speed, which is what this change is for; whether the textures look the same (no run of ours reaches a frame of the world); the rest of the test suite; AMD and Intel.
AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the tests and the two runs and wrote this note.
@TG0000 on GitHub · 2026-11-24 13:58 UTC · original · edited 2026-11-24 16:45 UTC
Thank you for the careful review. I checked each point against the code.
Pushed
28760f3on top of8cb6ba1(no force push):batch_boundaries_match_the_previous_decoderhashes the output ofbc1-700-2at 63, 64, 65, 127, 128 and 129 blocks (and at 700 blocks, per batch of 64) and ofbc1-8192-3, against whatmain(47efa2e) decodes from the same fixtures. They are synthetic (made bygenerate.py), no game data. It fails when the first record of a full batch is skipped, when the last one is dropped, and when the last one is repeated; the constant-data test still passes with the repeat. Formats with two symbols per block are not covered byte for byte past block 64, becausebc7-700-2has block errors; the description says so.mainwas the library tests only, not the same command as on the head, and that the byte-identity benchmark is not in the diff.// shortcut:note is back onRecordStream::fill_batch, where it still applies. I left the symbol lookup change in this PR rather than rewrite history.Tested:
cargo test -p xcl --lib hle::bcpack: 10 passed, 0 failed.cargo clippy -p xcl --lib --tests: no warning on the changed lines. Update:xcl-smokeblocks for the new head28760f3and for main47efa2eare now in the description (1034 and 1027 frames, no device removal or crash; other work ran on the PC, so not a timing comparison).AI-assisted: this follow-up was written and tested by Claude Code with Claude Sonnet 5.5.
@DavidM1911 on GitHub · 2026-11-25 08:51 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.