Skip to content

D3D12.X: indirect dispatches of a split program run its direct pieces - #3499

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/5-unified-dispatch-chain
Nov 30, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/5-unified-dispatch-chain

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Runs indirect dispatches of a split compute program through its direct DispatchChain piece set so no separate indirect piece set has to be precompiled or built at runtime.

What is in it

  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs, crates/xcl/src/hle/d3d12x/real.rs, crates/xcl/src/hle/d3d12x/list_x.rs: execute indirect split compute dispatches on the direct piece set.

Tested

  • Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11, DXC 1.9.2609
  • cargo check -p xcl --tests: passed on this exact head against origin/main (91244db94)
  • Eliminates duplicate indirect split-chain builds; verified across 95,737 chained dispatches (695 split programs, 3,819 pieces) in a 29-min live run with crashes.
  • Full workspace GPU suite + scripts/smoke.ps1 running now and will be pasted below.

Regression run

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: e8a366641a3eb2c1e14afcc5da539271f807d859
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1670 (PresentX 1670)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15773 MB

Not tested

  • AMD / Intel GPUs

AI use

  • Developed and verified with Claude Opus / Gemini coding assistants; all commits reviewed, built, and tested locally on RTX 5070 Ti.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 30, 2026
@Prime1997
Prime1997 merged commit c9aa9f8 into xcl-dev:main Nov 30, 2026
4 of 5 checks passed
dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 30, 2026
Keeps upstream's DXIL IR cuts (xcl-dev#3500-xcl-dev#3503/xcl-dev#3495-xcl-dev#3499: sampler waterfall,
descriptor windows, split-wave64 mask exchange, per-lane exec, direct PS
masks, quad shuffles, packed/normalized buffer decode, commit-aware
compiles), xcl-dev#3269 fixed-point optimizer, xcl-dev#3154 compact compute prologue,
xcl-dev#2123 split atomic add, xcl-dev#2070 offline 64 MB stacks, xcl-dev#3442 split-whole,
xcl-dev#1319 root-constant bounds, xcl-dev#3356 late Reset releases, xcl-dev#1322 empty-BVH/NaN
rays, xcl-dev#2753 3-D texture sizing, XMA/VFS/TLS/loader fixes.

Resolutions:
- real.rs: union of T-156 res_release pinning with upstream's InListReset
  and abi_rs_for_stages; dropped upstream's warm_graphics (T-095 removed
  that path); kept ComputeBuild::IndirectChain for our split-chain variant.
- dispatch_chain.rs: kept our IndirectBuild split-chain architecture (the
  T-095 port removed the preload/whole-worker machinery upstream builds
  on); ported upstream's huge-PSO refusal log.
- pso_async.rs: took upstream's commit-aware build_pieces/build_scoped and
  WORKER_STACK, removed the preload/backlog subsystem our port does not
  have (and its tests), kept our profile_is_series_s.
- late_release.rs: took upstream's Dead enum, Busy/InListReset and
  hold_pipeline/hold_heap/hold_unmap, with our vram release path (no
  recycle pool).
- emit.rs: upstream's additions moved into emit/memory.rs (ADD_TID_ENABLE),
  emit/exp.rs (misc-vector layer/viewport), emit/mimg.rs (SampleCmp with
  bias gradients), emit/valu.rs (abs/neg on shift/align), emit.rs out_struct.
- bind.rs: root-constant bounds clamp + its test; kept our bool
  execute_indirect API.
- bvh.rs: our grow/tri_ret/watertight model plus upstream's empty-root
  bounds and NaN-ray refusal.
- kernel.rs: upstream's mask/waterfall/rodata cuts plus our lanes_upper.
- shaders.rs: upstream's worker stack helpers and mesh/GS precompile paths,
  with our PipelineJob record identity.
- eh.rs: upstream's CLWB TF guard + test, our termination test.
- lower.rs test: 574bda4 makes wave32 SALU words compute S_WQM without
  quad lanes; assert that and keep the wave64 refusal.
@throny

throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

@Kalmarv a frame-rate regression in the world that bisects to this PR, on an RTX 4080 16 GB (621.40), i9-12900K, Windows 11, release builds of main with one local patch (button-press timing for the run script, no runtime effect), same title, same switches (XCL_UMA_WINDOWS=16 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072 XCL_DRED=pagefault XCL_PREPARE=0), presents per second measured from 240 s after the first frame:

main at merge run 1 (cold caches) run 2 (warm)
e1563603 before #3495 0.95 2.15
3a8745dc after #3497, before this PR 2.28 2.30
c9aa9f8a this PR 0.68 0.69
d52ff48c later main 0.79 (two more runs: 0.78, 0.81)

No device removal and no crash in any of them; the slow runs are steadily slow (few 2-second windows without a present), not stalls. The log's compute split: line, warm runs, 600 s each: before this PR 750,545 chained dispatches in 2,442,096 slabs over the run; with it 235,891 in 883,701 slabs, i.e. about the same per frame at a third of the frames. Before it, 18 ExecuteIndirect of a split compute program whose whole form is still being built skipped lines; with it none, so indirect dispatches of split programs that were skipped before now run their pieces, which looks like where the time goes.

The smoke blocks in the description are 60 s in the menus, which this does not reach. Is there a switch to get the old behaviour back for a comparison run, or should I measure something specific (XCL_GPU_TIMES)?

Not tested: AMD, other cards, more than two runs per commit.

AI use: Claude Code (Claude Opus 5.5) built the commits, ran the bisect and wrote this.

@tiagonleal

Copy link
Copy Markdown
Contributor

@throny on your question about a switch: nothing restores the old behaviour outright, but two existing variables should separate the candidates in a pair of runs. This is from reading the merged source (c9aa9f8a); I have not run any of it yet, my card is busy until later today.

What an indirect dispatch of a split program records now (real/dispatch_chain.rs, gpu/recomp/pso.rs): it always takes the chain. Because the CPU does not know the group count, it asks for the full XCL_SPLIT_SCRATCH_MB (256 MiB) of scratch, where a direct dispatch asks for what it needs. Then one slicer dispatch, and XCL_SPLIT_INDIRECT_ROUNDS (16) rounds of every piece, each piece with a UAV barrier and an ExecuteIndirect of its own, empty rounds included, and the whole form as the tail. No readback, CPU wait or flush. Before the PR the same call was one ExecuteIndirect of the whole form, or a skip while that was still building (your 18 lines). So roughly 16 x pieces + 2 dispatches where there was one.

Two things that could carry the cost, both guesses until measured:

  1. The count itself: XCL_SPLIT_INDIRECT_ROUNDS=1 cuts it by 16. If presents/s comes back near 2, that is it.
  2. Scratch: the 256 MiB claims of the indirect calls use most of the 384 MiB total, so other lists in the same frame fall back to the 2 MiB minimum (scratch_bytes), and a new 256 MiB committed buffer is made per recording and freed with the allocator. XCL_SPLIT_SCRATCH_MB=16 and the scratch and slab figures on the compute split: line would show it. Your slabs per dispatch only moved from 3.25 to 3.75, which argues against the fallback being the main part.

On the per-call numbers reported elsewhere (small direct dispatches 5 to 28 times slower with identical DXIL): the chain path in execute_indirect returns before gpu_profile::begin (bind.rs, the IndirectDispatch begin), so the chain has no timestamp pair of its own, and its work may be landing in the next dispatch's pair. I would not read those per-program times as those programs getting slower.

For a clean A/B without a revert, the smallest local change I can see is, in execute_indirect right after the chain lookup, to return Indirect::Whole when chain.whole.ready() is already Some(Ok(_)), which is the old path once the whole form exists.

I will run main against XCL_SPLIT_INDIRECT_ROUNDS=1 on an RTX 5070 Ti when the card is free and post the numbers here.

AI use: Claude Code (Claude Opus 5.5 read the diff and the source, Claude Fable 5.2 checked the cited switches and lines and wrote this).

  • Tiago

@tiagonleal

tiagonleal commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

The numbers I promised above. RTX 5070 Ti 16 GB (617.42), Ryzen 7 9800X3D, 32 GB RAM, release, main 9dfbe3ea, same retail title, warm caches, XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=1536 XCL_PREPARE=0, runs of 330 s. Presents per second in the world, counted from 30 s after world entry to the end of the run. This PC has 32 GB and cannot hold the world much longer, so the windows are about 217 s and start earlier than throny's.

run build / switch window presents/s compute split: chained dispatches / slabs indirect skipped lines
A1 main 216 s 0.58 93,188 / 265,487 0
A2 main 217 s 0.57 89,928 / 224,102 0
D1 main with c9aa9f8a reverted (git revert -m 1, clean) 217 s 1.43 233,172 / 554,729 13
B1 main, XCL_SPLIT_INDIRECT_ROUNDS=1 218 s 1.21 211,846 / 535,457 0
B2 main, XCL_SPLIT_INDIRECT_ROUNDS=1 53 s, see below 0.90 30,254 / 136,641 0
C1 main, XCL_SPLIT_SCRATCH_MB=16 218 s 0.56 90,950 / 114,167 0

What I read from it:

  • The regression is on this card too: 0.57 and 0.58 on main against 1.43 with the PR reverted, about 2.5 times. The reverted build has one run only; the second did not happen (below).
  • One indirect round instead of 16 gets most of it back in the one full run (1.21 against 1.43), so the count of rounds per indirect dispatch is where most of the time goes. One full run, so an indication.
  • The smaller scratch changes nothing (0.56), one run. The scratch claim is not the cost.
  • The saved world frames of A, B and D show the same scene and nothing looks broken with one round. They are from different moments, so that is a weak check.

B2 ended early with a driver timeout: nvlddmkm event 153, "Restarting TDR occurred", 166 s into the run, with free RAM at 3.5 GB. xcl.log simply stops there, with no device-removed line, and the process stayed stuck until my watchdog killed it. It is the only TDR today on this recipe (0 in A1, A2, B1, C1, D1 and none in this morning's world runs on the same main), so I cannot say whether one round has anything to do with it. My launcher stops all runs after a driver event, which is why D2 is missing. I will run D2 and one more full B run and add them here.

No device removal in the other five runs. Peak commit 39.2 to 41.6 GB, peak local video memory 19.2 to 20.8 GB against a 15.1 GB budget in all of them.

AI use: Claude Code (Claude Opus 5.5 built the revert, ran the runs and read the logs, Claude Fable 5.2 wrote this).

  • Tiago

@tiagonleal

Copy link
Copy Markdown
Contributor

The three runs that were missing from the table above, same card, binaries, switches and window:

run build / switch window presents/s chained dispatches / slabs
D2 c9aa9f8a reverted 216 s 1.33 218,831 / 549,705
B3 main, XCL_SPLIT_INDIRECT_ROUNDS=1 219 s 1.26 216,203 / 542,046
A3 main 127 s, cut by a driver timeout 0.61 51,500 / 142,928

So on this card: main 0.58, 0.57, 0.61; one indirect round 1.21, 1.26; the PR reverted 1.43, 1.33. main is 2.1 to 2.3 times slower than either, and repeats of the same variant differ by 0.1 at most. One round ends about 10 % under the revert, which two runs each cannot separate from noise.

A correction to what I said about the driver timeout: A3 is plain main and it also ended with nvlddmkm event 153, about 240 s into the run, so the timeout is not tied to XCL_SPLIT_INDIRECT_ROUNDS=1. That is 2 timeouts in 9 runs of this recipe this afternoon, none with a device-removed line in the log, both with local video memory about 5 GB over the 15.1 GB budget. The log's last 10 s in A3 show only the periodic lines (about 4,700 draws and 5,300 dispatches per 2 s), so I cannot say what was on the GPU.

AI use: Claude Code (Claude Opus 5.5 ran the runs and read the logs, Claude Fable 5.2 wrote this).

  • Tiago

@throny

throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

@tiagonleal thanks, your first guess is it. Same RTX 4080 16 GB setup as above, main d52ff48c with only the run script's input-timing patch, warm runs, presents/s from 240 s after the first frame:

run switch presents/s
314 none 0.58
315 XCL_SPLIT_INDIRECT_ROUNDS=1 2.05
316 XCL_SPLIT_SCRATCH_MB=16 0.77

So the 16 rounds of every piece per indirect dispatch carry the cost; the scratch size does not. With one round the frame rate is back near the 2.15 to 2.30 of main right before this PR. No removal or crash in any of the three.

I have not checked whether one round is enough for correctness: an indirect dispatch with more groups than one round covers would leave work undone, and the picture in these runs does not tell me that. @Kalmarv a default that sizes the rounds from the group count (or runs the whole form once it is built, as tiagonleal suggests) would avoid both. Until then, testers on current main can set XCL_SPLIT_INDIRECT_ROUNDS=1 for frame-rate comparisons, knowing it may drop work.

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

@CharlyRien

Copy link
Copy Markdown
Contributor

An RTX 3090 data point for XCL_SPLIT_INDIRECT_ROUNDS=1, one run each (1 of 1), same binary, same shader cache and same switches apart from the one named:

run base XCL_SPLIT_INDIRECT_ROUNDS presents/s in the world (world + 20..180 s)
A main d52ff48 + our stack default (16) 0.18
B main d52ff48 + our stack 1 0.26
C main 53e85fb + the same stack (before #3499) - 0.51
  • B: no TDR, no device removal, no GPU wait timeout (XCL_GPU_WAIT_TIMEOUT_MS=45000 in A and B so the 5 s watchdog does not stop the title; C ran with the default).
  • So on this card one round recovers part of the loss (+45 % over A), not all of it (B is about half of C).
  • Earlier, with XCL_GPU_PROFILE=1 on A's and C's bases: many small compute dispatches took 5-28x longer per call on d52ff48 while their translated DXIL was identical (one redundant select removed), which matches a runtime-side cost.

Setup: RTX 3090 24 GB, driver 616.56, Ryzen 9 5950X, Windows 11 22631. Our stack = 42 commits (ports of #3089, #2798 / #2799, the stencil part of #3290; #3094; #3281). Env: XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_ALIAS_COPY=1 XCL_PLACE_RETIRE=0 XCL_DEPTH_UAV_TWIN=1 XCL_PAIR_PAGES=1 XCL_OUTSIDE_VIEW_USE=1 XCL_OUTSIDE_ONLY_BYTES=0x3200000,0x1900000 XCL_TWO_PASS_MB=2048 XCL_VIEW_REACH_MB=36 XCL_PREPARE=0 XCL_DRED=1, warm translated cache.

Not checked: a revert of c9aa9f8 on this card; other values of the switch; XCL_SPLIT_SCRATCH_MB.

AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this; checked and posted by me.

@Kalmarv

Kalmarv commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you @throny, @tiagonleal, and @CharlyRien for bisecting and isolating this so clearly (XCL_SPLIT_INDIRECT_ROUNDS=1 pointed straight to the cause).

Opened #3528 to return Indirect::Whole from dispatch_chain::execute_indirect once chain.whole.ready() is Some(Ok(_)) (and to queue queue_whole immediately in dispatch_chain::build for programs already in EARLIER_INDIRECT_USED), keeping the split chain only while the whole form is still building or refused.

Kalmarv added a commit to Kalmarv/xcl that referenced this pull request Nov 30, 2026
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>
saintwolf pushed a commit to saintwolf/xcl that referenced this pull request Dec 1, 2026
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>
saintwolf pushed a commit to saintwolf/xcl that referenced this pull request Dec 1, 2026
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>
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:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants