Repository navigation
[upstream #968] D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock - #144
Merged
Merged
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
XCL_DRED=1a retail title stands still a few seconds after it starts – two reports of that in xcl-dev#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. xcl-dev#789 closes one; this closes the other. Part of xcl-dev#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 xcl-dev/xcl#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+ xcl-dev#789 (bc82410)main+ this PRmain+ xcl-dev#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 xcl-dev/xcl#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) xcl-dev/xcl#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) xcl-dev/xcl#675.Regression run (default settings, no
XCL_DRED)main:
PR:
A second round: 1375 frames (
main), 1362 (PR).mainhas moved on to6bac4b4since these ran (xcl-dev#923, xcl-dev#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 xcl-dev#789 (the other path,forget_buffer; it does not touchqueue()– checked by running it), xcl-dev#461, xcl-dev#433, #236, xcl-dev#496, xcl-dev#532, xcl-dev#923, xcl-dev#930 (other parts ofsparse.rs), and issue #344 (closed: the same mutex, at state replacement).🤖 Generated with Claude Code
Mirror of xcl-dev#968 (auto-synced, do not edit).