Skip to content

D3D12.X: XCL_GPU_CULPRIT names the dispatches a stalled queue has not done - #1323

Open
IvyNotFound wants to merge 1 commit into
xcl-dev:mainfrom
IvyNotFound:gpu-culprit
Open

IvyNotFound wants to merge 1 commit into
xcl-dev:mainfrom
IvyNotFound:gpu-culprit

Conversation

@IvyNotFound

@IvyNotFound IvyNotFound commented Nov 24, 2026 •

Copy link
Copy Markdown

Diagnostics only, off by default. Part of #505.

When the GPU-wait watchdog releases a wait, its lines (and #1123's chain line) say which queues wait on which, but not what the GPU is running at that point. @larelgit measured the GPU at 100 % during these stalls on #505, so something executes and does not end. With XCL_GPU_CULPRIT=1, XCL marks every dispatch it records and logs, at the release, the dispatches that started and are not done, with their console compute shader.

How: around each dispatch the list writes a running number into a readback buffer with WriteBufferImmediate, MARKER_IN before and MARKER_OUT after, one pair of words per PC list. A list whose last number in is above its last number out has work that started and is not done. The dispatches between the two are logged with the console CS (fnv64 of the title's CS bytecode, the name of its file in dxil\translated), the PC pipeline and the groups. Once per burst of releases, 4 s apart, 8 times at most. DRED breadcrumbs would give the op in flight on a device removal. But with DRED on, the driver did not take its cached pipelines here: a 1.99 MB compute pipeline took 153 s to build, and the retail title never got past its start.

What is in it

  • crates/xcl/src/hle/d3d12x/culprit.rs (new):
    • enabled, note_compute;
    • before_dispatch / after_dispatch (the markers); slot_for gives each PC list a slot, and none once the buffer's 16 384 slots are taken (the list is then not recorded, so no slot past the buffer is ever read);
    • open_lists / not_done (what is in flight);
    • on_watchdog_release (the log).
    • Tests: a_list_with_a_marker_in_above_its_marker_out_is_open, a_list_past_the_last_slot_gets_none, and the GPU test gpu_markers_of_a_finished_list_match.
  • bind.rs: markers around Dispatch and around the ExecuteIndirect of a translated compute pipeline.
  • console_list.rs: markers around a console-recorded dispatch.
  • real.rs: CreateComputePipelineState notes the console CS of the pipeline it returns (the old body is now create_compute_pso, unchanged).
  • list_x.rs: the watchdog calls culprit::on_watchdog_release after its release lines.

Tested

Regression run

main:

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1361 (PresentX 1361)
presents per 2 s (last 3): 19 29 59
device removals: 0
crashes: 0
peak commit: 26024 MB

this PR:

xcl-smoke v1
commit: a79d09d3d74525238429f83853622795f764d2e9
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1332 (PresentX 1332)
presents per 2 s (last 3): 20 25 40
device removals: 0
crashes: 0
peak commit: 26020 MB

Not tested

  • AMD, Intel; Linux / vkd3d-proton (WriteBufferImmediate there)
  • draws: only dispatches are marked (the stalls seen so far end on compute queues)
  • the cost with the variable set on a title that dispatches much more than this one (two WriteBufferImmediate per dispatch)

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests and this description, and ran the tests and the runs above.

🤖 Generated with Claude Code

@Aniseto

Aniseto commented Nov 24, 2026

Copy link
Copy Markdown

Ran the new culprit module tests at 7fa2ade:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib culprit
2 passed; 0 failed; 0 ignored      (exit 0)

a_list_with_a_marker_in_above_its_marker_out_is_open and gpu_markers_of_a_finished_list_match pass. These are unit-level tests, so the adapter is not the variable; the datapoint is the Windows 11 build 26200 / MSVC 14.44.35207 / DXC 1.9.2609.5 toolchain.

Not tested: the diagnostic against a real stalled queue (no unpacked title here), RDNA2/RDNA4 and Intel GPUs, Wine, release profile.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.

@futurepro62

Copy link
Copy Markdown

Full-suite run on NVIDIA and AMD to go with the culprit check above. Tested exact head 7fa2ade (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: a_list_with_a_marker_in_above_its_marker_out_is_open, gpu_markers_of_a_finished_list_match.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 707-709 passed, 0 failed, 21 ignored.

Thanks!

@Mischief8713

Copy link
Copy Markdown

GPU run of 7fa2ade on Windows (NVIDIA GTX 1660 Ti, Turing): 709 passed, 0 failed

Tested

  • NVIDIA GeForce GTX 1660 Ti 6 GB (Turing, driver 32.0.16.2114), Ryzen 5 2600X, Windows 11 (10.0.26300), rustc 1.100.0, debug build
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64)
  • main at 930e8b4 on the same machine: lib 707 passed, 0 failed, 21 ignored; e2e 3 passed
  • The head contains current main.
  • lib: 709 passed, 0 failed, 21 ignored. hle::d3d12x::culprit::tests::gpu_markers_of_a_finished_list_match and a_list_with_a_marker_in_above_its_marker_out_is_open ran and passed. Earlier reports on this PR are Blackwell only, so this adds Turing.

Not tested

  • No retail title and no scripts/smoke.ps1 run, so no regression run
  • AMD GPUs; only Turing was run here
  • A real stalled queue with XCL_GPU_CULPRIT set was not exercised, since that needs a title

AI use

  • Claude Code with Claude Sonnet 5.5 ran the commands and wrote this report. I checked the output.

@crosettiremi

crosettiremi commented Nov 24, 2026 •

Copy link
Copy Markdown

I exercised the dispatch marker fixture on Windows with an RX 7900 XT on a downstream XCL stack carrying 7fa2ade. The readback buffer was created and the completed list's marker-in and marker-out fixture passed.

I also tested bounded slot registration locally. At capacity, existing lists keep their slot and a new list receives no slot. This keeps the slot registry consistent with the readback buffer's capacity when later diagnostics enumerate it. The focused module with that additional check passed all three tests and the release build completed. The game runs that motivated this check reported a partly executed command list with Dispatch next in DRED. I haven't attributed those hangs to a specific shader.

Hardware follow-up with the markers enabled and the same saved profile: the log confirmed marker initialization. The game was still presenting in the 116.1 s sample and then terminated on the title's write to zero at +0x23cf683. No device removal or watchdog-release marker report was recorded in this run, so it did not identify a stalled dispatch.

lukastaro added a commit to lukastaro/xcl that referenced this pull request Nov 24, 2026
The console runs up to 2^32 - 1 thread groups a dimension; D3D12 takes
65 535, and past that a dispatch is undefined. On an NVIDIA RTX 5060 Ti a
retail game's world loading hung the GPU (DXGI_ERROR_DEVICE_HUNG,
0x887A0006) about 100 s in, every run: the only unfinished work was an
ExecuteIndirect of one loop-free compute program (found with the dispatch
markers of xcl-dev#1323), and its arguments, written by an earlier dispatch, were
72 512 x 1 x 1 and 75 072 x 1 x 1 groups.

A dispatch of more than 65 535 groups in X with 1 in Y now runs as
65 535 x ceil(n / 65 535) groups. The console's count goes into a new io
word (IO_GROUP_LIMIT, in the trap-temp range like IO_UMA_BASE_HI; 0 when
not folded), and every translated compute program takes
gid.x + gid.y * 65 535 as its group in X when the word is set, its Y as 0,
and returns at once in the groups at or past the count. A dispatch that
cannot be folded (two dimensions past the limit) is clamped and logged.

- Dispatch and console-recorded dispatches: the counts are known on the CPU
  (bind::fold, also in console_list).
- ExecuteIndirect of one dispatch: the counts are only on the GPU. A
  one-thread pass (clamp.rs) reads them, writes the counts to dispatch into
  a slot of XCL's buffer and the console's count into the dispatch's io
  (folding only when the rows stay within 65 535, as bind::fold does),
  then the dispatch reads its arguments from the slot. bind_abi now returns
  what it bound so the binding can be set again after the pass.

The translated compute HLSL changes (a few lines in the prelude), so
cached translations and DXIL of compute programs are made again once.

New tests: a folded dispatch runs each console group once and none past
its count (GPU; fails without the change from group 65 535 on), the
indirect pass folds / clamps / leaves counts as they are (GPU), and the
folding rule (unit). runner::device() gives tests the runner's device: a
test making its own device first left the Agility SDK unappliable and the
GPU tests after it skipped.

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

When the GPU-wait watchdog releases a wait (xcl-dev#505), its lines say which
queues wait on which, but not what the GPU is running. With
XCL_GPU_CULPRIT=1 every dispatch XCL records (title lists,
console-recorded lists, ExecuteIndirect of a translated compute
pipeline) is wrapped in WriteBufferImmediate markers, in before and out
after, one pair of words per PC list in a readback buffer. At a release
the lists whose marker in is above their marker out are logged with the
dispatches between the two: console CS (fnv64 of the title's bytecode),
PC pipeline and groups.

On the retail title of xcl-dev#505 (RTX 5080) this named, at each stall, one
list with a run of 1-D dispatches of one CS whose first never finished;
not the same CS from run to run. DRED breadcrumbs were tried first: they
change the driver's pipeline cache keys, so every pipeline was built
again and the title never got past its start.

Off by default; without the variable nothing is recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukastaro added a commit to lukastaro/xcl that referenced this pull request Nov 24, 2026
The console runs up to 2^32 - 1 thread groups a dimension; D3D12 takes
65 535, and past that a dispatch is undefined. On an NVIDIA RTX 5060 Ti a
retail game's world loading hung the GPU (DXGI_ERROR_DEVICE_HUNG,
0x887A0006) about 100 s in, every run: the only unfinished work was an
ExecuteIndirect of one loop-free compute program (found with the dispatch
markers of xcl-dev#1323), and its arguments, written by an earlier dispatch, were
72 512 x 1 x 1 and 75 072 x 1 x 1 groups.

A dispatch of more than 65 535 groups in X with 1 in Y now runs as
65 535 x ceil(n / 65 535) groups. The console's count goes into a new io
word (IO_GROUP_LIMIT, in the trap-temp range like IO_UMA_BASE_HI; 0 when
not folded), and every translated compute program takes
gid.x + gid.y * 65 535 as its group in X when the word is set, its Y as 0,
and returns at once in the groups at or past the count. A dispatch that
cannot be folded (two dimensions past the limit) is clamped and logged.

- Dispatch and console-recorded dispatches: the counts are known on the CPU
  (bind::fold, also in console_list).
- ExecuteIndirect of one dispatch: the counts are only on the GPU. A
  one-thread pass (clamp.rs) reads them, writes the counts to dispatch into
  a slot of XCL's buffer and the console's count into the dispatch's io
  (folding only when the rows stay within 65 535, as bind::fold does),
  then the dispatch reads its arguments from the slot. bind_abi now returns
  what it bound so the binding can be set again after the pass.

The translated compute HLSL changes (a few lines in the prelude), so
cached translations and DXIL of compute programs are made again once.

New tests: a folded dispatch runs each console group once and none past
its count (GPU; fails without the change from group 65 535 on), the
indirect pass folds / clamps / leaves counts as they are (GPU), and the
folding rule (unit). runner::device() gives tests the runner's device: a
test making its own device first left the Agility SDK unappliable and the
GPU tests after it skipped.

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

Copy link
Copy Markdown
Author

Thanks @crosettiremi, you were right about the slot bound: once the 16 384 slots were taken, a new list was still put in the map with a slot past the buffer, and the next watchdog report would have read it. Fixed in a79d09d (squashed into the PR's commit, rebased onto main 9e3831e): slot_for gives a new list no slot when the buffer is full and leaves it out of the map, and the lists that have one keep it. Test a_list_past_the_last_slot_gets_none.

At a79d09d on an RTX 5080: cargo test --workspace --no-fail-fast -- --test-threads=4 779 passed, 0 failed, 41 ignored; the new runs are in the description.

AI use: Claude Code (Claude Opus 5.5) wrote the fix, the test and this reply, and ran the tests and the runs.

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
lukastaro added a commit to lukastaro/xcl that referenced this pull request Nov 24, 2026
The console runs up to 2^32 - 1 thread groups a dimension; D3D12 takes
65 535, and past that a dispatch is undefined. On an NVIDIA RTX 5060 Ti a
retail game's world loading hung the GPU (DXGI_ERROR_DEVICE_HUNG,
0x887A0006) about 100 s in, every run: the only unfinished work was an
ExecuteIndirect of one loop-free compute program (found with the dispatch
markers of xcl-dev#1323), and its arguments, written by an earlier dispatch, were
72 512 x 1 x 1 and 75 072 x 1 x 1 groups.

A dispatch of more than 65 535 groups in X with 1 in Y now runs as
65 535 x ceil(n / 65 535) groups. The console's count goes into a new io
word (IO_GROUP_LIMIT, in the trap-temp range like IO_UMA_BASE_HI; 0 when
not folded), and every translated compute program takes
gid.x + gid.y * 65 535 as its group in X when the word is set, its Y as 0,
and returns at once in the groups at or past the count. A dispatch that
cannot be folded (two dimensions past the limit) is clamped and logged.

- Dispatch and console-recorded dispatches: the counts are known on the CPU
  (bind::fold, also in console_list).
- ExecuteIndirect of one dispatch: the counts are only on the GPU. A
  one-thread pass (clamp.rs) reads them, writes the counts to dispatch into
  a slot of XCL's buffer and the console's count into the dispatch's io
  (folding only when the rows stay within 65 535, as bind::fold does),
  then the dispatch reads its arguments from the slot. bind_abi now returns
  what it bound so the binding can be set again after the pass.

The translated compute HLSL changes (a few lines in the prelude), so
cached translations and DXIL of compute programs are made again once.

New tests: a folded dispatch runs each console group once and none past
its count (GPU; fails without the change from group 65 535 on), the
indirect pass folds / clamps / leaves counts as they are (GPU), and the
folding rule (unit). runner::device() gives tests the runner's device: a
test making its own device first left the Agility SDK unappliable and the
GPU tests after it skipped.

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

not-rex commented Nov 24, 2026

Copy link
Copy Markdown

RTX 3080 (10 GB, driver 610.88), retail 1.0.2.1 into the world with XCL_GPU_CULPRIT=1: one stalled dispatch named, an indirect CS.

Tested: this PR at a79d09d3 merged onto 9e3831e1 + #1123 + #1254 (diagnostics), release, warm DXIL cache and save, XCL_PSO_WAIT_MS=50, A at 30 and 40 s, 400 s.

  • #101 at 87.8 s, 28 presents after it (last at 126.1 s), 12 GPU queue.Wait … 5000 ms timeouts (first at 130.7 s), 10 cycle breaks; the title's watchdog (+0x23cf683) at 178.4 s; peak commit 32.6 GB.
  • The culprit line came once, at the first release (130.7 s): "1 of 269 lists have dispatches started and not done: list 0x15e270a1a0: marker in #19676, last marker out #19675". The one dispatch is cs 18567a5f0145bde9, indirect, up to 1 dispatch.
  • It is not one of the sky ray-march programs named on Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 (50625695d2e6cbe7, 206ed63b96be21a1); neither hash appears in this run's log.
  • The 11 later releases printed no culprit line. I don't know whether that's the PR's rate limit or nothing new being in flight; a line per release (or a "same as before" line) would make that clear.

On this card the stall also goes away when split-wave64 compute and mesh programs are refused (#505, comment 7142113187), so 18567a5f0145bde9 is likely a split-wave64 program, though I haven't confirmed that from its code.

Not tested: more than one run; without XCL_PSO_WAIT_MS.

AI use: Claude Code (Claude Opus 5.5) ran the run on my machine through a scripted runner and wrote this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants