Repository navigation
D3D12.X: a buffer's last release does not wait for the sparse state's lock - #1981
Merged
raylitebull merged 1 commit intoNov 25, 2026
Merged
Conversation
… 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. xcl-dev#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>
Eterst
marked this pull request as ready for review
November 25, 2026 00:26
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
Member
|
Code review on
Remaining before merge: |
Contributor
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
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.
forget_bufferno longer waits for the sparse state's lock.before_executeholdsSTATEaround D3D12 calls, and D3D12 can make a placed buffer's lastReleaseinside a call of its own on another thread; thatReleasereachesforget_buffer, which tookSTATE. The D3D12 call under the lock then waits for D3D12's lock and theReleaseinside D3D12 forSTATE. On a retail title this stopped presents after the third frame on every start (black screen), with both threads in those waits in a thread dump. #968 fixed the other half of the same cycle (queue()); this is the remaining half.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:forget_bufferqueues the resource inFORGOTTENand takesSTATEonly if it is free (try_lock); every other user of the state takes it throughlock_state, which first lets the queued buffers go (forget_released→forget_in, the old body). Testa_buffer_released_while_the_state_is_held_does_not_wait_for_it.Tested
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on892177b: 976 passed, 0 failed, 45 ignored. SKIPPED on this adapter (no wave64 / refused forms): thegpu::recomp::lowerandlower_dxilGPU comparisons,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,heap_window_out_of_memory_falls_back_to_the_switch_form.main689f2db(forget_buffer waited for the sparse state's lock, after its 5 s timeout) and passes here.hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memoryand threelist_xGPU tests (0x887A0005) fail now and then in parallel runs, onmainas well (3 of 8 parallelmainruns); they passed in the run above.Regression run
main:
this PR:
Not tested
mainthe 60 s smoke run does not hit the deadlock (it needs aReleasefrom inside D3D12 whileSTATEis held); the black screen was seen on an earlier base (930e8b4) before D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock #968, so the smoke runs only check for regressions.AI use
🤖 Generated with Claude Code