D3D12.X: a wait for a list not submitted yet waits on the GPU (#505) #769
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!769
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/769/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?
@ezbyDev on GitHub · 2026-11-24 05:01 UTC · original
ezbyDev:d3d12x/wait-for-later-writer→main· +382 −15 · 2 files · 1 commits · closed without mergingA retail title submits a list whose
Wait64BitValueXwaits 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::Waiton 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 theirWrite32/64BitValue…Xuntil submitted (value_writes),later_writer,wait_before_submit(inexecute_with_waitsandKickoffX), the gates signalled inafter_submit, the watcher (WATCHED), and two tests.crates/xcl/src/hle/d3d12x/real.rs:execute_with_waitsgets the queue.Tested
cargo test --workspace -- --test-threads=4on6c61607: 703 passed, 0 failed, 41 ignored, no SKIPPED (--no-fail-fast). An earlier run of the same commit failedplaced_title_textures_share_vram_and_preserve_pixels(+2 follow-on) – the cubemap page-count flake that fails onmainhere too and that #447 fixesa_later_writer_is_a_list_not_submitted_whose_value_meets_the_wait(the lookup) anda_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.XCL_NETWORK=0): with this change,Wait64BitValueX … waits on the GPU for list …, which writes it and is not submitted yetfor 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+0x23cf683in 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
KickoffXwith a gated wait is covered by the same functions but not by its own test.AI use
🤖 Generated with Claude Code
@ezbyDev on GitHub · 2026-11-24 05:15 UTC · original
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).
@itsd-effex on GitHub · 2026-11-24 05:17 UTC · original
Linux (Wine + vkd3d-proton) test of
6c61607: noWait64BitValueXtimeouts and no heartbeat abort. The run then ends the way vibryxcx's warm run in #505 did.Tested
master30b0eb9bwith the #257 kit's patch. Release, cross-compiled with cargo-xwin.mainf4ce27c+ #684 + #273 + #533 + #267 (merged locally as in my #505 comment), then this PR:084b291, which merged without conflicts.a_wait_for_a_later_list_holds_the_gpu_not_the_submitting_thread.XCL_PRESS_A_AT),XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=1 XCL_COMPUTE_PSO_WAIT_MS=1, caches warm (#690 preload of 1221 shader sets, 121 driver blobs reused). One run.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–40Wait64BitValueX timed out after 2000 mseach. A fourth ended earlier, before the world, at an NVIDIA driver out-of-memory error.With this PR
waits on the GPU for list …, which writes it and is not submitted yet(220.2–221.7 s,want 0x7c6).#101).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+0x4ddbfc4after skipped dispatches in #505.Control run (the same, but
XCL_COMPUTE_PSO_WAIT_MS=0: no compute skips), one run:Wait64BitValueXtimeouts. 0 dispatches skipped. World at 187.2 s.waited 20.9 s for compute pipeline … (built in this thread), then 18.4, 11.0, 10.1 and 8.6 s.want 0x708, for list0x5ab07c0). About 8–9 s later the kernel loggedNVRM: Xid 109 … CTX SWITCH TIMEOUTfor the process. XCL then reportedD3D12 device removed: 0x887a0005at 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 list0x5ab07c0had been submitted by then.So on this card, after this PR, skipping compute leads to the
0xffffffffffffffffread, 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.
Pull request closed