Skip to content

D3D12.X: a wait an earlier signal covers does not make a signal a cycle - #2052

Draft
nicolasabosch wants to merge 1 commit into
xcl-dev:mainfrom
nicolasabosch:d3d12x/false-gpu-cycle
Draft

nicolasabosch wants to merge 1 commit into
xcl-dev:mainfrom
nicolasabosch:d3d12x/false-gpu-cycle

Conversation

@nicolasabosch

Copy link
Copy Markdown

would_signal_close_cycle took every armed wait on the target cell with val <= sig_val as one that waits on the new Write64 signal. A wait that an earlier signal of the same cell already satisfies (submitted on the GPU, or released on the CPU) does not depend on the new one. With pipelined frames (queue A waits on cell X >= N; queue B then signals X = N + 1 after waiting on something A signals later), every such frame was reported as a cycle. The signal then went out on the CPU, and its waiters were released before the GPU work they wait for had run.

Found while working on #1269 (a retail title on an RTX 4070 Laptop). A local trace of the world load showed queue 1 waiting on a cell >= 0x6db, a wait already covered by queue 2's earlier 0x6db signal. That wait was counted against queue 2's 0x6dc signal, and the "cycle" was broken on the CPU. Each run of that load broke 14–32 such cycles.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: the target waiters are only the armed waits no earlier signal covers (val > max(submitted_max, cpu_signaled_max)).
  • Same file, test pipelined_next_frame_write_is_not_false_cycle: case 3 reproduces the traced case (no cycle), then turns the wait into one that only the new signal satisfies (a true cycle, still detected). Without the fix, the new no-cycle assertion fails.

Tested

  • NVIDIA GeForce RTX 4070 Laptop GPU (driver 32.0.16.2124), Intel Core i9-14900HX, Windows 11 build 26300, rustc 1.100.0; debug for the suite, release for the smoke runs.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on b67c8f0: 1120 passed, 0 failed, 46 ignored. SKIPPED: 20 × no wave64, 3 × refused (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics), 1 × no heap windows.
  • The new assertion fails with the fix reverted (checked on an earlier base with the same code).
  • Retail title ([OFFICIAL] Looking for PRs with shaders optimization #1269): in two world-load runs of a local build with this fix, there were no cycle breaks. The same load broke 14–32 per run without it. That local build also carries other experiments (read-select windows, a per-frame pipeline wait cap, and the same rule for title ID3D12Fence waits in break_cycles_before_title_signal, which is not in this PR). The title still loses the device later in that load, so this fix alone does not get it further.

Regression run

main:

xcl-smoke v1
commit: 00cf2589f26b0e357852ec943da36f0bbe540ff9
gpu: NVIDIA GeForce RTX 4070 Laptop GPU
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1489)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16515 MB

PR:

xcl-smoke v1
commit: b67c8f0cb5a68434c1a511c848fb53164f44f0bc
gpu: NVIDIA GeForce RTX 4070 Laptop GPU
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15915 MB

Not tested

  • AMD and Intel GPUs.
  • The 60 s smoke runs stay in the title's menus and do not reach the multi-queue world load where the false cycles happened. That load was only checked with the local build described above.
  • Title ID3D12Fence waits (break_cycles_before_title_signal) have the same pattern. They are left for a separate PR with a test of their own.

AI use

  • Claude Code with Claude Opus 5.5: traced the cycle breaks in the title's log, wrote the fix, the test, the commit message and this description, and ran the tests and smoke runs above.

🤖 Generated with Claude Code

`would_signal_close_cycle` took every armed wait on the target cell with
`val <= sig_val` as waiting on the new signal. A wait that an earlier
signal of the cell already satisfies (submitted on the GPU or released on
the CPU) does not depend on it. With pipelined frames – queue A waits on
cell X >= N, queue B then signals X = N + 1 after waiting on something A
signals later – every such frame was reported as a cycle, signalled on
the CPU and its waiters released before the GPU work they wait for ran.

A retail title on an RTX 4070 Laptop broke 14-32 such "cycles" in each
run's world load (traced: queue 1 waiting on 0x...fde0 >= 0x6db, covered
by queue 2's earlier 0x6db signal, counted against queue 2's 0x6dc
signal). With the fix: no cycle break in two runs of the same load.

The waiters taken now are those no earlier signal covers
(`val > max(submitted_max, cpu_signaled_max)`); a test reproduces the
traced case and keeps the true cycle detected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raylitebull

Copy link
Copy Markdown
Member

Code review on b67c8f0:

  • Filtering armed_waits in would_signal_close_cycle (crates/xcl/src/hle/d3d12x/list_x.rs) with aw.val > target.submitted_max.max(target.cpu_signaled_max) cleanly stops pipelined next-frame signals from looking like cycles when an earlier GPU or CPU signal already covers the armed wait value.
  • Both new cases in the sync-graph test pin the covered next-frame signal vs true cycle boundary cleanly.
  • Diff audited and CI workflow approved (PR description is green; awaiting Build and test + dual-vendor verification + marking ready for review).

theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
…al a cycle"

Local test only (the upstream PR is a draft, xcl-dev#2052). On this title the change left a real
multi-queue wait cycle: at 111 s of the world load all five queues waited on each other for
values one past their completed ones, the watchdog released 102 GPU waits and the title froze.
The cycle breaks logged before the change had been the false positives it meant to avoid; the
true ones it no longer breaks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants