D3D12.X: indirect dispatches of a split program run its direct pieces #3499
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3499"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-30T03:25:43Z.
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
Tested
cargo check -p xcl --tests: passed on this exact head againstorigin/main(91244db94)scripts/smoke.ps1running now and will be pasted below.Regression run
main:PR head:
Not tested
AI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-30T11:12:36Z.
@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
mainwith 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:mainate15636033a8745dcc9aa9f8ad52ff48cmainNo 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, 18ExecuteIndirect of a split compute program whose whole form is still being built skippedlines; 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.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T12:17:26Z.
@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 fullXCL_SPLIT_SCRATCH_MB(256 MiB) of scratch, where a direct dispatch asks for what it needs. Then one slicer dispatch, andXCL_SPLIT_INDIRECT_ROUNDS(16) rounds of every piece, each piece with a UAV barrier and anExecuteIndirectof 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 oneExecuteIndirectof 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:
XCL_SPLIT_INDIRECT_ROUNDS=1cuts it by 16. If presents/s comes back near 2, that is it.scratch_bytes), and a new 256 MiB committed buffer is made per recording and freed with the allocator.XCL_SPLIT_SCRATCH_MB=16and the scratch and slab figures on thecompute 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_indirectreturns beforegpu_profile::begin(bind.rs, theIndirectDispatchbegin), 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_indirectright after the chain lookup, to returnIndirect::Wholewhenchain.whole.ready()is alreadySome(Ok(_)), which is the old path once the whole form exists.I will run
mainagainstXCL_SPLIT_INDIRECT_ROUNDS=1on 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).
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T13:24:28Z.
The numbers I promised above. RTX 5070 Ti 16 GB (617.42), Ryzen 7 9800X3D, 32 GB RAM, release,
main9dfbe3ea, 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.compute split:chained dispatches / slabsmainmainmainwithc9aa9f8areverted (git revert -m 1, clean)main,XCL_SPLIT_INDIRECT_ROUNDS=1main,XCL_SPLIT_INDIRECT_ROUNDS=1main,XCL_SPLIT_SCRATCH_MB=16What I read from it:
mainagainst 1.43 with the PR reverted, about 2.5 times. The reverted build has one run only; the second did not happen (below).B2 ended early with a driver timeout:
nvlddmkmevent 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 samemain), 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).
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T13:45:48Z.
The three runs that were missing from the table above, same card, binaries, switches and window:
c9aa9f8arevertedmain,XCL_SPLIT_INDIRECT_ROUNDS=1mainSo on this card:
main0.58, 0.57, 0.61; one indirect round 1.21, 1.26; the PR reverted 1.43, 1.33.mainis 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
mainand it also ended withnvlddmkmevent 153, about 240 s into the run, so the timeout is not tied toXCL_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).
Imported from ivall/xcl. Originally posted by throny on 2026-11-30T13:51:44Z.
@tiagonleal thanks, your first guess is it. Same RTX 4080 16 GB setup as above,
maind52ff48cwith only the run script's input-timing patch, warm runs, presents/s from 240 s after the first frame:XCL_SPLIT_INDIRECT_ROUNDS=1XCL_SPLIT_SCRATCH_MB=16So 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
mainright 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
maincan setXCL_SPLIT_INDIRECT_ROUNDS=1for frame-rate comparisons, knowing it may drop work.AI use: Claude Code (Claude Opus 5.5) made the runs and wrote this.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-30T14:02:57Z.
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:XCL_SPLIT_INDIRECT_ROUNDSmaind52ff48c+ our stackmaind52ff48c+ our stackmain53e85fb1+ the same stack (before #3499)XCL_GPU_WAIT_TIMEOUT_MS=45000in A and B so the 5 s watchdog does not stop the title; C ran with the default).XCL_GPU_PROFILE=1on A's and C's bases: many small compute dispatches took 5-28x longer per call ond52ff48cwhile 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
c9aa9f8aon 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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-30T14:36:56Z.
Thank you @throny, @tiagonleal, and @CharlyRien for bisecting and isolating this so clearly (
XCL_SPLIT_INDIRECT_ROUNDS=1pointed straight to the cause).Opened #3528 to return
Indirect::Wholefromdispatch_chain::execute_indirectoncechain.whole.ready()isSome(Ok(_))(and to queuequeue_wholeimmediately indispatch_chain::buildfor programs already inEARLIER_INDIRECT_USED), keeping the split chain only while the whole form is still building or refused.