Skip to content

D3D12.X: a wait for a list not submitted yet waits on the GPU (#505) - #769

Closed
ezbyDev wants to merge 1 commit into
xcl-dev:mainfrom
ezbyDev:d3d12x/wait-for-later-writer
Closed

ezbyDev wants to merge 1 commit into
xcl-dev:mainfrom
ezbyDev:d3d12x/wait-for-later-writer

Conversation

@ezbyDev

@ezbyDev ezbyDev commented Nov 24, 2026

Copy link
Copy Markdown

A retail title submits a list whose Wait64BitValueX waits for a counter before the list, on another queue, that writes it – from one thread, and at times before that list is even recorded (@vibryxcx's trace in #505). XCL checked the wait on the CPU before submitting the waiting list, so the thread was held 2 s per wait and the writer was submitted only after the timeouts; the waiting lists ran without the value. Frames stopped and the title's watchdog ended it at +0x23cf683. Part of #505.

A wait that is not met when its list is submitted now becomes ID3D12CommandQueue::Wait on a fence of its own, as on the console, and the list goes to the GPU at once. The fence is signalled on the writer's queue right after the writer list is submitted. The writer is a list recorded already, or the first one recorded later that writes a value meeting the wait. A watcher thread signals the fence instead when the memory meets the wait (a CPU write) or after 10 s, and a writer list that is reset or released lets it go. With no queue or no fence, the wait stays a CPU wait as before.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: lists keep the values of their Write32/64BitValue…X until submitted (value_writes), later_writer, wait_before_submit (in execute_with_waits and KickoffX), the gates signalled in after_submit, the watcher (WATCHED), and two tests.
  • crates/xcl/src/hle/d3d12x/real.rs: execute_with_waits gets the queue.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Intel Core i7-9700K; Windows 11 Pro 26300; Rust 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.8.2502.11; debug for the tests, release for the title.
  • cargo test --workspace -- --test-threads=4 on 6c61607: 703 passed, 0 failed, 41 ignored, no SKIPPED (--no-fail-fast). An earlier run of the same commit failed placed_title_textures_share_vram_and_preserve_pixels (+2 follow-on) – the cubemap page-count flake that fails on main here too and that Tests: check cubemap tile reuse independently of idle page reclamation #447 fixes
  • New tests: a_later_writer_is_a_list_not_submitted_whose_value_meets_the_wait (the lookup) and a_wait_for_a_later_list_holds_the_gpu_not_the_submitting_thread (GPU: two queues; for a writer recorded before, recorded after the submit, released instead, and the CPU writing the counter, the submit returns at once, the waiting queue does not run before its writer, and goes on after it). With the GPU wait turned off the second fails (the submit waited 2.03 s on the CPU); without claiming a writer recorded later, its third round fails.
  • The retail title on this PC (interactive, XCL_NETWORK=0): with this change, Wait64BitValueX … waits on the GPU for list …, which writes it and is not submitted yet for the waits @vibryxcx traced (at 177 s and 230 s in two runs). One wait whose writer was not recorded yet still timed out on the CPU in those runs; the commit now covers it. The title still ends at +0x23cf683 in these runs: the frames stop before these waits, while compute pipelines are built (up to 116 s for one on this driver). This change removes one cause of the stall, not all of it.

Regression run

main:

PR:

Not tested

  • NVIDIA, Intel and RDNA2/3; a run that gets past the watchdog; whether the title reads anything wrong when a wait is let go after 10 s.
  • KickoffX with a gated wait is covered by the same functions but not by its own test.

AI use

  • Claude Code (Claude Opus 5.5): found the fix from @vibryxcx's trace, wrote the code, the tests and this description; the runs above were made on this PC.

🤖 Generated with Claude Code

…v#505)

A retail game submits a list with a Wait64BitValueX on a counter before
the list, on another queue, that writes the counter, from one thread -
at times before that list is even recorded. XCL evaluated the wait on
the CPU before submitting the waiting list, so the thread was held 2 s
per wait and the writer came only after the timeouts; the waiting lists
ran without the value. The title's frames stopped and its watchdog
ended it (+0x23cf683).

A wait that is not met when its list is submitted now becomes
ID3D12CommandQueue::Wait on a fence of its own. Lists remember the
values their Write32/64BitValue*X put at each address until they are
submitted; the list that writes the value - recorded already, or the
first one recorded later - signals the fence on its queue right after
its submission. A watcher thread signals it instead when the memory
meets the wait (a CPU write) or after 10 s, and a writer list that is
reset or released lets it go. Without a queue or a fence the wait stays
a CPU wait.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ezbyDev

ezbyDev commented Nov 24, 2026

Copy link
Copy Markdown
Author

Closing in favour of #708, which covers the same waits (a waiting list submitted before the list that writes its counter) and was opened first; I missed it when I searched. I'll test #708 on an RX 9060 XT (RDNA4) with the retail title and report there.

AI use: Claude Code (Claude Opus 5.5).

@ezbyDev ezbyDev closed this Nov 24, 2026
@itsd-effex

Copy link
Copy Markdown

Linux (Wine + vkd3d-proton) test of 6c61607: no Wait64BitValueX timeouts and no heartbeat abort. The run then ends the way vibryxcx's warm run in #505 did.

Tested

Compared with the same tree without this PR (same settings; one of the three with XCL_PSO_PRELOAD=0): three runs ended at the heartbeat abort (+0x23cf683, 226–269 s) after 16–40 Wait64BitValueX timed out after 2000 ms each. A fourth ended earlier, before the world, at an NVIDIA driver out-of-memory error.

With this PR

  • 0 timeouts. 8 waits logged waits on the GPU for list …, which writes it and is not submitted yet (220.2–221.7 s, want 0x7c6).
  • No heartbeat abort. World at 216.7 s (#101).
  • At 220–221 s the 1 ms compute limit skips a lot: dispatches skipped go from 1024 to 3384 and draws skipped to 512. From ~224 s there are 0 submits and 0 presents.
  • At 248 s: 0xc0000005 in game_scarlett_master.exe+0x5024b9b (read at address 0xffffffffffffffff), rax=0x3f19999a3f19999a, stack +0x4f414a5, +0x71bfd00, +0xa28c96, …. That's the same kind of read as vibryxcx's +0x4ddbfc4 after skipped dispatches in Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505.

Control run (the same, but XCL_COMPUTE_PSO_WAIT_MS=0: no compute skips), one run:

  • Still 0 Wait64BitValueX timeouts. 0 dispatches skipped. World at 187.2 s.
  • Title threads wait long for compute pipelines instead: waited 20.9 s for compute pipeline … (built in this thread), then 18.4, 11.0, 10.1 and 8.6 s.
  • One wait went to the GPU at 202.9 s (want 0x708, for list 0x5ab07c0). About 8–9 s later the kernel logged NVRM: Xid 109 … CTX SWITCH TIMEOUT for the process. XCL then reported D3D12 device removed: 0x887a0005 at 215.3 s, and the run ended there. The first run's 8 GPU waits caused no Xid, so I can't say this wait caused the timeout, only that a queue was in a GPU-side wait when it happened. I didn't log whether list 0x5ab07c0 had been submitted by then.

So on this card, after this PR, skipping compute leads to the 0xffffffffffffffff read, and waiting for it leads to multi-second stalls. In this one run there was also a GPU context-switch timeout while a GPU-side wait was pending.

Not tested: Windows. The default 4000 ms limits. More than one run of each. Whether the Xid repeats.

AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the suite and the runs, read the logs and drafted this comment. The runs are mine, on the hardware above.

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