D3D12.X: bridge Wait64BitValueX to GPU fences with exact cycle breaking #795
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!795
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/795/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?
@gsucristo on GitHub · 2026-11-24 05:33 UTC · original
gsucristo:d3d12x/wait64-gpu-bridge-and-cycles→main· +1717 −21 · 3 files · 1 commits · merged 2026-11-24 05:58 UTCBridge monotonic
Wait64BitValueX/Wait32BitValueXandWrite64BitValueXoperations across queues using realID3D12Fencequeue.Wait/queue.Signalinstead of stalling the CPU submission thread until timeout, with an exact(queue, seq)dependency graph that detects and breaks genuine cross-queue cycles at Signal time without false positives on pipelined frames. Related to #505 (note: overlaps in goal with draft #769 and open #708; this PR specifically contributes the exact(queue, seq)transitive cycle graph including same-cell edges and GPU watchdog diagnostics, with mid-list splitting separated into a stacked follow-up PR).Size note: The diff is +1,717 / -21 lines total (~1,005 runtime lines, ~712 lines of unit and GPU tests across 6 new tests). Mid-list command-list splitting has already been split out into a stacked follow-up PR; the remaining bridge state machine,
(queue, seq)cycle graph, same-queue FIFO bypass, and GPU watchdog share the same per-cell fence table and are kept together so every submission path stays deadlock-free.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: per-cell GPUID3D12Fencebridge for monotonicWait64/Wait32/Write64sequences, same-queue FIFO bypass, exact(queue, seq)transitive dependency graph (including same-cell edges) with deterministic Signal-time cycle breaking, GPU completion watchdog, and 6 new GPU/unit regression tests (write_buffer_immediate_on_open_existing_heap_visible_to_cpu,cross_queue_wait64_before_signal_does_not_deadlock_submit_thread,cross_queue_cycle_and_same_queue_fifo_do_not_deadlock,pipelined_next_frame_write_is_not_false_cycle,rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang,cpu_watchdog_signal_with_inflight_gpu_signal_completes_cleanly).crates/xcl/src/hle/d3d12x/fence_x.rs: record explicitID3D12CommandQueue::Wait/Signalfence edges into the shared dependency graph for transitive cycle detection and watchdog diagnostics.crates/xcl/src/hle/d3d12x/real.rs: hookExecuteCommandListssubmission sequencing into the Wait64 GPU bridge.Tested
rustc 1.98.1(x86_64-pc-windows-msvccross-compile), debug.cargo test --workspace --no-fail-fast --target x86_64-pc-windows-msvc -- --test-threads=4 --skip a_freed_block_is_decommitted_before_its_address_is_reused: 705 passed, 4 failed (pre-existing Wine-only failures:hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime,test_title_runs_and_game_folder_is_untouched,disk_free_space_ex_reports_pls_quota,set_predication_buffer_state_and_kickoff), 41 ignored, 1 filtered (a_freed_block_is_decommitted_before_its_address_is_reused).SKIPPEDGPU tests:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
scripts/smoke.ps1runs on a retail title (Linux/Proton environment only).Not tested
scripts/smoke.ps1retail regression run.AI use
@MesshM on GitHub · 2026-11-24 05:51 UTC · original
Test run of
8a5643f4eaf1d6ffa343cd636ab50c54ef57d049on AMD RDNA4. I merged it onto currentmaine50836blocally (clean merge).Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 710 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 669 passed, 0 failed, 21 ignoredSKIPPED; thefence_x/list_xtests pass,the_cell_follows_the_fenceincluded.Review: At 1717 lines I reviewed the structure, not every line. Overlap: the description itself names #708 (open) and #769 (draft) as having the same goal; the maintainer will want one approach for cross-queue
Wait64BitValueX, so it may help to say in one place how this one differs from #708's list splitting.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@upipibi on GitHub · 2026-11-24 05:51 UTC · original
Three points on
8a5643f, from reading the code (not run):1. The watchdog can lose its wakeup (high confidence). The watchdog takes
lock, seesARMED_GPU_WAITS == 0and callscv.wait(guard)with no timeout (list_x.rs:1335-1336), butwake_sync_watchdogcallsnotify_one()(:1427) without takinglock. A wait armed and notified between the check and thecv.waitis missed, and the watchdog then sleeps until the next wait is armed. If that missed wait is the one a frame hangs on, nothing releases it. Takinglockaround the counter update andnotify_one, or usingwait_timeoutin the idle branch too, closes it.2. The cycle check doesn't see XCL's own sparse-queue waits (medium).
would_signal_close_cycle(:1120) is exact only for the edges inSYNC_GRAPH. Two waits XCL inserts aren't in it: after a list that writes sparse memory the sparse queue waits on the title queue'srb_fence(sparse.rs:1193-1194), and every title queue waits on the sparse queue'ss.fence(sparse.rs:1429). With a bridged Wait64 they close a cycle:Wait64(A >= n); its writer L2 is recorded but not yet submitted; L1 writes sparse memory. That givesQ1.Wait(A),Q1.Signal(rb),sparseQ.Wait(rb).s.fence.Q2.Signal(A)passes the check (no edge from Q2 to Q1), and now Q1 waits on Q2, Q2 on sparseQ, sparseQ on Q1. Only the 5 s watchdog breaks it, by releasing A on the CPU before L2 has written it, which is an ordering violation as well as a hitch. With point 1 it can be permanent.Recording the rb / sparse-fence edges in the graph, or not taking the readback wait on a queue that has an armed bridged wait, would cover it.
3. Overlap with #708. #708 (open, retail-tested) converts the same waits, and #769 was closed today in its favour. This PR conflicts with #708 in
list_x.rsandreal.rs. Is the plan to rebase onto #708 and add the cycle graph and watchdog on top?AI-assisted (Claude Code), read-only review.
@woreksami on GitHub · 2026-11-24 08:19 UTC · original
A run where cross-queue
Wait64cycles were not caught at Signal time and ended in the 5 s watchdog, then no frames until the title's stall watchdog (#232). It may be the case upipibi's second point describes, though here no sparse-queue edge was needed: the cycles are direct, title queue to title queue.Setup
XCL_NETWORK=0,XCL_PSO_WAIT_MS=150,XCL_COMPUTE_PSO_WAIT_MS=500,XCL_PAGE_BUDGET_MB=3072main09940bb(so #795, #797, #866, #873, #897, #907 in) + #214, #267, #456, #468, #503, #533, #572, #640, #825, #850, #851, plus local changes (draws of a frame share one wait budget, empty texture-page pools released, a mid-list split takes a new PC list instead of a spare).What happened
… allocator resets so far with recordings still held or on the GPU – another PC allocator took its place (64 made …)).+0x23cf683, write at 0, as in #232).GPU queue.Wait … did not complete within 5000 ms … – released on CPU to prevent GPU hanglines, all within 96.2–96.8 s and all for the same value 0x5fa, withsubmitted=0x5fa, completed=0x5f9on the producer. Grouped by waiter ← producer: So q2 waits on each of q0, q1, q3, q4 at 0x5fa while each of them waits on q2 at 0x5fa: four two-queue cycles at one value. The lastwould close a GPU cycle – signalled on CPUline was at 91.8 s, so these were not broken at Signal time.96.246 GPU queue.Wait at 0x70416ab68 >= 0x5fa did not complete within 5000 ms (waiter=q0/ty2, prod=qSome(2)/tySome(0), recorded=0x5fa, submitted=0x5fa, completed=0x5f9)and96.800 … at 0x70416aaf0 >= 0x5fa (waiter=q2/ty0, prod=qSome(0)/tySome(2), …). Next to it:pending title ID3D12Fences during GPU wait timeout: 0x…(done=0x14/sig=0x19/wait=0x0,cell=true), …(done=0xc14/sig=0xc26, …).completedstayed one belowsubmittedon every producer for the whole 5 s, though.Not tested
AI use
@akimfomin on GitHub · 2026-11-24 15:19 UTC · original
Follow-up on upipibi's watchdog observation. I used PortBridge to compare queue synchronization work and isolated this case on XCL main
930e8b49.On Windows, a synthetic CPU check missed the notification in 3/3 trials when it arrived just before the worker waited. The positive control with the worker already waiting passed 3/3. Holding the existing wake mutex while notifying made both cases pass 3/3. The producer releases the synchronization-graph lock before reaching this code. The XCL library passed
cargo check.GPU and runtime integration still need the project's normal test path. Worker source · Rust Condvar. AI-assisted with Codex.