Skip to content

D3D12.X: use whole form once ready for split ExecuteIndirect - #3528

Merged
throny merged 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/3499-indirect-use-whole-when-ready
Dec 2, 2026
Merged

throny merged 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/3499-indirect-use-whole-when-ready

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What is in it

Fixes the 2–3× world frame-rate regression introduced by #3499 (c9aa9f8a2), bisected and diagnosed by @throny, @tiagonleal, @CharlyRien, and @bmjask.

  • Root cause: dispatch_chain::execute_indirect always routed Dispatch-only ExecuteIndirect calls of split compute PSOs through the split chain — claiming the split scratch budget (256 MiB), running the slicer dispatch, and recording XCL_SPLIT_INDIRECT_ROUNDS (default 16) rounds of every piece plus UAV barriers — even after the background whole form (chain.whole) had finished building.
  • Fix:
    • In dispatch_chain::execute_indirect, return Ok(Indirect::Whole) once chain.whole.ready() is Some(Ok(_)) so bind.rs issues a single whole-form ExecuteIndirect without claiming split scratch or recording multi-round piece chains.
    • Re-check chain.whole.ready() immediately before recording the split chain so a background build that completes during setup hands off cleanly instead of recording a redundant split chain.
    • Keep the split chain path while chain.whole is still pending (None) or refused by the driver (Some(Err(_))), preserving D3D12.X: indirect dispatches of a split program run its direct pieces #3499's cold-build and zero-indirect-variant behavior, and update queue_whole's refusal warning to match.
    • Remove the now-unused pso::dispatch_command_signature helper and tail-signature recording path.
  • Measured performance:
    • 60 s title smoke (RTX 5070 Ti, 8b9d8dfe4 vs main 1c8b55147): 1699 frames shown vs 1387 (+22.5%), 60 60 60 presents per 2 s, 0 device removals, 0 crashes, 18164 MB vs 17480 MB peak commit (+3.9%).
    • In-world merge-checks on the same handoff (49eb78ef): @throny measured 2.49–2.73 presents/s vs 0.77 presents/s on main (3.2–3.5× recovery, restoring pre-D3D12.X: indirect dispatches of a split program run its direct pieces #3499 2.15–2.30 presents/s) on RTX 4080 16 GB (600–900 s runs).
  • Rebased onto main (1c8b55147) and updated per @Foniass's review:
    • Dropped creation-time prefetch_whole in dispatch_chain::build so this PR stays focused on the execute_indirect handoff and cannot starve split-chain compilation with eager whole-form builds.
    • Removed the dead pso::dispatch_command_signature helper (0 new compiler warnings).
    • Narrowed the ready() race window before chain recording (if the whole form completes after the re-check, that single dispatch still runs the chain as on main) and updated the queue_whole refusal log message.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5 (debug + release).
  • scripts/test.ps1 (cargo build --workspace, cargo bench -p xcl --bench '*' -- --test, cargo test --workspace -- --test-threads=4): 2910 passed, 0 failed, 51 ignored across all 43 test targets (24 SKIPPED GPU tests on this adapter: 22 no wave64, 2 no heap windows).
  • dispatch_chain::tests (17/17 passed), including indirect_prefers_whole_only_once_built_ok (pending / OOM retry / built Ok / driver-refused Err) and an_indirect_dispatch_runs_its_chain_without_any_whole_form (transition from Indirect::Ran while building to Indirect::Whole without binding the split chain or running the slicer once chain.whole is Ok).
  • cargo build --release -p xcl: clean (0 new warnings vs main).

Regression run

Baseline (main):

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1387 (PresentX 1387)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17480 MB

PR head:

xcl-smoke v1
commit: 8b9d8dfe4c7a0a6d56ff94d7f2d9b25988f8dff3
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1699 (PresentX 1699)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18164 MB

Not tested

  • Non-NVIDIA (AMD / Intel) GPUs and native wave64 hardware paths (22 wave64 GPU tests skipped on RTX 5070 Ti).
  • Opt-in XCL_HEAP_WINDOWS=1 GPU tests (2 skipped under default scripts/test.ps1).
  • Re-running the multi-minute in-world frame-rate checks after removing prefetch_whole (prior merge-checks verified the execute_indirect handoff itself; only the 60 s title smoke was re-run on 8b9d8dfe4).

AI use

  • Antigravity (Gemini 4 Neon) assisted with rebasing onto main, addressing the review items, running the workspace tests and smoke pair, and updating this description; initial PR draft was assisted by Antigravity (Claude Opus 5.5). Note: the commit trailer on 8b9d8dfe4 carried Gemini 3.1 Pro from an earlier template, while the actual rebase/verification was done with Gemini 4 Neon (leaving the commit SHA untouched to preserve the three merge-checks).

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) labels Nov 30, 2026
@tiagonleal

tiagonleal commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: 49eb78e
merge: clean (the head is on the current main, so the merge is the head itself)
build: cargo build --workspace -> ok (also cargo build --release -p xcl)
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on this base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). Both changed tests pass and the GPU one ran on this card. With only the early return in execute_indirect turned off (if false && indirect_prefers_whole(...)), an_indirect_dispatch_runs_its_chain_without_any_whole_form fails ("whole-ready indirect dispatch must not bind the split chain"), so it tests the change. indirect_prefers_whole_only_once_built_ok tests the helper only and passes either way.
review: whole diff read (+46/-24, real/dispatch_chain.rs). Once chain.whole.ready() is Some(Ok(_)), execute_indirect returns Indirect::Whole before claiming scratch or building commands. bind.rs then takes the same whole_ready -> Whole::Ready path as before #3499, binds the whole form and issues one ExecuteIndirect. WholeBuild keeps an Ok result for good, so the second check in whole_ready cannot see anything else (no race between the two reads). While the whole form is building (None) or the driver refused it (Some(Err)), the chain runs as in #3499 and the build is queued. The tail ExecuteIndirect that #3499 recorded for groups past the slicer's rounds is gone. It only ran when the whole form was ready, and that case now leaves at the first check. Edit after the review by Zippp69: there is one window left. If the build finishes between the first ready() (line 602) and the recording, the chain is still recorded, now without the tail, so a dispatch with more groups than the rounds cover is left out for that one call. That is what already happens to such a dispatch while the whole form is building or refused, before and after this PR, so I do not see it as a blocker; returning Indirect::Whole at the second check (line 614) when it sees Some(Ok(_)) would close it. The "whose whole form is still being built skipped" warning is not brought back for Dispatch-only commands: it stays only on the Whole paths it had before (multi-command or count-buffer signatures, no chain scratch). The early queue_whole in build goes through whole_sent, so the whole form is queued once per chain. It runs on the single xcl-pso-whole worker, holds no lock past the CHAINS insert, and adds whole-form compiles at load time for programs listed in used-indirect-split.txt (the journal note_indirect_use fills; read once at start from the DXIL cache directory). World entry did not move in our runs (below). Two notes, neither a blocker. (1) The refused-build warning in queue_whole still says "its indirect dispatches stay left out", but they now run the chain. (2) The log does not count how many indirect dispatches took the whole form or the chain. A counter in the compute split: line would make this checkable in the field.
performance: scripts/smoke.ps1, 60 s of a retail title, release, after one warm-up run of the base: 1671 frames, 18966 MB peak commit against 1652 frames, 18909 MB on the base (warm-up: 1665, 18646 MB). No device removal, no crash. World runs, release, warm caches, 16 UMA windows, the same 330 s plan with scripted presses and the RAM guard, interleaved base, PR, base, PR. Presents per second are measured from 30 s after world entry to the end. Base: 0.61 and 0.63 (214-215 s windows, world entry 86-88 s; compute split: 89-95k chained dispatches in 221-260k slabs, scratch 561-613 MiB). PR: 1.37 and 1.41 (214-217 s windows, world entry 84-88 s; 224-229k chained dispatches in 281-284k slabs, scratch 334-348 MiB). That is 2.2x the base. It matches #3499 reverted on the same base earlier today (1.43, 1.33), and the two pairs agree within 0.04. No "skipped" lines, no device removal. Min free RAM 1.22-2.25 GB, peak commit 39.7-39.9 GB against 41.2-41.7 GB on the base. One PR run was cut at 132 s (48 s of world) by a driver timeout (nvlddmkm 153 at 15:12:10; the log ends with no removal line); its retry ran the full 330 s. Plain main had 2 such timeouts in 9 runs of this recipe on this PC today, so one timeout says nothing about this PR. The world frames show the same lit interior, and nothing looks missing or broken. The late frames of the PR runs are darker (7-10 % lit pixels against 38-100 % on the base), but two runs of the revert already differ (20 % and 42 %), and the frames come from different moments of the scene, so I cannot read a rendering change into it.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, tests, smoke and world runs, reviewed the diff against the merged source and wrote this)

  • Tiago

@CharlyRien

