Repository navigation
D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock - #968
Conversation
…rse state's lock A resource's last Release goes to late_release::hold, whose drain asks sparse::queue() for the tile-mapping queue, and queue() took the sparse state's lock to clone it. That lock is held around D3D12 calls (an upload's allocator Reset in begin_slot), and D3D12 can make a resource's last Release inside a call of its own on another thread: with XCL_DRED=1 a list's Reset does, every run. The Reset under the lock then waits for D3D12's lock and the Release inside D3D12 for the sparse state's: the title stands still a few seconds after it starts. The queue is kept a second time outside the state (QUEUE), set when the state is made or replaced, and queue() answers from there. Test: the_queue_is_answered_while_the_state_is_locked. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Test report for #968 at Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the suites and read the diff; I checked the report. |
|
Linux / AMD RDNA3 datapoint. Merged state: head Full suite, Not tested: retail titles (none here), Windows, RDNA4. 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 AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting. |
|
Independent verification, merged onto current Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
AI use: test runs by Devin (Cognition, SWE-2); no code changes. |
|
Independent native GPU queue check on 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 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. |
|
Retail DRED run with #968 and #789 on AMD RDNA4 Tested
Not tested — The retail effect of #968 in isolation, a clean upstream-main comparison, or rendered gameplay. AI use — OpenAI Codex ( |
…cl-dev#1286-xcl-dev#1291, xcl-dev#1294, xcl-dev#1296-xcl-dev#1297, xcl-dev#1300 Prevent background shader preloading and concurrent DXC/RADV compiles from exhausting host RAM under Wine, and integrate 11 open upstream PRs: - dxc.rs & real.rs: check free physical RAM (ullAvailPhys.min(ullAvailPageFile)) under Wine instead of swap-inclusive ullAvailPageFile, avoid bypassing the guard after 60 s under Wine, and serialize giant (>= 4 MiB DXIL) driver compiles with BIG_COMPILES under Wine. - pso_async.rs: cap background preload workers to 1 under Wine. - title_textures.rs: use real::create_raw_fence in submit_on_title_queue and read coherent-window hash bytes safely via with_title_bytes. - Integrate upstream PRs xcl-dev#968 (sparse::queue lock-free for late_release), xcl-dev#1286 (v_dot2_f32_f16 NEG_HI abs), xcl-dev#1287 (XMA >8 channels), xcl-dev#1288 (Sleep pauses during PSO bind waits), xcl-dev#1289 (pipeline stream bounds check), xcl-dev#1290 (root signature MAX_ARGS cap), xcl-dev#1291 (console UAV clears xcl-dev#53/xcl-dev#54), xcl-dev#1294 (shadowed PENDING accuracy), xcl-dev#1296 (16-bit compare low halves), xcl-dev#1297 (fence_x pre-cell signal arming), xcl-dev#1300 (log driver compute PSO refusal). Verified on RX 9060 XT under GE-Proton11-14 (MemoryMax=12G, 80 s): committed RAM stays flat at 4830 MB (down from 27.6 GB OOM), 1493 frames shown, exit 0x0. Assisted-by: Antigravity (Google DeepMind)
…-dev#968, xcl-dev#1286-xcl-dev#1300 Assisted-by: Antigravity (Google DeepMind)
|
Windows 11, RX 7900 XT (RDNA3), driver 32.0.32029.2010. I tested main 930e8b4 and the pair #789 bc82410 + #968 9beaa73. 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. |
Brings in 20 newly merged upstream PRs (xcl-dev#959, xcl-dev#968, xcl-dev#1079, xcl-dev#1084, xcl-dev#1091, xcl-dev#1099, xcl-dev#1127, xcl-dev#1133, xcl-dev#1137, xcl-dev#1150, xcl-dev#1211, xcl-dev#1223, xcl-dev#1224, xcl-dev#1265, xcl-dev#1289, xcl-dev#1290, xcl-dev#1330, xcl-dev#1353, xcl-dev#1354), including in-memory shader cache session fallback (xcl-dev#1211), CPU-invisible resource Map filtering (xcl-dev#1099), DRED partially executed list priority (xcl-dev#1330), allocation info alignment padding (xcl-dev#1354), and DirectStorage status/error/cancel fixes (xcl-dev#1127, xcl-dev#1223, xcl-dev#1224).
Conflicts: - sparse.rs (init): our WORK/STATE split already keeps the sparse queue in QUEUE outside both locks, which is what xcl-dev#968 adds. Upstream's second QUEUE static and its init lines are dropped; its ordering is kept: QUEUE is replaced before the GPU side and the state, so queue() never answers with a queue older than the state's. - sparse.rs (tests): both kept; xcl-dev#968's test asserts queue() answers while STATE is held, ours while WORK is held. queue()'s doc names WORK. - real.rs (DRED): our dred_lines (lines returned for the log, DRED 1.1 names, no-fault and no-list lines) is kept. xcl-dev#1330's order is taken over: unfinished lists the GPU had started are named before unstarted ones (unfinished_to_name), at most 64, and the chain is read to at most 4096 nodes. Its report_dred_lists and its xlog lines are dropped (they would log the lists a second time); its test is ported to BreadcrumbNode in our dred_tests. Assisted-by: omp (Claude Opus 5.5)
…aced The merge of xcl-dev#968 kept its comment "the queue first: queue() never answers with one older than the state's", which is true upstream, where QUEUE is replaced before STATE is taken. Here QUEUE, WORK and STATE are all replaced in one section under WORK and STATE, so the order inside it cannot be seen; the comment now says that. Assisted-by: omp (Claude Opus 5.5)
…sign It said that nothing may wait on the state from a release inside a D3D12 call. Here a release does take STATE (forget_buffer, forget_queue), which is safe because STATE is never held across a D3D12 call; the lock a release must not wait for is WORK. The doc now says that queue() needs neither WORK nor STATE. Assisted-by: omp (Claude Opus 5.5)
… lock `before_execute` holds the sparse state's lock (`STATE`) around D3D12 calls. D3D12 can make a placed buffer's last Release inside one of its own calls on another thread; that Release reaches `forget_buffer`, which took `STATE` too: the D3D12 call under the lock waited for D3D12's lock, the Release inside D3D12 for `STATE`. A retail title's presents stopped after its third frame on every start (black screen) with both threads in those waits. `forget_buffer` now queues the resource in `FORGOTTEN` and only takes `STATE` if it is free (`try_lock`); every other user of the state takes it through `lock_state`, which first lets the queued buffers go. #968 fixed the other half of the same cycle (`queue()`). Test: a_buffer_released_while_the_state_is_held_does_not_wait_for_it (fails on main after its 5 s timeout: "forget_buffer waited for the sparse state's lock"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With
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– D3D12.X: decommit released sparse blocks outside the driver callback #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 D3D12.X: decommit released sparse blocks outside the driver callback #789 the second. With both the title runs.XCL_DRED=1went on to the device removal of Retail title 1.0.2.1: GPU hang / crash at +0x23cf683 when the story loads (RTX 3070 Ti) #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 Retail title 1.0.2.1: GPU hang / crash at +0x23cf683 when the story loads (RTX 3070 Ti) #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