Skip to content

D3D12.X: a partly read-back sparse chunk is uploaded again - #1740

Open
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/sparse-partial-chunk-readback
Open

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/sparse-partial-chunk-readback

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Addresses XCL-BT-033 from #1488.

readback_ranges copies a GPU-written range into the CPU view and then sync_sent_range marked every 64-byte chunk the range touched as sent, hashing the chunk's whole content. The bytes of such a chunk that the readback did not write may be CPU writes that were never uploaded — hashing them as sent made the next before_execute skip the chunk for good: the GPU never had those bytes, and the CPU's view kept them until a later readback replaced them with the GPU's.

This marks a chunk sent only when the range covers it whole; a partly covered chunk is given a hash it cannot have, so the next submit uploads it (the GPU end gets the CPU's view, which now also holds the read-back bytes).

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs: mark_read_back() does the per-chunk rule; State::sync_sent_range calls it; add test a_partly_read_back_chunk_is_uploaded_again (a 4-byte readback inside a chunk with a 4-byte CPU write: the chunk must be uploaded; a range covering chunks whole must not be; the page's last chunk too). Fails on main with left: [], right: [(0, 64)] — the CPU's write was dropped.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 960 passed, 0 failed, 43 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required)). The one #[ignore]d test in the module (early_commit_timing) is pre-existing.
  • cargo test -p xcl --lib sparse: 18 passed, 0 failed, 1 ignored

Regression run

main (c4d37be, clean tree, no local changes):

xcl-smoke v1
commit: c4d37bec1bb4286eb373aea963404a23f13401fa
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1639 (PresentX 1640)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14618 MB

PR (294f565, clean tree, no local changes):

xcl-smoke v1
commit: 294f5655c918446b9732858a8e09f13f0ce8fdda
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1645 (PresentX 1645)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14620 MB

Not tested

  • a title that writes a sparse window's CPU view between before_execute and a GPU readback of the same cacheline (the test drives mark_read_back directly)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: checked XCL-BT-033 against readback_ranges/scan_page, wrote the fix and test (and confirmed it fails without the fix), rebased onto c4d37be, ran the test suite and scripts/smoke.ps1 regression runs with Scripts: smoke blocks print the game folder's name #677's title hashing, and drafted this PR description.

anoyarou pushed a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
)

readback_ranges copies a GPU-written range into the CPU view and then
sync_sent_range marked every 64-byte chunk the range touched as sent,
hashing the chunk's whole content. The bytes of such a chunk the readback
did not write may be CPU writes that were never uploaded; hashing them as
sent made before_execute skip them for good - the GPU never had them, and
the CPU's view kept them (until the next readback put the GPU's back).

Mark a chunk sent only when the range covers it whole; a partly covered
one gets a hash it cannot have, so the next submit uploads it.

Assisted-by: OpenCode (Gemini 4 Neon)
@thatirishguyyy

Copy link
Copy Markdown

Independent AMD check on Windows, RX 9070 XT. I cherry-picked #1740 head 36371bd onto b9b6ea6 (local 259499b).

cargo test -p xcl --release --locked --offline --lib hle::d3d12x::sparse::tests -- --nocapture --test-threads=1 returned 15 passed, 0 failed, 1 ignored. a_partly_read_back_chunk_is_uploaded_again passed. This is a focused suite result.

AI-assisted with Codex for setup, execution, and reporting.

readback_ranges copies a GPU-written range into the CPU view and then
sync_sent_range marked every 64-byte chunk the range touched as sent,
hashing the chunk's whole content. The bytes of such a chunk the readback
did not write may be CPU writes that were never uploaded; hashing them as
sent made before_execute skip them for good - the GPU never had them, and
the CPU's view kept them (until the next readback put the GPU's back).

Mark a chunk sent only when the range covers it whole; a partly covered
one gets a hash it cannot have, so the next submit uploads it.

Assisted-by: OpenCode (Gemini 4 Neon)
@b3IKK
b3IKK force-pushed the d3d12x/sparse-partial-chunk-readback branch from 36371bd to 294f565 Compare November 24, 2026 21:38
@b3IKK

b3IKK commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto c4d37be and re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 960 passed, 0 failed, 43 ignored.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

PR #1740 compatibility verification

Tested head 294f5655c918446b9732858a8e09f13f0ce8fdda on STOR-WINLAB. The sparse read-back regression passed. The full workspace suite exited 101 with failures in the GPU library tests and the synthetic test title.