CharlyRien commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: 49eb78e
merge: clean (the head's parent is main 9dfbe3e, so git merge --no-edit is a fast-forward and the merged tree is the head itself; git diff --check 9dfbe3ea..HEAD clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (debug, on the merged tree) -> 2883 passed, 4 failed, 51 ignored; SKIPPED: 25 (22 "no wave64" (this card has no wave64), 2 "no heap windows" (opt-in), 1 "no GPU_UPLOAD heaps"); failing: gpu_direct_image_get_resinfo_d16, test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred fail on base 9dfbe3e alone too (the same suite run there: 2883 passed, 3 failed). test_title_runs_and_game_folder_is_untouched failed once in the merged debug suite only ([FAIL] ... a texture in title memory (XG layout, #44) follows CPU writes: subresource 2 row 0 differs); rerun alone in release 3 times on each side after cargo build --workspace --release, it passed 3 of 3 on the merged tree and 3 of 3 on base, so I read it as flaky and unrelated to dispatch_chain.rs. The PR's module tests in release on the GPU (dispatch_chain::tests + bind.rs's ExecuteIndirect test, GPU skips not allowed): 17 passed, 0 failed, including indirect_prefers_whole_only_once_built_ok.
review: no blocking finding after reading the whole diff (1 commit, dispatch_chain.rs +46/-24). What I checked:

  • Once chain.whole.ready() is Some(Ok), execute_indirect now returns Indirect::Whole before claiming any split scratch, so bind.rs falls through to whole_ready, which hands back the cached whole form without waiting. This is what ran for these dispatches before D3D12.X: indirect dispatches of a split program run its direct pieces #3499.
  • The removed tail path (the whole form running the slicer's whole-form command) ran only in that Some(Ok) case, so nothing is lost. While the whole form is still building (None) or was refused (Some(Err)), the behaviour is unchanged: same chain, same queue_whole when None, and a dispatch too large for the rounds is still left out.
  • note_indirect_use still runs before the early return, so the journal stays complete.
  • The new queue_whole in build (records already in used-indirect-split.txt) moves the whole-form compile from the first indirect dispatch to pipeline creation, on the same single xcl-pso-whole worker, guarded by whole_sent. Unlike whole_ready, it does not check pso_async::cs_goes_on(). If that is off, a later synchronous whole(true) only waits on the same WholeBuild lock, so I do not count it as a bug. A record that is journaled but never dispatched in a run now pays one whole-form compile.
  • The updated GPU test now covers the change of path, from Ran while building to Whole with no split bind once the whole form is built. The new pure test covers pending, OOM retry, built and refused.
    Not covered here: AMD / Intel, the Series X profile, and the PR alone on plain main in the world (see performance).
    performance: by default it should give back the frame time D3D12.X: indirect dispatches of a split program run its direct pieces #3499 took once each whole form is built, plus an earlier whole-form compile on warm runs.
    Measured, 60 s scripts/smoke.ps1, one run per side, the retail title, XCL_PREPARE=0, cold shader cache on both sides (no used-indirect-split.txt, so only the cold path runs): base 9dfbe3e 561 frames, peak commit 15813 MB; merged 559 frames, peak commit 15702 MB (-111 MB). 0 device removals and 0 crashes on both sides. These 60 s do not reach the world on this machine.
    World frame rate, one run with the PR's commit, on a local tree: main d52ff48 (already contains D3D12.X: indirect dispatches of a split program run its direct pieces #3499) + 42 local commits of ours (none in dispatch_chain.rs or bind.rs; same translator id with and without the PR), the same warm shader cache with the journal, the same switches (XCL_PREPARE=0 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_HUGE_PSO_CONCURRENCY=8 XCL_HUGE_PSO_WANTED_CONCURRENCY=8 XCL_PSO_WAIT_MS=5000 XCL_ALIAS_COPY=1 XCL_PLACE_RETIRE=0 XCL_VIEW_REACH_MB=36 XCL_TWO_PASS_MB=2048 XCL_DEPTH_UAV_TWIN=1 XCL_OUTSIDE_ONLY_BYTES=0x3200000,0x1900000 XCL_OUTSIDE_VIEW_USE=1 XCL_PAIR_PAGES=1 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=45000). Presents/s over world + 20..180 s:
  • that tree without the PR: 0.18;
  • with XCL_SPLIT_INDIRECT_ROUNDS=1: 0.26;
  • with this PR: 0.19;
  • the same stack on main 53e85fb, before D3D12.X: indirect dispatches of a split program run its direct pieces #3499: 0.51.
    0 removals, 0 TDR. So no world gain measured on this tree: the log does not say whether the whole forms were built during the window, so this may only mean the new path was not taken here; the other reports on D3D12.X: indirect dispatches of a split program run its direct pieces #3499 / here measured a gain on plain main. One run per setting, so treat differences under ~10 % as noise.
    verdict: safe to merge
    hardware / tool and model: NVIDIA GeForce RTX 3090 (driver 616.56), AMD Ryzen 9 5950X, Windows 11 build 22631 / AI use: Claude Code (Claude Opus 5.5) ran the merge, the builds, the suite, both smoke runs and the world run on this machine, read the diff and wrote this report; checked and posted by me.

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 30, 2026
@minimalhipster990

minimalhipster990 commented Nov 30, 2026 •

Copy link
Copy Markdown

Correction, December 1. On this RTX 4090, 49eb78e reduced the split work from #3499 and the world remained near 0.2 frames/s. I previously attributed that remaining cost to #2571 alone. Our fast-to-slow comparison spans four changes, and the exact pre-#2571 control hung before world entry. Corrected bisection and measurements.

Setup: RTX 4090 24 GB, NVIDIA 621.40, 32 GB RAM, Windows 11 build 26300, NVIDIA shader heap 2048 MB (#2590). d52ff48c + #3318 f5496479 (without it this card does not reach the world), with and without 49eb78e cherry-picked (clean), release. Retail title, the same save and inputs, 600 s, warm XCL cache, the switches listed on #2571.

tree frames/s, 300–540 s split slabs per present
3a8745dc (before #3499) 2.13 · 3.08 · 3.08 · 3.22 · 3.17 ~985
c9aa9f8a (#3499) 0.73 · 0.75 · 0.75 · 0.72 · 0.63 ~2,900
d52ff48c 0.17–0.22 (2 runs) ~1,900
d52ff48c + 49eb78e 0.18 · 0.20 · 0.22 · 0.22 · 0.23 ~1,170
  • My bisection of main's merges agrees with throny's: 3a8745dc good, c9aa9f8a bad.
  • No device removal or crash in either run.

Not tested: this commit on c9aa9f8a (before #2571), which would show whether it recovers the full ~3.1 frames/s here, and the PR head on top of 9dfbe3ea.

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the replays and wrote this. The person running these tests checked it and asked for it to be posted.

December 1 correction drafted with Codex (GPT-6) after checking the Git ancestry and replay logs.

@Zippp69 Zippp69 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Recheck whole-form readiness before recording the split chain

If the background build completes between the two chain.whole.ready() calls in execute_indirect, the second check sees Some(Ok(_)) but still records the split chain. For a dispatch that exceeds the slicer’s round budget, the split commands do no work. Before this PR, a successful build observed at this point let the tail command execute that dispatch.

Keep the fast path and replace the second check with:

match chain.whole.ready() {
    Some(Ok(_)) => return Ok(Indirect::Whole),
    None => { queue_whole(&chain); }
    Some(Err(_)) => {}
}

I checked that the patch applies to 49eb78e. In an isolated Rust harness, the completed-build case failed before the change. All three cases (completed, pending, and refused) passed afterward. The XCL suite and GPU tests were not run.

Codex assisted with the review, patch, and isolated tests.

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 30, 2026
@throny

throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

@Kalmarv a run of this PR on the RTX 4080 16 GB (621.40), i9-12900K, release, main 9dfbe3ea + 49eb78ef + a local input-timing patch for the run script, the switches of my #3499 comment, 600 to 900 s per run:

build runs presents/s from 240 s device removal
main 9dfbe3ea 2 0.77; 0.00 (no present after 240 s) none
+ this PR 4 2.73, 2.49; two runs ended early 2 of 4: 0x887a0006 (hung) at 141 s and 151 s, DRED page fault at VA 0, no breadcrumbs
+ this PR + XCL_PER_LANE=1 1 ended early an access violation at 168 s

So it does bring the frame rate back (2.5 to 2.7 against 0.77, close to the 2.15 to 2.30 before #3499), but half of the runs with it lost the device about 140 to 150 s after the first frame, which none of my runs of 3a8745dc (before #3499) or of main did. Caveats: the first pair ran while other GPU work ran on the same card (I discarded that as evidence, but the hang repeated in the clean pair); a TDR at about that time also took this PC down a few minutes later, so I stopped the series there.

My reading, not verified: the switch from the chain to the whole form happens mid-frame once the whole form becomes ready, and the first indirect dispatch on the whole form is where it hangs. If you have a switch to force the chain or the whole form from the start, I can run both.

AI use: Claude Code (Claude Opus 5.5) made the runs and wrote this.

@cj-tomlin

cj-tomlin commented Nov 30, 2026 •

Copy link
Copy Markdown

Correction (edit of the report below): the device removals are not specific to this PR. main removes the device at the same point once its pipelines are warm. The two main runs in the report ran on without a removal only because they froze before the GPU work that fails.

Five more main runs after the report, same machine and setup (abec7ce9, runtime the same as 9dfbe3ea, the same uncommitted memory counters). One used the shader cache the report's runs used, three a fresh copy of my main shader cache, one after a reboot:

main in the report (2 runs) this PR (4 runs) main later (5 runs)
first cutscene its audio only, no image drawn its audio only, no image
title threads waiting 1 s for a pipeline still being built 87, 100 54, 0, 0, 14 0, 7, 0, 0, 0
after the cutscene opening's burst (~8,000 dispatches in 2 s) 0 submits: the title stands still keeps submitting keeps submitting
last present 87, 105 s 104, 104, 109, 126 s 90, 95, 104, 108, 124 s
end ran the 300 s, no removal removed at 106, 121, 128, 155 s removed at 91, 97, 105, 107, 127 s
  • Removals on main: four 0x887A0005 and one 0x887A0006, all with DRED no breadcrumbs, system commit 47–54 of 81 GB. The same signature as with this PR.
  • The pipeline waits fall run by run as the shader and driver caches warm. The two main runs in the report were early in that: they stalled on pipelines at the cutscene opening, so they never submitted the work after it.
  • So the report's "main 0 of 2 removals, this PR 4 of 4" compares a cold stall with a warm run, and does not show that this PR causes the removals. What still holds: with this PR the first cutscene is drawn; on main it is not, warm or cold (audio only, in all seven main runs). The removal that follows happens on main as well, and I don't know its cause.
  • Not tested: a raised NVIDIA shader heap; other GPUs.

AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs and drafted this correction; I checked it.


Test report, RTX 3080 10 GB: with this PR a retail title draws its first in-engine cutscene, which main never shows; then the device is removed, in 4 of 4 runs.

Setup

  • RTX 3080 10 GB (NVIDIA 621.40, no driver profile for xcl.exe, so the default 512 MB shader heap), Ryzen 7 7800X3D, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, release build.
  • PR: main abec7ce9 + this PR's head 49eb78ef (clean merge). main: 9dfbe3ea (its runtime is the same as abec7ce9; the commit between them only changes a test file). Both with uncommitted logging of memory counters that I use for Swarm: eliminate redundant physical-page GPU backing without losing memory visibility #3211; no other change.
  • A retail title, Series X profile, same save, warm shader and driver caches, XCL_PREPARE=0 XCL_ACTIVITY=1 XCL_NETWORK=0 XCL_PRESS_AT=25:A, 300 s limit. 4 runs with the PR, 2 with main, back to back.
  • cargo test --release -p xcl --lib dispatch_chain -- --test-threads=4 on the merged tree: 27 passed, 0 failed, 0 ignored; SKIPPED dispatch_chain_native_wave64_builds_whole (no wave64). I did not run the whole suite.

Results

main (2 runs) this PR (4 runs)
first cutscene its audio only, no image drawn: backdrop (1 run), title card with audio (3 runs), some stutter
last present 87, 105 s 104, 104, 109, 126 s
DirectStorage read by then 5,259, 5,303 MB 5,575, 5,733, 5,767, 5,824 MB
end ran the 300 s, no removal device removed at 106, 121, 128, 155 s
peak local video memory (DXGI budget 8.7–9.0 GB) 15,319, 15,685 MB 16,236, 16,343, 16,492, 16,502 MB
split scratch, peak (compute split log line) 386, 574 MiB 392, 394, 531, 539 MiB
  • On main the title stops presenting when the first cutscene starts, with draws waiting over 1 s on pipelines still being built. With this PR it keeps presenting into the cutscene.
  • Every removal: 0x887A0005, DRED no breadcrumbs, system commit 54 of 81 GB at the removal. In one run the title's own crash handler ran after the removal (exit 0x80000003).
  • At the same amount of DirectStorage read (4,500 and 5,000 MB), local video memory and the D3D12 heaps commit part match main within ~0.4 GB. The PR runs use more because they get further. I have not shown that the removals come from video memory; main never gets far enough to compare.
  • Split scratch while the cutscene loads is as high as on main, as expected: the whole forms are still building then, so indirect dispatches still take the 256 MiB claim. In one run it fell to 23 MiB once they were ready.

Against the other reports here: these runs end at the opening of the first in-engine cutscene. That is where the cold-cache stall on #505 happens too (118–126 s, with a title thread waiting in whole_ready → Chain::whole), and earlier than the interior scene of @throny's RTX 4080 runs. So the removals here are at a different point of the game from that hang, and of another kind: that was 0x887a0006 with a DRED page fault at VA 0. These are silent 0x887a0005 with no breadcrumbs, the signature of the NVIDIA shader-code heap filling (#2403, 512 MB by default). This PR's early queue_whole adds whole-form compiles at load for every journaled program, so more machine code may be in use than on main when the cutscene starts. This machine has no NVIDIA profile for xcl.exe, so the shader heap was at the default 512 MB in all six runs. That fits, but I have not tested a raised heap. The RTX 4090 runs of this PR above, with the shader heap at 2048 MB (#2590), had no removal; I don't know how far into the game they ran.

Not tested: a raised NVIDIA shader heap (#2590), which would tell whether the removals are #2403; the whole test suite, scripts/smoke.ps1, a GPU with more video memory (to tell whether the removals are a 10 GB limit), AMD, other titles. Commit other was 0.7–2 GB higher with the PR at the same DirectStorage read, and I have not found why.

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the tests and the runs, read the logs and drafted this; I watched the runs and checked it.

@minimalhipster990

minimalhipster990 commented Nov 30, 2026 •

Copy link
Copy Markdown

How far the RTX 4090 runs with this PR got, to answer cj-tomlin's question above: past the load into the 3D scene, and on in it until the 600 s limit. With the NVIDIA shader heap at 2048 MB (#2590), none of them ended with the silent 0x887a0005 of #2403.

AI use: Claude Code (Claude Opus 5.5) ran the replays, read the logs and wrote this. The person running these tests checked it and asked for it to be posted.

December 1 correction drafted with Codex (GPT-6).

@Gevroska

Copy link
Copy Markdown
Contributor

@Kalmarv I checked the first ExecuteIndirect call after the whole pipeline becomes ready, using the same fixture on parent 9dfbe3ea and PR head 49eb78ef. The argument buffer held a 1×1×1 decoy at offset zero and the intended 2×3×4 dispatch at byte offset 16. I read back the group counts after each WARP queue fence.

Pipeline state Parent PR head
Whole pipeline pending 24 groups in each split piece 24 groups in each split piece
First call with whole pipeline ready 24 groups in each split piece 24 groups in the whole shader, zero in either split piece

On the head, forcing the refusal case sent all 24 groups through each split piece again. Every completed readback preserved both guard words and returned the expected group-ID sums (12, 24, 36). That checks both the switch on the first ready call and the argument offset across it.

The fixture controls readiness directly. I didn’t test asynchronous readiness timing or reproduce the reported physical-GPU device removals.

I used Codex GPT-6.2 Sol to write the fixture and run both revisions. A separate GPT-6.2 Sol agent verified the source and raw WARP logs. Codex GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@treybertram06

treybertram06 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Test report: in-world frame rate on NVIDIA, 49eb78ef against its base 9dfbe3ea.

Tested

  • RTX 3080 10 GB (driver 621.40, ReBAR on), Ryzen 9 5900X, 64 GB RAM, Windows 11 26300. Release builds of both commits, no local changes.
  • Retail title, 300 s per run with scripted presses, alternating main, PR, main, PR. Env: XCL_PREPARE=0 XCL_HEAP_WINDOWS=1 XCL_GFX_PSO_WAIT_MS=100 XCL_GPU_TIMES=8,150 XCL_LOOK_STATS=2, otherwise main's defaults (edited: an earlier version of this comment also listed XCL_SPARSE_LAZY, XCL_TEXTURE_LEVEL_PAGES and XCL_TEXTURE_SYSMEM, which these runs did not set). Counted over 150–300 s, in the world:
run presents GPU ms per frame
main 1 96 1143
PR 1 262 611
main 2 97 1321
PR 2 275 496
rounds presents GPU ms per frame
16 (default) 85 1445
1 193 938
4 206 670

Not tested

  • The test suite on this head.
  • Other GPUs, and AMD.
  • Runs longer than 300 s.
  • Whether the frames are drawn correctly; only rates and GPU times were compared.
  • The review point about rechecking chain.whole.ready() between the two calls in execute_indirect.

AI use

  • Claude Code, Claude Opus 5.5. It built both commits, ran and analysed the runs and the GPU trace, and wrote this report.

@andresd-cerebras andresd-cerebras left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawn.

PR xcl-dev#3499 routed Dispatch-only ExecuteIndirect of split compute PSOs through the split chain even after the background whole form had finished building, claiming split scratch and recording multi-round piece chains on every indirect dispatch.

Return Indirect::Whole from dispatch_chain::execute_indirect once chain.whole.ready() is Some(Ok(_)) so bind.rs dispatches the single whole-form ExecuteIndirect directly, while staying on the split chain while the whole form is still pending or refused. Re-check chain.whole.ready() before recording the chain so a build finishing in between hands off cleanly, and drop the now-unused pso::dispatch_command_signature helper.

Co-Authored-By: Antigravity (Gemini 3.1 Pro) <noreply@google.com>
@Kalmarv
Kalmarv force-pushed the fix/3499-indirect-use-whole-when-ready branch from ba8592a to 8b9d8df Compare December 2, 2026 02:59
@github-actions github-actions Bot added the area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 label Dec 2, 2026
@Kalmarv

Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (1c8b55147) at 8b9d8dfe4 and addressed all four review points from @Foniass:

  1. Dropped creation-time prefetch_whole in dispatch_chain::build so this PR stays focused on the execute_indirect handoff.
  2. Removed the unused pso::dispatch_command_signature helper (0 new warnings).
  3. Re-checked chain.whole.ready() immediately before recording the split chain to close the race window.
  4. Updated queue_whole's driver-refusal warning to reflect that Dispatch-only indirect dispatches continue on the split chain.

Re-verified with full scripts/test.ps1 (2910 passed, 0 failed, 51 ignored on RTX 5070 Ti + DXC 1.9.2609.5) and a fresh 60 s scripts/smoke.ps1 pair (1699 frames vs 1387 on main, 0 removals/crashes).

@github-actions github-actions Bot added gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) and removed gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md) gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 2, 2026
@vasanex

vasanex commented Dec 2, 2026 •

Copy link
Copy Markdown

merge-check
base: 1c8b551
head: 8b9d8df
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same tests as on the base (2909 passed there); failing: none. indirect_prefers_whole_only_once_built_ok and an_indirect_dispatch_runs_its_chain_without_any_whole_form ran and passed.
review: whole diff read, nothing that blocks. Once the whole form is built, a Dispatch-only indirect call returns Indirect::Whole before any scratch is claimed, so the caller issues the one whole-form ExecuteIndirect it issued before #3499. While the whole form is pending or refused the chain runs as on main; the removed tail call only ran when the whole form was there, which now returns earlier, so a dispatch whose groups do not fit the slicer's rounds is left out in the same cases as before (the slicer still writes the tail command, which nothing reads now). The device removals reported for an earlier head on an RTX 4080 were corrected in this thread as not specific to the PR; I saw none (below). Not tested here: AMD, and a driver that refuses the whole form.
performance: better in the world, neutral in the 60 s smoke. Smoke, release, same title and settings: base 1608 frames, peak commit 19911 MB; merged tree 1696 frames, 18650 MB (94 %), presents 60 60 61, 0 device removals, 0 crashes. In the world (a private test line on this base with non-default memory switches, so not the merged tree itself; same shader cache, one run each): 0.51 presents/s without this PR, 1.46 presents/s with it between 300 and 380 s, and 1.5 to 1.67 presents/s over a 1500 s run with no device removal and no crash. Per-program GPU times without the PR showed two split compute programs at 384 ms and 205 ms a frame (one of them the ExecuteIndirect one); with it neither is among the 60 most expensive.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0 / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 8b9d8df, since ba8592a, diff read, not a merge-check):

  • Creation-time prefetch and the driver/GPU identity of whole-form blobs: no longer applies. prefetch_whole and whole_blob_path are gone from crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs, and build (~280-311) only creates the chain again. The whole form is queued only from execute_indirect / whole_ready, as on main, so a cold driver cache no longer makes compute_container compile each journalled whole form at load time.
  • Regression evidence: fixed. Both xcl-smoke blocks are now for head 8b9d8df and main 1c8b551, which contains D3D12.X: indirect dispatches of a split program run its direct pieces #3499. Frames 1699 vs 1387, peak commit 18164 MB vs 17480 MB (+684 MB, 3.9 %), no device removal or crash. The 2-3x world frame-rate recovery in the description still comes from the runs on 49eb78e; the 60 s smoke does not show it for this head, and Not tested says so.
  • Description: mostly fixed, one point open. The full suite is reported (2910 passed, 0 failed, 51 ignored, 24 SKIPPED), and the prefetch (the second change) and the claim that every journalled program is queued are gone. Still open: AI use names "Antigravity (Gemini 4 Neon)", the commit trailer says "Antigravity (Gemini 3.1 Pro)", and the initial draft is credited to "Antigravity / Claude" with no model. Name each tool and model the same way in both places. Also, "Closed the ready() race" overstates it: the second check at dispatch_chain.rs ~620 narrows the window but does not close it. If the whole form finishes after that check, this dispatch still records the chain with no tail, as main does while the whole form is pending, so it is not a regression; the wording should say "narrowed".
  • Unused pso::dispatch_command_signature and the stale test doc: fixed. The helper is removed from crates/xcl/src/gpu/recomp/pso.rs ~1835 with no references left, and the doc of an_indirect_dispatch_runs_its_chain_without_any_whole_form (dispatch_chain.rs ~826) no longer mentions the overflow tail.
  • Test for the fast path that avoids split scratch: fixed (GPU only). The same test now builds the whole form, calls execute_indirect again and expects Indirect::Whole, with bind and around_slicer set to panic (~876-886); on main that call binds the chain and runs the slicer, so it fails without the fix. It skips with "no GPU" on the CI runner.
  • No new problems found. By reading: on Indirect::Whole, bind.rs ~3857 whole_ready sees ready().is_some() and returns the built form without compiling, so the dispatch goes through the guard/clamp path from before D3D12.X: indirect dispatches of a split program run its direct pieces #3499. While the whole form is pending or refused, behaviour is unchanged from main.

Fine: the diff is down to a small change in two files (+55/-38): an early hand-off once the whole form is Ok, the re-check after scratch is set up, and the dead helper and tail recording removed. #3648 touches dispatch_chain::build, not execute_indirect, and merges with this PR without conflicts.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Decodere

Decodere commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 1c8b551
head: 8b9d8df
merge: clean fast-forward onto 1c8b551475e1e7bfe48f94448492a4c3544a2e0f (8b9d8dfe4c7a0a6d56ff94d7f2d9b25988f8dff3; git diff --check clean).
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets) -> 2909 passed, 1 failed, 51 ignored (+1 passed vs main 1c8b5514's 2908 passed, 1 failed, 51 ignored). All 17 hle::d3d12x::real::dispatch_chain::tests passed with 0 skips, including new indirect_prefers_whole_only_once_built_ok and updated an_indirect_dispatch_runs_its_chain_without_any_whole_form and a_split_indirect_dispatch_slices_the_counts_the_guard_let_through. 28 SKIPPED lines — all hardware/environment-expected on RTX 4060 (22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)). Sole failure is pre-existing Issue #3441 (tests/gpu_two_pass_cache_e2e.rs :: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs at line 584, releasing the title PSOs releases their two-pass state, left: 1, right: 0), which also fails on clean base 1c8b5514 (2/2 on this machine) and is unrelated to dispatch_chain.
review: read the full diff (2 files: crates/xcl/src/gpu/recomp/pso.rs -15, crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs +55/-23, total +55/-38). Clean and tightly scoped: execute_indirect checks indirect_prefers_whole(chain.whole.ready()) before claiming split scratch or command storage and re-checks after preparing scratch/command signature so indirect dispatches hand back to Indirect::Whole as soon as the background whole-form build finishes (Some(Ok(_))) while staying on the split chain during None (building) or Some(Err(_)) (driver refusal). No cold-cache prefetch_whole in dispatch_chain::build, and pso::dispatch_command_signature has no remaining callers. No UB, synchronization, or correctness issues found.
performance: Tier 3 60 s retail smoke (title: 29640639) shows no regression vs main 1c8b5514 baseline (1462 frames, presents per 2 s (last 3): 48 53 59, peak commit: 16043 MB): 1618 frames (+10.7%), presents per 2 s (last 3): 60 60 60, peak commit: 15250 MB (-4.9%), 0 device removals, 0 crashes.

xcl-smoke v1
commit: 8b9d8dfe4c7a0a6d56ff94d7f2d9b25988f8dff3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15250 MB

verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 1c8b551
head: 8b9d8df
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at #3528 (comment) and its findings stand. Most serious: all earlier points are fixed; the AI use section and the commit trailer name different models, and "closed the race" should say "narrowed".
performance: 60 s smoke of a retail title, main 1c8b551 vs this merge (8b9d8df): 1652 -> 1688 frames shown (102 %; last presents per 2 s: 60 61 60), peak commit 18228 -> 17150 MB, 0 device removals, 0 crashes.
verdict: safe to merge: no blocking finding in the review (the points there are minor), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 8b9d8dfe: 1 finding(s). These are on lines outside the diff:

crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs:652: Oversized ("partial") Dispatch-only indirect dispatches are now dropped but reported as Indirect::Ran. The slicer zeroes every piece round and puts the groups only in the whole-form tail command, and with the tail ExecuteIndirect removed nothing reads that tail. If the whole form is pending (None) or refused by the driver (Err) and the GPU args need more than XCL_SPLIT_INDIRECT_ROUNDS x most slabs (e.g. 16 rounds with large groups), the slicer sets partial=true, writes 0 groups to every round and puts g at chain_tail_offset(rounds). No groups run, execute_indirect returns Ok(Indirect::Ran), and bind.rs counts it as RAN/DISPATCHES instead of SKIPPED. With a permanent Err the dispatch is lost for the whole session with no warning, while the new refusal warning (~365) says these dispatches run their chain. Returning Indirect::Whole or Err for partial splits would make it counted and logged as a skip.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

@Kalmarv

Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @vasanex, @Decodere, @Foniass, and @bmjask for the reviews and merge-checks!

  • Updated the description wording for @Foniass ("narrowed" the ready() window and clarified the commit trailer vs Gemini 4 Neon model naming without touching HEAD 8b9d8dfe4).
  • Re @bmjask on dispatch_chain.rs:652 (oversized partial splits when chain.whole is pending or refused): as @vasanex noted, on main the tail ExecuteIndirect also only ran when chain.whole was already built, so oversized dispatches while chain.whole is pending/refused are unchanged from main (not a regression of this PR). Happy to track returning Err/skip accounting for permanently refused oversized splits in a small follow-up so we do not invalidate the three merge-checks here.

@github-actions github-actions Bot removed the ready-to-merge Has 2 independent safe merge-checks on current head (#3041) label Dec 2, 2026
@bmjask

bmjask commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

@throny
throny merged commit 3a61783 into xcl-dev:main Dec 2, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.