D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock #968
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!968
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/968/head"
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?
@imnicho on GitHub · 2026-11-24 09:39 UTC · original
imnicho:late-release-sparse-queue→main· +29 −2 · 1 files · 1 commits · merged 2026-11-24 15:56 UTCWith
XCL_DRED=1a retail title stands still a few seconds after it starts – two reports of that in #675 ("stalls the title at ~9 s", "stalls at startup here too (3 of 3)") – so nobody gets the breadcrumbs of the device removal that issue is about. It is two threads waiting for each other, and there are two ways into it. #789 closes one; this closes the other. Part of #675.From thread dumps here (frames of XCL symbolised from the build's PDB):
q_execute_command_lists→title_textures::refresh→sparse::before_execute→State::upload_dirty→State::begin_slot→ID3D12CommandAllocator::Reset, waiting for a lock inside D3D12Core – with the sparse state's mutex held;Resetof a command list: inside D3D12Core, which makes a resource's lastReleasethere → XCL's release hook, which waits for the sparse state's mutex:main, insparse::forget_buffer– #789's path;late_release::hold→drain_known→sparse::queue(), which took the mutex only to clone the queue – this PR.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs: the state's queue is kept a second time outsideSTATE(QUEUE), set when the state is made or replaced, andqueue()answers from there. Testthe_queue_is_answered_while_the_state_is_locked(onmainit fails after its 5 s: "queue() waited for the sparse state's lock").Tested
stable-x86_64-pc-windows-msvc; debug for the tests, release for the title.cargo build --workspace && cargo test --workspace -- --test-threads=4on9beaa73: 717 passed, 0 failed, 41 ignored (SKIPPED GPU tests:gpu_wave32_program_in_wave64_hardware,gpu_geometry_wave32_prefix_count_over_a_mask– no wave64).XCL_NETWORK=0,XCL_DRED=1, no input (its first screens), 45 s runs, four builds in turn, 3 rounds, release. Frames shown in the run, and the time of the last line of the 2 s activity log (it stands still with the title):main(077ce40)main+ #789 (bc82410)main+ this PRmain+ #789 + this PR(The same
mainwithout the variable, one run before these that also filled the DXIL cache: 874 frames.)XCL_DRED=1go on here: onmainthe first path is met first, with #789 the second. With both the title runs.XCL_DRED=1went on to the device removal of #675 at 168 s and its breadcrumbs were logged: 40 unfinished list entries, 39 of them not begun and one at its 12th operation of 20, anExecuteIndirect(breadcrumb op 5) between barriers and dispatches. I will put that on #675.Regression run (default settings, no
XCL_DRED)main:
PR:
A second round: 1375 frames (
main), 1362 (PR).mainhas moved on to6bac4b4since these ran (#923, #849); the branch merges into it without conflicts.Not tested
holdand the drain still call D3D12 (Signal,GetCompletedValue) from inside the release hook; none showed in the runs above.XCL_DRED: the same two threads can meet whenever D3D12 makes a resource's lastReleaseinside a call of its own, but I have not seen that stall without the variable.AI use
Duplicate check (Gate A 09:07 UTC on
main077ce40, Gate B 09:38 UTC on6bac4b4): no open PR changes howlate_releasegets the sparse queue; read #789 (the other path,forget_buffer; it does not touchqueue()– checked by running it), #461, #433, #236, #496, #532, #923, #930 (other parts ofsparse.rs), and issue #344 (closed: the same mutex, at state replacement).🤖 Generated with Claude Code
@oni-swr on GitHub · 2026-11-24 10:23 UTC · original
Test report for #968 at
9beaa73on AMD (the description has an NVIDIA run only).Tested
stable-x86_64-pc-windows-msvc, debug.cargo build --workspace && cargo test --workspace -- --test-threads=4, each tree in its own target directory:main02bfd1d: 727 passed, 0 failed, 41 ignored, 0 SKIPPED.main02bfd1d+9beaa73(merges cleanly): 728 passed, 0 failed, 41 ignored, 0 SKIPPED. The one extra isthe_queue_is_answered_while_the_state_is_locked.STATEis only ever set ininit, which setsQUEUEjust before it, soqueue()cannot outlive or lag the state it mirrors.Not tested
XCL_DRED=1runs, a smoke pair.AI use: Claude Code (Claude Opus 5.5) ran the suites and read the diff; I checked the report.
@SlopTart on GitHub · 2026-11-24 10:38 UTC · original
Linux / AMD RDNA3 datapoint.
Merged state: head
9beaa73onto main9aec53d, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 718 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. late-release drain + sparse queue tests green; this rig is exactly the "can only see it at Wine scale" case and the leak did not bite in-lane.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.
@raylitebull on GitHub · 2026-11-24 10:39 UTC · original
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (
Build and test+PR description). Moving the sparse queue acquisition outsidesparse::STATEinlate_releasedrain cleanly fixes that part of the #675 deadlock. Recommend merging, @ivall.@DavidM1911 on GitHub · 2026-11-24 12:23 UTC · original
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
cargo test -p xcl --lib sparse: 17 passed, 0 failed, 1 ignored — includes the newthe_queue_is_answered_while_the_state_is_locked, and the GPU testgpu_sparse_vram_descriptors_buffers_and_xmempassed on this run.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@thehollowedone on GitHub · 2026-11-24 13:56 UTC · original
Independent native GPU queue check on
9beaa73applied cleanly to930e8b4in a scratch checkout. Windows 11 build 26300, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug.I initialized the real sparse state, held its mutex, and asked a second thread to look up the queue and signal a native fence. It returned the correct queue and the fence completed while the mutex was still held. I repeated the check after replacing the sparse state and got the new queue, with its fence also completing. On unmodified
930e8b4, the same fixture timed out on its first lookup while the mutex remained held.This checks the queue lookup implicated in the DRED hang. No retail or DRED-enabled run. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.
@deepdev237 on GitHub · 2026-11-24 14:45 UTC · original
Retail DRED run with #968 and #789 on AMD RDNA4
Tested
32.0.32015.7029), Ryzen 9 5950X, Windows 11 build 26300, Rust 1.100.0 MSVC, release.9beaa733fbead2d7909d22d36d59f6dc9e16dc64and #789bc82410abd9ccad26987ed86ec82f4194e06a888together to a local diagnostic stack based on47efa2ecea0a12934719ae69b81930cf02a4b1c3(resulting Git treef4890332e2b99b49ef23de068079e86e2b4cfbef).cargo test --offline --locked --release -p xcl --lib hle::d3d12x::sparse::tests -- --nocapture --test-threads=1: 14 passed, 0 failed, 1 ignored, zero GPU skips. This includedthe_queue_is_answered_while_the_state_is_locked.xcl.exe run "<retail-title>"withXCL_DRED=1,XCL_NETWORK=0, a matched DXIL cache seed and scripted A starting at 44 s. The local control without either patch stalled around 7.4 s. With both patches the run reached story loading and presented through 202.354 s. At 204.029 s,DXGI_ERROR_DEVICE_HUNGproduced seven DRED breadcrumbs. The started, unfinished list had 11 of 17 operations complete, withEXECUTEINDIRECTnext and page-fault VA0x0.Not tested — The retail effect of #968 in isolation, a clean upstream-main comparison, or rendered gameplay.
AI use — OpenAI Codex (
gpt-6.2-sol) ran the tests, checked the local receipts and wrote this report.@crosettiremi on GitHub · 2026-11-24 15:24 UTC · original
Windows 11, RX 7900 XT (RDNA3), driver 32.0.32029.2010. I tested main
930e8b4and the pair #789bc82410+ #9689beaa73. Both builds had the same local file-based controller script, Series X profile, starting application caches, offline mode, DRED enabled and a 28 GiB whole-job limit.On main the activity log stopped at 13.027 s after two presents in total. No frame dump reached the account prompt. Two local process snapshots taken over a minute apart gave identical stack-scan results for the activity thread waiting on sparse::STATE, a resource release in sparse::forget_buffer, and an upload in State::begin_slot / ID3D12CommandAllocator::Reset. Background pipeline workers continued running. I ended this diagnostic run manually.
With the pair applied, the Player1 prompt rendered. The scripted A press was observed at 33.034 s. The title passed the splash, showed loading artwork, and streamed world assets. At 96.5 s the process had 28,129 MB committed and 8,351 MB in target pages. It subsequently exited 0xc0000409 with zero device removals. The sparse suite passed 16 tests with one ignored, including the lock-held queue lookup and resource-release tests.
This corroborates the startup improvement on another AMD generation. The later world-loading exit is separate. I did not run the two patches individually in this title comparison.
@DavidM1911 on GitHub · 2026-11-26 03:23 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin