Skip to content

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

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/3499-indirect-use-whole-when-ready
Open

Kalmarv wants to merge 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

Summary

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 full 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) immediately 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.
  • Keep the split chain path while chain.whole is still building (None) or if the driver refused the whole form (Some(Err(_))), preserving D3D12.X: indirect dispatches of a split program run its direct pieces #3499's cold-build and zero-indirect-variant behavior.
  • In dispatch_chain::build, immediately queue queue_whole(&chain) for programs already recorded in EARLIER_INDIRECT_USED so warm runs load the cached whole form on xcl-pso-whole before the first indirect dispatch.

Regression run

Baseline (main):

xcl-smoke v1
commit: 91244db94d2f402237c6a8e428dbe5da07673c48
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1514 (PresentX 1514)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15133 MB

PR head:

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

Tested

  • cargo test -q -p xcl --lib hle::d3d12x::real::dispatch_chain::tests -- --test-threads=1 on Windows 11 + RTX 5070 Ti: 16 passed, 0 failed, 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 (verifying transition from Indirect::Ran while building to Indirect::Whole without binding the split chain once chain.whole is Ok).
  • 60 s title smoke on RTX 5070 Ti (49eb78efb vs 91244db94): 1693 frames (60/60/60 per 2 s), 0 device removals, 0 crashes, 16774 MB peak commit.

Not tested

AI use

  • Antigravity assisted with inspecting dispatch_chain.rs / bind.rs, drafting the fix and unit test updates, running local tests and smoke, and writing this description.

@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

@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 (c9aa9f8) routed Dispatch-only ExecuteIndirect of split compute PSOs through the split chain even after the background whole form had finished building. That claimed the full split scratch budget and recorded XCL_SPLIT_INDIRECT_ROUNDS rounds of every piece plus UAV barriers on every indirect dispatch, regressing world frame rate 2-3x across multiple GPUs.

Return Indirect::Whole from dispatch_chain::execute_indirect once chain.whole.ready() is Some(Ok(_)) so bind.rs dispatches the single whole-form ExecuteIndirect immediately, while keeping the split chain for cold builds while the whole form is still pending or if the driver refused it. execute_indirect checks again before recording the chain and returns Indirect::Whole when the build finished in between: the chain has no tail for groups past the slicer's rounds, so such a dispatch was left out while counted as run.

Also queue the whole form in dispatch_chain::build for programs already recorded in the indirect-use journal, as before xcl-dev#3499 only when the whole form's driver blob is already on disk (whole_blob_path, the DirectConstants chain root compute_container loads it under), so warm runs load the cached whole form before the first indirect dispatch and a cold driver cache does not compile every journalled whole form at pipeline creation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kalmarv
Kalmarv force-pushed the fix/3499-indirect-use-whole-when-ready branch from 49eb78e to ba8592a Compare November 30, 2026 23:28
@github-actions github-actions Bot removed the ready-to-merge Has 2 independent safe merge-checks on current head (#3041) label Nov 30, 2026
@AAsobu

AAsobu commented Nov 30, 2026

Copy link
Copy Markdown

Test report for #3528 at head 49eb78efbd8e4aaac3ce2d750ecc5b026b6ce337: the in-world run on an RTX 3090 that Not tested asks for.

  • Merged into main 86e86fcb33f94fa5d0c809d9b50af7b84bf49cce: clean. cargo build --workspace: ok.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 2890 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps), the same as main plus the new test. indirect_prefers_whole_only_once_built_ok and an_indirect_dispatch_runs_its_chain_without_any_whole_form pass.
  • Diff read in full: no findings.

Retail title, in the world. Release builds of main (ff0c364b, which differs from this base only in scripts/ and .github/) as A and this merge as B, runs A, B, A, B of 420 s each, warm XCL and driver caches, xcl.exe with the #2590 profile (1024 MB shader heap; without it this card loses the device ~5-50 s after world entry, #2403). Env: XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4, start prompt by XCL_PRESS_A_AT, no input. Numbers from world entry + 30 s to the end of the run (~220 s each):

