Repository navigation
Conversation
sparse::init installed its state with *STATE.lock() = Some(s): the state it replaced was dropped while the guard was held. Once used, that state holds the last references to buffers of its own (readback, staging, zeros), all made through the adopted device; their release goes through real::res_release, which calls sparse::forget_buffer, which locks STATE again - the thread waited for itself, and every later user of the sparse windows behind it. The windows are set up again when two first real::init calls overlap, as GPU tests starting together do: a suite run hung in four GPU tests until it was killed. The old state is now taken out under the lock and dropped after it. Fixes ivall#344 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Test run of Tested
Review of the change: in Not tested: no retail title or regression run (I have no unpacked game), no Run and report by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Tested RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug, Pass: 677 passed, 0 failed, 41 ignored. SKIPPED: only the 2 Run and written with Claude Code (Claude Opus 5.5). |
shdann
left a comment
There was a problem hiding this comment.
crates/xcl/tests/sparse_reinit.rs:33 assumes that the second initialization creates at least one window. On 16fc79d, the Windows CI worker completed the call within the timeout and returned zero windows. The test then failed at this assertion. Please check that the adapter can create the second set of windows before using this integration test as the deadlock check. A separate test with a destructor that takes the same lock can cover the lock order on every worker. Failed CI job. Reviewed the diff and CI log with OpenAI Codex (GPT-6).
d3d12x::sparse::initinstalled its state with*STATE.lock().unwrap() = Some(s), so the state it replaced was dropped while the guard was held. A state that has been used holds the last references to buffers of its own: readback, staging and zeros, made lazily through the adopted device (sparse.rs830–896). Their release goes throughreal::res_release, which callssparse::forget_buffer, which locksSTATEagain. The thread waits for itself, and every later user of the sparse windows waits behind it. The old state is now taken out under the lock and dropped after it, as planned in the issue.Fixes #344
The windows get set up again when two first
real::init()calls overlap.real::initreturns early only onceDEVICEis set, andDEVICEis set afteropen_uma→sparse::init, so GPU tests that start together can both get there. That is how the hang in the issue came about: the issue's suite run stopped in four GPU tests until it was killed. One correction to the issue: what matters is not placed buffers in general but the state's own last-referenced buffers, which is why the test reads back a block before setting the windows up again.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs,sparse::init:STATE.lock().unwrap().replace(s), and the old state is dropped after the guard.crates/xcl/tests/sparse_reinit.rs,the_sparse_state_is_replaced_outside_its_lock, in its own process:real::init(), then a 64 KiB sparse block, written and read back (readback_now), which gives the state its readback buffer;sparse::initagain with the same device, on a second thread. The test waits 60 s for it, so on main it fails instead of hanging the suite.Tested
cargo test --workspace -- --test-threads=4on16fc79d(this PR, on maina6f5f7a): 677 passed, 0 failed, 41 ignored (thexcllibrary: 636 passed, 21 ignored). SKIPPED GPU tests: 2, bothno wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).a6f5f7awith only the test added: 3 of 3 failed withsparse::init did not return within 60 s(60.3–60.7 s);16fc79d.scripts/test.ps1: 677 passed, 0 failed, 41 ignored, no SKIPPED GPU tests. Withsparse.rsfrommainand the new test kept, the test fails after 60.33 s (1 run).16fc79dmerged ontomain2997c9a.cargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored; SKIPPED only the 2no wave64tests.Regression run
main: Pending: no title on our machine yet; our own run follows when we have one.
PR: Pending: no title on our machine yet; our own run follows when we have one.
Not tested
sparse::inittwice (a second device, for example).real::init()calls that really overlap. The test callssparse::inita second time directly, with the device it already has.sparse::initand keeps the drop under the guard (*state = Some(s)whilestateis the guard), so whichever merges second needs a rebase.AI use
🤖 Generated with Claude Code