Environment
Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. Wave range 8–32, DoublePrecisionFloatShaderOps=0, and d3d12SDKLayers.dll unavailable. Rust 1.100.0 (0ef1bc386), DXC/DXIL 1.9.2609.5, unoptimized profiles with debug info and incremental compilation disabled. The suite log confirms the real Arc A770 backend.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both succeeded. All cargo test invocations used the shared Arc lock.
  • cargo test -p xcl hle::d3d12x::sparse -- --nocapture --test-threads=1 reported 15 passed, 0 failed, 1 ignored, 0 SKIPPED. The new unit test passed in both runs. It checks that a partial GPU read-back leaves the 64-byte chunk queued for one re-upload, including at the page boundary, and that a fully read-back chunk stays clean.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 reported 941 passed, 19 failed, 43 ignored over 20 result summaries, with 22 SKIPPED lines. Skip markers are excluded from GPU coverage.

Failures and skips

  • Library (18 failures) • 14 compute PSO creation errors (0x80070057), including FP64 cases, plus four result mismatches covering fused FMA, implicit sample LOD, the high half of an FP16 lane, and a pixel-shader wave reduction.
  • E2E (1 failure) • The synthetic title's RSSetDepthBiasX check produced blue where green was expected.
  • Skip markers (22) • 17 no wave64, 3 unsupported per-lane forms, 1 driver cache could not be disabled, and 1 no heap windows.

Not tested
Paired retail-title smoke runs, other GPUs or drivers, and D3D12 debug-layer behavior. No main test baseline was collected, so the suite failures establish the observed behavior at this head only.

AI use
T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1740-suite.log and published this report.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@thehollowedone

Copy link
Copy Markdown

Independent Windows run on 294f565. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, debug.

cargo build --offline --locked --workspace passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture finished with 960 passed, 0 failed, 43 ignored and 23 runtime skip notices included in Cargo’s counts.

I extended ensure_mapped_with_query_holes_skips_uncommitted_pages_on_readback in a scratch copy to read back 72 bytes across a page boundary on the native D3D12 adapter. The next scan queued exactly the two partially covered 64-byte chunks for upload and kept the fully covered chunk out of the queue. A second GPU readback matched all 192 bytes, including the CPU writes at both ends. With the old hash update restored, the same scan queued zero chunks and the test failed at that assertion.

cargo test --offline --locked -p xcl --lib ensure_mapped_with_query_holes_skips_uncommitted_pages_on_readback -- --nocapture --test-threads=1 passed 1/0/0 with zero fixture skips. Synthetic test coverage only. AI-assisted. Codex (GPT-6, exact variant unavailable) extended the fixture, ran the tests, and drafted this report.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA, the title, 100 s runs: the case this fixes did not come up here. In 4 runs of main with a counter added, no read-back range covered a 64-byte chunk in part. In 3 runs with #1740 merged the title ran as on main: no fault, and the last present within the range of the main runs. The one fault, in a main run, is the one #751 is for, on a path #1740 does not change.

Setup: 294f565 and #684 (e56dbc3) merged locally onto main f087b99 (local merge c5c9f58). The counting copy is main f087b99 + #684 + a counter in sync_sent_range (local 67e229e; its first run was on local 0724148, which counted only partly covered chunks). RTX 4070 12 GB (615.71.09), Ryzen 9 9950X3D, Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence, release. Series X profile, first-run screens done once, no story progress, A pressed at 16.2 to 16.5 s in the main runs and at 16.4 to 18.5 s with #1740 (--press-a-when-ready), XCL_PSO_PRELOAD=0, WINEDEBUG=err+all,fixme-all. The two trees ran in turn.

main + counter (4 runs) #1740 (3 runs)
ranges read back 1,024 to 2,047 in 2 runs; 512 to 1,023 in the run that faulted; not counted in 1 –
chunks read back in part 0 in 4 runs –
last 2 s with a present 60.1, 82.4, 82.6, 98.2 s 82.7, 84.2, 94.1 s
faults 1 run: msvcrt.dll+0xa52b, a read with tiling::Chain::detile_level and title_textures::subresources on the stack at 58.7 s (the fault #751 is for), then the title's watchdog game+0x23cf683 at 89.3 s 0

Not tested: the rest of the suite; Windows; AMD and Intel; runs past 100 s.

AI use: Claude Code (Claude Opus 5.5) read the change, wrote the counter, ran the title and the tests, and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants