D3D12.X: a sparse list still in flight after its bounded wait is held, not reset #3062
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3062"
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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T18:42:06Z.
The sparse queue's wait (
wait_for) gives up after 5 s and goes on.begin_slotand the readback path thenResetthe allocator and list of the submission the wait gave up on, while the GPU may still be executing it. D3D12 does not allow that. Retail runs on other machines log the timeout (sparse: the queue has not reached fence value … after 5 s) five or more times a run: #675, #505, #846, #646.Now a pair that is still in flight after the wait is held until the queue has passed its submission, and a new pair takes its place. Part of #3011 (C16); the mechanism follows Vice-Tay
b06fdd5.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:wait_forreturns whether the fence was reached. The bound (5 s) is unchanged.hold_pending: the old allocator and list go toheld_listswith the fence value of their last submission, and a new pair replaces them. If no new pair can be made, it waits without a bound instead of resetting.begin_slot(upload slots) and the readback list use it.reclaim_ringdrops held pairs once the fence has passed.a_slot_still_in_flight_after_the_wait_is_held_not_reset. It holds the queue on an unsignalled fence (queue.Wait), submits a slot, comes round to it again with a 20 ms bound, and checks that the slot got a new allocator and that the old one goes once the queue is released. A test-only override of the bound (wait_ms) keeps it short.sparse.rs:wait_forchecks the fence after every wake and waits again against the same deadline. The sparse fence waits share one auto-reset event, so a wake left behind by a wait that gave up ended the next wait at once, and it reported "not reached" without waiting (found by pickles976 on #3063;mainhas the same single wait). The timeout warning now gives the time actually waited. Testa_stale_wake_does_not_end_the_next_wait: a wake is left on the event, then a wait for the next value, signalled from another thread 20 ms later, must returntrueafter at least 10 ms.THIRD_PARTY.md: a row for Vice-Tay. No code is taken from it, only the mechanism (a submission whose bounded wait timed out stays pending until its fence has passed), reimplemented here.This makes the lifetime of the lists safe, not the bytes. After a timed-out wait,
flush_and_copystill copies the readback buffer into title memory; #3063 (stacked on this one) leaves that copy out. The upload staging ring was already safe: its space is freed only for completed fences.Tested
cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4ate9e84e87: 1467 passed, 0 failed, 47 ignored; 25SKIPPED(no wave64 on this adapter, and one "no heap windows").cargo test -p xcl --lib sparse::ate9e84e87: 19 passed, 0 failed, 1 ignored (early_commit_timing, ignored onmaintoo).a_stale_wake_does_not_end_the_next_waitalone: passed 3 of 3.begin_slot: "an allocator the GPU may still execute was reset for reuse". With the old single wait: "the wait ended on a stale wake after 111–192 µs", 3 of 3.Regression run
Both 60 s,
XCL_PREPARE=0(full shader preparation does not finish in time on this machine),XCL_PRESS_AT=25:A, a new emptyXCL_DXIL_CACHEfor each run, the same retail game.main:This PR:
Not tested
main, and the 60 s smoke never comes near a 5 s sparse-queue stall. The reporters of #675 / #505 would see it: the warningsparse: N command lists still in flight after the wait were held, not resetshould appear wherehas not reached fence valuedoes.AI use
Credit: the mechanism is Taynan Piza's (Vice-Tay #307,
b06fdd5).🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T03:26:19Z.
I checked the previously untested native D3D12 debug-layer path on RTX 5070 / NVIDIA 616.92 at head
e9e84e87, using a test-only fixture with two consecutive bounded sparse-queue waits and controlled gates. Three fresh-process runs passed without skips or debug-layer errors.While the sparse queue was blocked, both 20 ms waits timed out. XCL retained both pending allocator/list pairs and used a distinct replacement for each subsequent recording. Releasing the first gate advanced the fence from 0 to 1 and reclaimed only the first pair; releasing the second advanced it to 3 and reclaimed the remaining pair.
This tests the synthetic allocator lifetime and reclamation path under a stalled queue. It does not test retail stalls, physical memory savings, or readback contents.
AI use: OpenAI Codex with GPT-6.2 Astra built and ran the checks; Codex reviewed and prepared this report.
Pull request closed