D3D12.X: track Write64 fence highs and keep the sync watchdog awake after CPU releases #1419
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1429"
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:53:04Z.
On native Windows D3D12, an older in-flight GPU
queue.Signal(&fence, v - 1)on a slower queue can retire after a higher GPU completion or a CPUfence.Signal(v)(from a cycle-break or watchdog release) and rewindID3D12Fence::GetCompletedValue()backwards. Two gaps inlist_x.rslet those rewinds stick and stall laterqueue.Waitcalls:prune_completed_waitsdid not track the highest observedGetCompletedValue()on aSyncCellor restore a fence that dropped belowcpu_signaled_max.max(highest_completed).ARMED_GPU_WAITSdropped to0andxcl-sync-watchdogwent straight back tocv.wait, so an older in-flight GPUSignalretiring milliseconds later rewound the fence with nothing awake to restore it.This change records
SyncCell::highest_completed, restores rewound fences inprune_completed_waits, and adds a shortREWIND_GUARD_UNTILwindow (10 s, polling at 20 ms whileARMED_GPU_WAITS == 0) armed whenever a CPU release or rewind repair occurs soxcl-sync-watchdogcatches post-release GPU rewinds.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: trackSyncCell::highest_completed, detect/restore fence rewinds inprune_completed_waits, addREWIND_GUARD_UNTIL/arm_rewind_guard/rewind_guard_activeforxcl-sync-watchdog, and addsync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13)(stable-x86_64-pc-windows-msvc), debug (tests) and release (smoke).main(9633138) asdd5ea20:cargo +stable-x86_64-pc-windows-msvc test -p xcl --lib hle::d3d12x::list_x::tests— 35 passed, 0 failed (includingsync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits);cargo +stable-x86_64-pc-windows-msvc build --release -p xclclean.3ea5ef4:cargo +stable-x86_64-pc-windows-msvc test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored (SKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state).<game folder>): 60 s regression run below; in longer bring-up runs past the opening title card on this machine, multi-queueWrite64rewinds (0x6df -> 0x6de,0x6e1 -> 0x6e0,0x795 -> 0x794) were caught and repaired, cuttingGPU queue.Waittimeouts from 166 to 0 in the compared run.Regression run
main:
PR:
Not tested
d3d12SDKLayers.dllnot installed), Wine /vkd3d-proton.XCL_SAMPLE_*env vars.Write64rewinds do not occur; the zero-armed-waits rewind repair path is covered directly by the unit test and by longer local bring-up runs.AI use
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:57:48Z.
Full-suite run, since this PR has no test report yet. Tested exact head
3ea5ef4(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.sync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T19:02:11Z.
Review: COMMENTED
AI-assisted review; I checked the guard lifetime against the D3D12 queue ordering described in the PR.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:18Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T19:02:11Z.
Code review location:
crates/xcl/src/hle/d3d12x/list_x.rs; line 1101The rewind guard expires after 10 seconds, but a queued
ID3D12CommandQueue::Signalhas no completion deadline: it can remain behind stalled or long-running work and retire after this window. Once the guard expires with no armed waits, the watchdog returns tocv.wait, so that late lower signal can rewind the fence without repair until some later event happens to wake the watchdog. Could the guard remain active while older signals are in flight, or otherwise track their completion rather than use a fixed timeout? AI-assisted review; I verified the fixed window and idle branch.upstream-sync referenced this pull request2026-11-25 06:04:27 +00:00
upstream-sync referenced this pull request2026-11-25 12:04:57 +00:00
Imported from ivall/xcl. Originally posted by gridoe on 2026-11-25T11:19:06Z.
Rebased onto current
main(9633138) asdd5ea20, resolving the two additive conflicts incrates/xcl/src/hle/d3d12x/list_x.rsalongside#1926,#2078, and#2163.Tested
rustc 1.99.1(stable-x86_64-pc-windows-msvc).cargo +stable-x86_64-pc-windows-msvc test -p xcl --lib hle::d3d12x::list_x::tests— 35 passed, 0 failed (includingsync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits,sync_watchdog_pair_is_set_before_the_thread_starts, andcpu_cycle_break_publishes_value_to_title_memory_and_keeps_it_monotonic).cargo +stable-x86_64-pc-windows-msvc test -p xcl --lib -- --test-threads=4— 1,173 passed, 2 unrelated pre-existing failures onmain9633138(gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translatorandhle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa), 26 ignored.AI use: Rebase conflict resolution and test verification assisted by Antigravity with Gemini 4 Neon.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T13:09:23Z.
Update for head
b14487f4(earlier results fordd5ea20below)Same RX 9070 / RADV / Proton Experimental machine, patched vkd3d-proton (master
ec207194without the allocator / command-listlpVtblchecks), Rust 1.96.0,x86_64-pc-windows-gnu. Head merged ontomain83b00818, test commitff73a5f9.Tests (debug,
XCL_REQUIRE_GPU=wave64,--test-threads=1)hle::d3d12x::list_x::: 41 passed, 0 failed (main: 40 passed, 0 failed), includingsync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waitscargo test --workspace --no-fail-fast -- --test-threads=4, lib binary: 1322 passed, 8 failed, 27 ignored (mainthe same run: 1320 passed, 9 failed, 27 ignored). The failures are all amongmain's.Retail title, 300 s (release, every run from a copy of the same warm-cache snapshot;
XCL_DIRECT_DXIL=1 XCL_PREPARE=1 XCL_PSO_PRELOAD=1 XCL_PSO_WAIT_MS=50 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=1024 VKD3D_CONFIG=ignore_shared_fence,Apressed every 10 s)0xc0000005in the title (game_scarlett_master.exe+0x23cf683, a write at address 0) at 305.7 s, after the 300 s, while the title was being stopped; it had 2,046 presents.main, 4 runs: all clean, 1,892–2,122. It is not this PR's: the same crash (same offset, a write at address 0) happened in 16 earlier runs on this machine on trees without this PR (11-24 and 11-26, at ~110–130 s), and on #3011 a skip file of the title's ray-tracing programs is reported to remove it.Not tested
AI use
Linux / AMD RDNA4 (RADV) test report for head
dd5ea20merged locally ontomain1a0bbe3(clean merge).Environment
experimental-11.0-20261112), vkd3d-proton v3.1 (#257+dxil-spirvmaster694cc674), 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::list_x: 35 passed, 0 failed, 0 ignored, 0 skipped (0.34 s), includingsync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits.hle::d3d12x::real: 56 passed, 0 failed, 0 ignored, 0 skipped.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 gridoe on 2026-11-25T17:39:20Z.
Rebased onto current
main(68a284a) asb14487f, resolving the additive test conflict at the end ofcrates/xcl/src/hle/d3d12x/list_x.rs.Tested
rustc 1.99.1(stable-x86_64-pc-windows-msvc).cargo +stable-x86_64-pc-windows-msvc test -p xcl --lib hle::d3d12x::list_x::tests— 37 passed, 0 failed (0.63 s), includingsync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits,sync_watchdog_pair_is_set_before_the_thread_starts, andcpu_cycle_break_publishes_value_to_title_memory_and_keeps_it_monotonic.AI use: Rebase conflict resolution and test verification assisted by Antigravity with Gemini 4 Neon.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:13:10Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-27T14:36:21Z.
Wine/NVIDIA verification of exact head
b14487f442d91f33e8640bddfc91fe1eb1261773:x86_64-pc-windows-msvc,DXVK_CONFIG='dxgi.hideNvidiaGpu = False'.2576c0b4adfae4a+(two local console-vtable assertion relaxations used throughout this lab; not stock-vkd3d certification).Compiling xcl v0.1.0 (.../xcl-pr1429/crates/xcl).cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib sync_watchdog_and_prune_repair_fence_rewind_with_zero_armed_waits -- --nocapture --test-threads=1through the Wine wrapper, with a 9 GiB memory / 512 MiB swap scope.0x7 -> 0x4and0xa -> 0x9.This closes the PR's listed Wine/vkd3d test gap for the focused rewind fixture only. No title was launched, and this does not establish correction of our separately observed Game-Init
cpu_writeslegacy fallback (fence at 0, wanted 1).Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:43:11Z.
Triage (#1607) – head
b14487fNo open or merged PR makes the same change: #906 handles rewinds of the fence_x.rs completed-value mirrors, and #2499 (merged) only fixed the watchdog's lost wake-up; neither tracks a highest_completed floor per Write64 cell or keeps the watchdog polling after a CPU release.
The PR conflicts with main: wake_sync_watchdog now sleeps through sync_watchdog_sleep_if_idle (#2499), so the REWIND_GUARD_UNTIL check has to move into that helper's idle condition when rebasing.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.