D3D12.X: a buffer released during a placement keeps the new one (#2457) #2518
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2528"
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 xpatfussy69x on 2026-11-25T21:45:54Z.
Part of #2457 (item 2 only; item 1 is claimed on the issue).
place_bufferholds the sparseSTATEacrossCreateReservedResource. A placed buffer whose lastReleaseruns meanwhile cannot takeSTATE, soforget_bufferqueues it inFORGOTTENfor the nextlock_state. When the new reserved resource gets the released one's address,place_bufferrecorded the new buffer under it, and the nextlock_statelet it go: its tiles were unpinned while the buffer was live on the GPU. The new buffer is now recorded byrecord_buffer, which lets the queued buffers go first (the issue's second fix direction).What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:record_buffer(pins the new buffer's tiles and records it, afterforget_released);place_bufferuses itcrates/xcl/src/hle/d3d12x/sparse.rs:a_buffer_released_during_a_placement_does_not_take_the_new_one_with_it: an old buffer at an address is queued as released, a new one is recorded there, thenlock_state's drain runs. Fails without the fix (the new buffer's entry is gone), passes with it.test_state()builds aStateover a D3D12 device (WARP without a GPU) asa_pool_retired_a_moment_ago_is_taken_backdoesTested
cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignoredV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32(onmaintoo; #2182 removes them)cargo test -p xcl --lib d3d12x::sparse: 18 passed, 0 failed, 1 ignoredRegression run
main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T22:10:32Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T22:24:21Z.
Independent AMD RDNA4 (native wave64) test report on exact head
237882e85be2919904333b6b084baee4cc4c4411(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1422 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::sparse::tests::a_buffer_released_during_a_placement_does_not_take_the_new_one_with_it.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T23:07:53Z.
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.Targeted run of
a_buffer_released_during_a_placement_does_not_take_the_new_one_with_it: passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-26T00:18:18Z.
Heads-up for merge order: #2531 renames
State::quarantinedtoretirement. This PR'stest_state()builds aStatewithquarantined: VecDeque::new(). Git merges the two without a textual conflict, but the merged tree's tests do not build:error[E0560]: struct sparse::State has no field named quarantined(sparse.rs:1946, a local merge of6d7f8b9and237882e,cargo test -p xcl --lib --no-run). Whichever lands second needs that one field renamed; I'll rebase this one if #2531 goes first.AI use: Claude Code (Claude Opus 5.5) found this by building the merge.
Imported from ivall/xcl. Originally posted by throny on 2026-11-26T00:58:33Z.
Two contributors checked independently and found that #2539 solves the same problem (for #2457) in a different way: #1607, group D122. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-26T01:17:30Z.
Thanks for the hint. #2539 and this PR fix the same item (2) of #2457 the two ways the issue suggests; this one was opened first (21:45 vs 22:12 UTC).
STATEacrossCreateReservedResourceand only lets the queued releases go (forget_released) before the new buffer is recorded – the smallest change that closes the race.STATEacross the driver call, which needs the window to be checked again afterwards and an abort path when it went away.If not holding the lock across the driver call is wanted for its own sake, #2539 is the more complete fix and I'm happy to close this one in its favour; if the minimal fix is preferred, this one. I'll leave the choice to the maintainer and won't push either way.
AI use: Claude Code (Claude Opus 5.5) compared the two diffs; I checked the comparison.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T04:25:34Z.
NVIDIA test report for
237882e: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4(thehle::xaudio2tests hang on this machine, onmaintoo):hle::d3d12x::sparse::tests::a_buffer_released_during_a_placement_does_not_take_the_new_one_with_itpanicked atsparse.rs:1838:9, "the old buffer's tile is still pinned".--test-threads=1 --nocapture, 3 runs: passes each time.6d12f58, same command: 1289 passed, 0 failed, 26 ignored (it does not have the test).RESinto the globalFORGOTTENand then drains it into its own state, but another test that callslock_state()in parallel can takeFORGOTTENfirst, so the test's state never lets the old buffer go.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T03:31:27Z.
Independent desktop NVIDIA verification of PR #2528 at head
237882e85be2919904333b6b084baee4cc4c4411(1commit; exact parent & merge-base:6d12f58a229bc73889878a448c64dc3af25eeba0, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
237882e8)cargo test --release -p xcl --lib a_buffer_released_during_a_placement_does_not_take_the_new_one_with_it -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1324 filtered out× 3 (0.22s,0.19s,0.19s,0skipped — live D3D12 execution on RTX 4060)cargo test --release -p xcl --lib hle::d3d12x::sparse:: -- --test-threads=1(3 consecutive runs)18 passed; 0 failed; 1 ignored; 1306 filtered out× 3 (1.32s,1.34s,1.32s,0skipped)cargo build --release -p xcl1m 07s, exit0,0new warnings)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
6d12f58a229bc73889878a448c64dc3af25eeba0, cached baseline on the same machine):PR #2528 (
237882e85be2919904333b6b084baee4cc4c4411):Runtime log observations (
xcl.log)9225log lines,0[ERROR]/ device-removal / panic lines.18508 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14006 MB committed by the process; video memory 6116 MB local, 4682 MB non-local.Limits of coverage
a_buffer_released_during_a_placement_does_not_take_the_new_one_with_it(3/3,0skipped) andhle::d3d12x::sparse::(18/0/1× 3).title: 29640639exercises live sparse VRAM allocation (7445 MBsparse) with zero device removals or crashes (frame-count delta vs. cached parent reflects single-run startup variance, not this PR).AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by throny on 2026-11-30T20:18:54Z.
Closing:
a97dbe9bonmain(adapted from #2539, landed with the #2959 stack) creates placed buffers outside the sparse state and clears released ones before recording the new one, which fixes item (2) of #2457 the other way; you had offered to close in favour of #2539. Checked against currentmain(ff0c364b), hunk by hunk. 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) checked this; part of the duplicate sweep on #3041.
Pull request closed