D3D12.X: replacing the sparse state drops the old one after the lock #461
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!461
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/461/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?
@coenflict on GitHub · 2026-11-24 00:34 UTC · original
coenflict:sparse-init-drop-outside-lock→main· +29 −1 · 1 files · 1 commits · closed without mergingsparse::initassigned the new sparse state under theSTATEguard, so the old state was dropped with the guard held. Dropping it releases its resources throughreal::res_release→sparse::forget_buffer, which locksSTATEagain and waits for itself. The old state is now taken out under the guard and dropped after it. Fixes #344What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:replace_unlockedputs the new value in and drops the old one after the guard;inituses it. A unit test replaces a value whoseDroplocks the same mutex, twice, on a thread with a 10 s timeout.Tested
cargo test -p xcl --lib replacing_drops_the_old_value: with the old assignment it fails (deadlock, timeout after 10 s); with the fix it passescargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored (lib: 637 passed, 0 failed, 21 ignored)gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
main:
this PR:
This PR's head ran four times: 1149, 887, 1506 and 1531 frames. The first two runs came before any run of
main. The 887 run fell to 8 presents per 2 s in its last seconds. After that, alternatingmainand PR runs gave 1499 and 1498 frames onmainand 1506 and 1531 on this PR.mainran three times in all, with 1495 to 1499 frames. The low runs were not seen once the runs alternated, and the change only acts whensparse::initruns twice.Not tested
real::init()calls racing.sparse::initonce, so the smoke run checks for regressions and does not reach the fixed path.AI use
🤖 Generated with Claude Code
@MesshM on GitHub · 2026-11-24 00:52 UTC · original
Heads-up for whoever merges: this PR and #443 (opened ~12 minutes earlier) fix the same thing, #344, with the same change in
sparse::init: take the old state out under theSTATEguard and drop it after the guard. Only one of the two should land.What differs, so either can be picked:
sparse::init, plus an integration test (crates/xcl/tests/sparse_reinit.rs) that runs the real path on a device: a sparse block written and read back, thensparse::initagain on a second thread. I ran it on an AMD RX 9060 XT (RDNA4) and posted the results there: full suite 677 passed / 0 failed / 0 SKIPPED, and withmain'ssparse.rsthe test fails after 60 s. Its regression run is still pending.replace_unlockedhelper and a unit test with aDropthat relocks the mutex (no device needed), and it already has a regression run on a retail title (RTX 5090).I have not run this PR's head. Written with Claude Code (Claude Opus 5.5); the comparison was checked against both diffs.
@upipibi on GitHub · 2026-11-24 05:28 UTC · original
For cleanup: #443, the same change to
sparse::initthat @MesshM pointed out above, was merged at 03:38 UTC, and this PR now conflicts withmaininsparse.rs. The only part not onmainis the unit test; if it adds coverage #443 lacks, it could go in as a test-only PR, otherwise this one can close.AI-assisted (Claude Code), read-only review.
@raylitebull on GitHub · 2026-11-24 10:42 UTC · original
Closing as a duplicate of #443, which has already been merged into
main.Pull request closed