A1 B1 A2 B2
world entry (first two-pass mesh dispatch) 142 s 162 s 151 s 165 s
presents per 2 s 0.72 0.94 1.04 1.12
draws per 2 s 2395 4066 4645 4596
process CPU (cores busy) 10.6 10.3 9.3 9.9
peak private / working set, MB 40989 / 18900 40481 / 20646 40685 / 20589 40155 / 20162
chained dispatches at the end 53,453 76,475 99,154 93,384
device removals 0 0 0 0
  • No regression: no removal or crash, memory and CPU the same within noise.
  • Frame rate: B averaged 1.03 presents per 2 s against 0.88 for A (+17 %), but the two A runs differ by 44 % between themselves, so with two runs a side this is not a measured gain. The 2-3x of the D3D12.X: indirect dispatches of a split program run its direct pieces #3499 regression is not visible here: this title on this card is GPU-bound at about one present per 2 s on both builds.
  • I could not tell from the log how many indirect dispatches took the whole form: used-indirect-split.txt lists 296 programs, but no whole-form build on xcl-pso-whole took over 1 s in any run (no slow-compile line), so they were either loaded from driver blobs or not built in these runs.
  • What the screen shows in the world on both builds: frames keep being presented, but no frame is drawn correctly (a flat black, white or blurred single-colour image). Audio plays without glitches.

Hardware: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0. Tool and model: Claude Code (Claude Opus 5.5), results checked by me.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: ba8592a
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache); failing: none. The PR's tests ran and passed: an_indirect_dispatch_runs_its_chain_without_any_whole_form (GPU, not skipped), indirect_prefers_whole_only_once_built_ok, whole_form_is_prefetched_only_when_used_indirectly_and_its_blob_is_on_disk.
review: whole diff read (1 commit, dispatch_chain.rs +79/-22) together with bind.rs's ExecuteIndirect path and compute_container. All three earlier review points are fixed at this head: the second readiness check returns Indirect::Whole (dispatch_chain.rs:630-636), the load-time whole-form queue is gated on the journal and on the whole form's DirectConstants driver blob being on disk (309, 358-367; the path matches the one compute_container loads), and the refusal warning is corrected (382). Indirect::Whole goes to whole_ready -> Whole::Ready; an Ok result stays in a OnceLock, so the two reads cannot disagree. Remaining: (1) blocking: the PR description check fails: both xcl-smoke blocks are from the old head 49eb78e, not ba8592a; the description still describes the ungated prefetch, omits the second-check fix, lists 16 module tests from the old head and no full-suite counts, has no "What is in it" section, and AI use names "Antigravity" with no model (the commit says Claude Opus 5.5). (2) minor: with only the first early return (616) disabled, the GPU test still passes, because the second check now covers it; the scratch-avoiding fast path has no test that fails without it (both checks disabled -> fails at 883). (3) minor: a blob kept by an older driver passes the prefetch gate, is refused and then compiled in full at creation, despite the comment at 307-308 (same as before #3499). (4) Device removals reported on this PR (RTX 4080 2/4; RTX 4090 1/6 about 3 s after a whole form finished building) are not attributed, since main removes the device at the same point on an RTX 3080; not checked here. No retail title on this machine: no smoke or world run, no Tier 2/3 runtime evidence of my own.
performance: reasoned: by default it brings back the single whole-form ExecuteIndirect from before #3499 once whole forms are built (other testers measured 2.2-2.8x on RTX 5070 Ti / 3080 / 4080 at 49eb78e). The new code is a load at pipeline creation for journalled programs with a blob on disk, plus a stat call per split program. Not measured here (no retail title); the description's smoke blocks are for 49eb78e, not this head.
verdict: not yet: the required PR description check fails (no xcl-smoke block on head ba8592a), and the description is stale (old prefetch behaviour, no full-suite counts, no model named in AI use); the code itself has no blocking finding
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114 / 621.14), AMD Ryzen 7 7800X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0 MSVC / Claude Code, Claude Opus 5.5

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@AAsobu

AAsobu commented Dec 1, 2026

Copy link
Copy Markdown

merge-check
base: d0832e6
head: ba8592a
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps); failing: none. In the full run the lib binary aborted early (0xc0000005, last line gpu::dxil::compact_tests::a_mask_read_whole_after_one_copy_only_splits_the_class ... ok, nothing this PR touches); the other binaries gave 148 passed, 0 failed, 20 ignored. Lib alone (cargo test -p xcl --lib -- --test-threads=4) 3 times in a row: 2744 passed, 0 failed, 31 ignored each time; the counts above add those. The same early lib abort happened on my run of #3514 on ff0c364b. The 3 tests of this PR pass, an_indirect_dispatch_runs_its_chain_without_any_whole_form on the GPU (not skipped).
review: none. Read the whole diff (dispatch_chain.rs +79/-22). The prefetch at creation is gated on the journal and on a non-empty whole-form blob file at driver_cache::path_for_chain_root_node(.., DirectConstants, ..), so a cold driver cache adds no compiles; execute_indirect hands back Indirect::Whole before and after building the slicer commands once the whole form is Ok, so a dispatch whose groups pass the slicer's rounds is no longer left out. The file writes are in the test only, in a temp dir it removes.
performance: retail title, in the world. Release builds of main d0832e61 (A) and this merge (B), runs A, B, A, B of 420 s each, warm XCL and driver caches, xcl.exe with the #2590 profile at 2048 MB. Env: XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4, start prompt by XCL_PRESS_A_AT, no input. From world entry + 30 s to the end (~240 s each):

A1 B1 A2 B2
world entry (first two-pass mesh dispatch) 143 s 144 s 136 s 142 s
presents per 2 s 1.79 3.52 1.06 2.98
draws per 2 s 3588 8405 4358 14290
process CPU (cores busy) 9.4 9.6 9.2 9.7
peak private / working set, MB 42846 / 20169 40763 / 20510 43258 / 20263 41466 / 20677
chained dispatches at the end 73,976 169,274 99,066 300,805
device removals 0 0 0 0
  • Both B runs beat both A runs: 3.25 against 1.43 presents per 2 s on average (2.3x) and 2.8x the draws, at the same CPU and ~2 GB less private memory. That is the size of the D3D12.X: indirect dispatches of a split program run its direct pieces #3499 regression this fixes.
  • My runs of the first head 49eb78ef (on main 86e86fcb, profile at 1024 MB) showed no clear gain (0.94 / 1.12 against 0.72 / 1.04). I cannot tell from the logs how much of the change comes from this head's prefetch of the cached whole forms and how much from the caches being warmer now, but A and B had the same caches here, alternated.
  • On screen, both builds play the intro with the UI and subtitles drawn; the user saw parts of the scene (a lit horizon, haze) more often with B, but the scene is still mostly a flat colour on both.
    verdict: not yet: the required PR description check fails, its xcl-smoke blocks are from the old head 49eb78ef (as Foniass noted); the code and the in-world numbers above have no blocking finding
    hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), results checked by me

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: ba8592a
merge: clean
build: cargo build --workspace -> ok (new warning: dispatch_command_signature is never used)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 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 the whole diff (dispatch_chain.rs, +79/-22). It changes the default path: once a split program's whole form is built, its Dispatch-only indirect dispatches go through the whole-form bind instead of the slicer, and programs an earlier run dispatched indirectly queue their whole form at creation. Findings: (1) the "only a load" guard of the creation-time prefetch (prefetch_whole) only checks that a blob file exists. Compute chain blob names (path_for_chain_root_node) carry no adapter/driver identity, unlike graphics files (graphics_file_hash), so after a driver update or GPU swap the file exists, the driver rejects it, and compute_container compiles every journalled whole form during loading on the one worker, the case the comment says it avoids. Fold the driver identity into the chain name or treat a rejected blob as "no prefetch". (2) The regression evidence is not for this head: the smoke block names 49eb78e (before the blob check), and the main run 91244db predates #3499. Peak commit +1.6 GB is unexplained. (3) Rules: AI use names the tool but not the model; the full suite was not run; the creation-time prefetch is a second change that could be its own PR; the description still says every journalled program is queued. (4) pso::dispatch_command_signature (pso.rs ~1835) is now unused, and the doc of an_indirect_dispatch_runs_its_chain_without_any_whole_form still mentions the removed overflow tail. Fine: a built whole form stays built, the re-check after scratch allocation covers the race, refused / pending / OOM states are unchanged, the journal is still noted before the early return, and the new GPU-test assertion fails on main.
performance: 60 s smoke of a retail title, main d0832e6 vs this merge (a4f0b7db): 1516 -> 1662 frames shown (110 %; 60 presents per 2 s in both), peak commit 18133 -> 17634 MB, no device removal, no crash. Same driver as the main run, so it does not exercise finding (1).
verdict: not yet: the creation-time prefetch can compile every journalled whole form during loading after a driver update (finding 1), and the PR's own regression run is from an earlier head
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.

@brainhay5

Copy link
Copy Markdown

A third card, and one number I have not seen in the reports above: the peak video-memory overshoot falls as well.

Setup

  • RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088), Ryzen 7 5800X3D, 64 GB, Windows 11 22631.
  • This head merged into main d0832e61 (merge 8934162b, parents verified), cargo build --release -p xcl ok. Diff read in full: one file, no unrelated edits.
  • Title, 300 s per run, scripted presses. Env: XCL_PREPARE=0 XCL_NETWORK=0 XCL_DEVICE_TYPE=lockhart XCL_ACTIVITY=1.
  • One prerequisite worth knowing: on this card every run was removed (0x887a0005) at ~80 s until xcl.exe was given a 2048 MB driver shader heap (the default 512 MB; xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590). Without that profile there is no in-world measurement to make here, so all runs below have it.
  • Same worktree, same binary flags, same warm shader and driver caches for every run; three control runs of plain main interleaved with three of this PR.
control 1 control 2 control 3 PR 1 PR 2 PR 3
1500 frames reached at 236.0 s 237.4 s 238.5 s 174.8 s 164.6 s 126.8 s
worst video memory over Windows' budget 1,945 MB 1,913 MB 2,085 MB 1,752 MB 1,573 MB 1,179 MB
median dispatches per 2 s 4,663 4,683 4,471 5,943 9,679 9,535
device removals 0 0 0 0 0 0

So the control is stable to within 2.5 s across three runs, and the PR is 1.4-1.9× faster to the same 1500-frame mark with a consistently lower peak overshoot. The dispatch count per 2 s goes up, which I read as the intended effect rather than a regression: a whole-form ExecuteIndirect replaces several rounds of piece dispatches, so more of the frame's work completes in the same wall time.

What it does not fix here: the frame rate after the world loads stays around 1-2 fps either way. On this card the title's texture pages alone come to 19,393 MB against the 15,152 MB budget Windows gives the process, so the driver pages continuously; that is a 16 GB limit, not something this PR can move. The gain is in how much of the load completes before that plays out.

This is consistent with the reports above in one respect and not another: a clear win on a 10 GB card, a small one on a 24 GB one, and a clear one here — plausibly the cards where memory pressure is highest benefit most.

AI use: an agent ran the builds and the runs and wrote this comment.

@thehollowedone

Copy link
Copy Markdown
Contributor

One implementation detail for Foniass's cache review at head ba8592a4: Microsoft documents cached PSOs as specific to the hardware and driver; another adapter or driver version may reject them. XCL's prefetch check, runtime DirectChain load/save, and offline pipeline preparation all use the same driver-agnostic chain filename.

If the disk key is made driver-specific, carry one key/path helper through all three call sites. Changing prefetch alone would miss stale blobs in runtime; changing runtime alone would stop it finding offline-prepared blobs. XCL already computes an adapter/driver identity and exposes it to preparation. A focused regression can assert that preparation and runtime derive the same path for one identity, different identities derive different paths, and a legacy unkeyed file alone cannot trigger prefetch. If identity is unavailable, the disk path can be absent and the ordinary build path still works.

This is a source-level implementation suggestion; I did not run a build or test. AI use: OpenAI Codex (GPT-6.2 Sol) traced the cache call sites and checked Microsoft's D3D12 contract.

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 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.