D3D12.X: a partly read-back sparse chunk is uploaded again #1730
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1740"
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?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T20:06:26Z.
Addresses
XCL-BT-033from #1488.readback_rangescopies a GPU-written range into the CPU view and thensync_sent_rangemarked 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 nextbefore_executeskip 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_rangecalls it; add testa_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 onmainwithleft: [], right: [(0, 64)]— the CPU's write was dropped.Tested
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, andcannot 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 ignoredRegression run
main (
c4d37be, clean tree, no local changes):PR (
294f565, clean tree, no local changes):Not tested
before_executeand a GPU readback of the same cacheline (the test drivesmark_read_backdirectly)AI use
XCL-BT-033againstreadback_ranges/scan_page, wrote the fix and test (and confirmed it fails without the fix), rebased ontoc4d37be, ran the test suite andscripts/smoke.ps1regression runs with #677's title hashing, and drafted this PR description.Imported from ivall/xcl. Originally posted by thatirishguyyy on 2026-11-24T20:21:17Z.
Independent AMD check on Windows, RX 9070 XT. I cherry-picked #1740 head
36371bdontob9b6ea6(local259499b).cargo test -p xcl --release --locked --offline --lib hle::d3d12x::sparse::tests -- --nocapture --test-threads=1returned 15 passed, 0 failed, 1 ignored.a_partly_read_back_chunk_is_uploaded_againpassed. This is a focused suite result.AI-assisted with Codex for setup, execution, and reporting.
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T21:38:30Z.
Rebased onto
c4d37beand re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 960 passed, 0 failed, 43 ignored.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T22:44:05Z.
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 unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:43:03Z.
PR #1740 compatibility verification
Tested head
294f5655c918446b9732858a8e09f13f0ce8fddaon 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, andd3d12SDKLayers.dllunavailable. 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 --workspaceandcargo test --workspace --no-runboth succeeded. Allcargo testinvocations used the shared Arc lock.cargo test -p xcl hle::d3d12x::sparse -- --nocapture --test-threads=1reported 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=4reported 941 passed, 19 failed, 43 ignored over 20 result summaries, with 22 SKIPPED lines. Skip markers are excluded from GPU coverage.Failures and skips
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.RSSetDepthBiasXcheck produced blue where green was expected.Not tested
Paired retail-title smoke runs, other GPUs or drivers, and D3D12 debug-layer behavior. No
maintest 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 againstpr1740-suite.logand published this report.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T10:50:13Z.
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 --workspacepassed.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapturefinished 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_readbackin 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=1passed 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.Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-25T11:52:22Z.
Linux (Wine + vkd3d-proton) + NVIDIA, the title, 100 s runs: the case this fixes did not come up here. In 4 runs of
mainwith a counter added, no read-back range covered a 64-byte chunk in part. In 3 runs with #1740 merged the title ran as onmain: no fault, and the last present within the range of themainruns. The one fault, in amainrun, is the one #751 is for, on a path #1740 does not change.Setup:
294f565and #684 (e56dbc3) merged locally ontomainf087b99(local mergec5c9f58). The counting copy ismainf087b99+ #684 + a counter insync_sent_range(local67e229e; its first run was on local0724148, 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 themainruns 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)msvcrt.dll+0xa52b, a read withtiling::Chain::detile_levelandtitle_textures::subresourceson the stack at 58.7 s (the fault #751 is for), then the title's watchdoggame+0x23cf683at 89.3 smark_read_back(sparse.rs:369) makes. The range counter logs its 1st to 4th and then each power of two: all 11 or 12 ranges it printed per run were 64-byte aligned at both ends (for example0x863a40000+0x4000). So here #1740 would give every chunk its real hash, asmaindoes, and changes nothing on this path.sparse::testsunder Wine: 16 passed, 1 ignored with #1740 (a_partly_read_back_chunk_is_uploaded_againamong them); 15 passed, 1 ignored onmain+ #684.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.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T20:46:18Z.
Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head
294f5655c918446b9732858a8e09f13f0ce8fdda(merged cleanly ontomain6d12f58).Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnu(debug for tests, release for retail)Unit / GPU tests (
XCL_REQUIRE_GPU=wave64,XCL_DXC_DIR,VKD3D_CONFIG=ignore_shared_fence,--test-threads=1 --nocapture)hle::d3d12x::sparse: 18 passed, 0 failed, 1 ignored (0 skipped)Combined retail sanity run (
main6d12f58+#2068,#1771,#1740,#1256merged together;XCL_DIRECT_DXIL=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PSO_WAIT_MS=50,XCL_SPLIT_MIDLIST_WAIT=0,XCL_COHERENT_MB=1024,VKD3D_CONFIG=ignore_shared_fence,XCL_PSO_PRELOAD=0,XCL_NETWORK=0)exit=0) with 0 crashes and 0 device removals (11.55 GiBpeak VRAM / 0 GTT spill,13.35 GiBpeak RSS,1,800+frames presented,16,442translated draws,4,499dispatches,11,257Opus packets).Not tested
AI use
main, ran the tests and combined retail run under Proton on this machine, and drafted this report.Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:13:28Z.
Review: COMMENTED
No concrete defect found. Partial 64-byte readback chunk hashing correctly forces only incompletely read-back chunks to re-upload; range/page calculations look sound. Please add end-to-end readback_ranges coverage for real partial GPU copy, including multi-page partial first/last chunks and full middle pages. Current head lacks visible Windows CI; retain the disclosed CPU-write-between-submit/readback race limitation and provide current evidence.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-26T15:07:36Z.
Suite on RTX 5070 Ti (Windows 11) at
294f5655: 960 passed, 0 failed, 43 ignored; the new test passesTested
294f5655c918446b9732858a8e09f13f0ce8fdda, clean detached worktree, built as is, debug. PR open and head unchanged when I started. Its merge-base withmainisc4d37bec, not the currentmainb49be183, so this is not the tree that would merge.cargo build --workspace: ok.cargo test --workspace --no-fail-fast -- --test-threads=4: 960 passed, 0 failed, 43 ignored. With no failure there was nothing to compare against the base.SKIPPED: 18 "no wave64", 3 wave32 per-lane forms refused (f16 arithmetic, f16 packed, f32 conversions), 1heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).cargo test -p xcl --lib hle::d3d12x::sparse -- --nocapture --test-threads=1: 15 passed, 0 failed, 1 ignored (early_commit_timing).a_partly_read_back_chunk_is_uploaded_againis among the passes.Not tested
main. One machine, one suite run.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:38:44Z.
Triage (#1607) – head
294f565The problem (a partial copy-back hashing unsent CPU bytes in the same 64-byte chunk as sent) is fixed on main differently.
ee3118b("copies back never go over newer CPU writes") lands copy-backs only on chunks the CPU has not written since they were last sent.sync_sent_rangeis now called from just one place, a stored immediate, and only whenchunk_clean(va)holds before the write, so no unsent CPU bytes can be hashed as sent.The branch conflicts with that rewrite of
sparse.rs.Recommendation: close (superseded by main commit
ee3118b).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:47:42Z.
Closing as superseded: this change is already on
main(ee3118b1). mainee3118b1: land_page lands copy-backs chunk by chunk and leaves CPU-changed chunks and hashes alone; sync_sent_range now only runs for immediates on a clean chunkTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed