D3D12.X: wait_for ignores stale signals on the reusable sparse fence event #1409
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1419"
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 gridoe on 2026-11-24T15:47:00Z.
sparse::State::wait_forreuses a single auto-reset Win32 event (self.event) across waits onself.fence, callingSetEventOnCompletion(target, self.event)followed by oneWaitForSingleObject(self.event, 5000). If an earlier wait times out at 5 s and its pendingSetEventOnCompletion(old_target, self.event)completes afterwards,self.eventstays signalled (or fires mid-wait during a later call). Every subsequentwait_for(newer_target)then returns in under 1 ms beforeself.fenceactually reachesnewer_target, lettingbegin_slotreset an in-flight command allocator andreadback_after_executecopy from staging before the GPU copy finishes.This change extracts a small
wait_fence_untilhelper that callsResetEvent(event)beforeSetEventOnCompletionand loopsWaitForSingleObjectagainst the remaining deadline untilfence.GetCompletedValue() >= target.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs: addwait_fence_until, switchState::wait_forto call it, and addwait_fence_until_ignores_stale_event_signalcovering both an already-signalled event and an earlier pendingSetEventOnCompletionfiring mid-wait.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13)(stable-x86_64-pc-windows-msvc), debug (tests) and release (smoke).cargo +stable-x86_64-pc-windows-msvc build --workspaceandcargo +stable-x86_64-pc-windows-msvc test --workspace -- --test-threads=4: 725 passed, 0 failed, 41 ignored (includinghle::d3d12x::sparse::tests::wait_fence_until_ignores_stale_event_signal).SKIPPEDGPU/D3D12 tests on this adapter:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)test_title_draws_with_a_root_signature_under_the_debug_layer(no d3d12SDKLayers.dll)uploads_start_from_each_subresources_state(no D3D12 debug layer (0x887A002D))<game folder>): 60 s regression run below; in longer bring-up runs past menus on this machine, once a single 5 s sparse wait timed out,wait_forpreviously logged 51 back-to-back ~1 ms timeouts before crashing in readback, and dropped to 0 after this fix.Regression run
main:
PR:
Not tested
d3d12SDKLayers.dllnot installed), Wine /vkd3d-proton.XCL_SAMPLE_*env vars.wait_fordoes not time out; the stale-event timeout path is covered directly by the unit test and by longer local bring-up runs.AI use
wait_fence_untilhelper, unit test, and PR description; all builds, tests, and smoke runs were executed locally on the hardware listed above.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:57:00Z.
Full-suite run, since this PR has no test report yet. Tested exact head
3861d2e(on its base9aec53d).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 725 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.wait_fence_until_ignores_stale_event_signal.XCL_ADAPTER=radeon), full suite: one failure, 2 of 2 runs:readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state, atreal.rs:5463,assert_ne!(VirtualFree(mem, 0, MEM_RELEASE), 0)(the release of theOpenExistingHeapFromAddressmemory fails after the heap is dropped). 683 passed before cargo stopped.main930e8b4right after passes (751 passed, 0 failed), and the test passed in all ~70 other full Radeon runs of other PRs I did today. Run on its own, it passes 5 of 5 on both this head andmain. So it shows up only next to the other lib tests with this change in.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:13:12Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (One parallel run showed a single flaky failure; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:41:51Z.
Test report for head
3861d2eas pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 725 passed, 0 failed, 41 ignoredwait_fence_until_ignores_stale_event_signalran and passedXCL_SAMPLE_*data set (game-data tests not run)Not tested
main; the D3D12 debug layerAI use
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T12:19:39Z.
Linux / AMD RDNA4 (RADV) test report for head
3861d2emerged locally ontomain1a0bbe3(clean merge).Environment
experimental-11.0-20261112), vkd3d-proton v3.1 (#257+dxil-spirv53aac418), DXVKv3.1.1-209, DXC1.9.2609.5,x86_64-pc-windows-gnucross-compileTested (debug test binary under Wine,
XCL_ADAPTER=9070 XCL_REQUIRE_GPU=wave64,--test-threads=1 --nocapture)hle::d3d12x::sparse: 16 passed, 0 failed, 1 ignored (early_commit_timing), 0 skipped (2.31 s), includingwait_fence_until_ignores_stale_event_signalon RX 9070 / RADV.Not tested: full workspace suite, retail title run, native Windows.
AI use: T3 Code / Antigravity (Gemini 4 Neon) merged, built, ran the tests on this machine, and drafted this report.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T13:19:16Z.
AMD RDNA3 (native wave64) test report for exact head
3861d2e2b561482933c657802cc5801b28bc60ba, as pushed on its base9aec53d(not merged onto currentmain).Tested
cargo build --workspace: okwait_fence_until_ignores_stale_event_signal: 1 passed;sparsefilter: 17 passed, 0 failed, 1 ignoredcargo test --workspace --no-fail-fast -- --test-threads=4: 725 passed, 0 failed, 41 ignored (summed over all test binaries)Not tested
scripts/smoke.ps1regression run (synthetic GPU/unit tests only)main; other GPUs (NVIDIA / Intel / RDNA2 / RDNA4)AI use: Claude Code (Claude Sonnet 5.5) ran the build and tests and wrote this report; the numbers are from the runs above.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:41:18Z.
Triage (#1607) – head
3861d2eMain already fixes this: commit
b5e8baff(merged with #3203) rewroteState::wait_foraswait_for_ms, which re-armsSetEventOnCompletionand waits again untilfence_completed >= targetor the timeout, for the same reason (a timed-out wait's registration firing the shared event later).The large amd-dev PRs that share these lines (#2912, #2981, ...) carry this commit as part of their base; they are not separate fixes.
Recommendation: close (superseded by main commit
b5e8baf).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:45:24Z.
Closing as superseded: this change is already on
main(b5e8baff). main sparse.rs State::wait_for_ms loops SetEventOnCompletion/WaitForSingleObject until fence_completed >= target or timeout (b5e8baff), so a stale event signal no longer ends the wait; same fix as the PRTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed