Repository navigation
Recompiler: split large direct compute pipelines at CFG edges - #2080
Conversation
|
Native Ampere follow-up on Tested
Both whole and split results match the independently calculated expected values, including all guards. All 324 source hashes match before/after and the local source snapshot. Only the attached test differs from the author head. Not tested: production D3D12.X chain allocation/lifetimes, ExecuteIndirect, AMD/native64, retail smoke or gameplay, full workspace suite, shader compilation/GPU throughput/memory cost. This uses synthetic DXIL and the runner, not console shader assets. New fixture has no cross-half exchange; that coverage comes from the author's existing test. The author already owns the multi-wave follow-up; this test doesn't cover or implement it. AI use: Codex (GPT-6) inspected the change, wrote the new test, ran native Windows verification and prepared this report. Portable test-only patch on af2bd61diff --git a/crates/xcl/src/gpu/dxil/module/split.rs b/crates/xcl/src/gpu/dxil/module/split.rs
index c4cfe66..7af0f2a 100644
--- a/crates/xcl/src/gpu/dxil/module/split.rs
+++ b/crates/xcl/src/gpu/dxil/module/split.rs
@@ -613,4 +613,122 @@ mod tests {
#[test]
fn dispatch_chain_wave64_live_loops_and_exchange() { compare(64); }
+ /// Early exits and forward skips retain their own continuation tags; group
+ /// indexing must keep every lane separate across all three dispatch axes.
+ #[test]
+ fn dispatch_chain_divergent_forward_edges_3d() {
+ if !runner::wave32_supported().unwrap_or(false) {
+ runner::skip_test("no wave32 GPU");
+ return;
+ }
+ println!("CHAIN_GPU={}", runner::adapter().unwrap());
+ for threads in [32, 64] {
+ let geometry = [threads, 1, 1];
+ let split = threads == 64;
+ let cs = CsInterface { threads: geometry, ..Default::default() };
+ let options = KernelOptions { wave64: split, split, mem_windows: 1, sampler_base: 0 };
+ let mut lw = Lw::new(&[], &Default::default(), options, &Entry::Compute(cs));
+ let (tid, _) = lw.setup_lanes_compute(geometry, false);
+ let mem = lw.mems[0];
+ let [x, y, z] = [0, 1, 2].map(|axis| lw.s.group_id(axis));
+ let three = lw.c(3);
+ let row = lw.mul(z, three);
+ let row = lw.add(row, y);
+ let row = lw.shlc(row, 1);
+ let group = lw.add(row, x);
+ let count = lw.c(threads);
+ let base = lw.mul(group, count);
+ let index = lw.add(base, tid);
+ let offset = lw.shlc(index, 2);
+ let original = lw.s.raw_load(mem, offset, 1)[0];
+ let mode = lw.andc(tid, 3);
+ let trips = lw.addc(mode, 1);
+ let zero = lw.c(0);
+ let one = lw.c(1);
+ let i32 = lw.s.m.i32();
+ let early = lw.s.m.new_block();
+ let choose = lw.s.m.new_block();
+ let first = lw.s.m.new_block();
+ let middle = lw.s.m.new_block();
+ let second = lw.s.m.new_block();
+ let done = lw.s.m.new_block();
+ let exits = lw.cmp(Pred::Eq, mode, zero);
+ lw.s.m.cond_br(exits, early, choose);
+ lw.s.m.set_block(early);
+ let marker = lw.addc(index, 100_000);
+ lw.s.raw_store(mem, offset, &[marker]);
+ lw.s.m.ret();
+ lw.s.m.set_block(choose);
+ let skips = lw.cmp(Pred::Eq, mode, one);
+ lw.s.m.cond_br(skips, middle, first);
+ lw.s.m.set_block(first);
+ let mut value = original;
+ let mut middle_value = None;
+ for round in 1..=16 {
+ if round == 9 {
+ let previous = lw.cur();
+ lw.s.m.br(middle);
+ lw.s.m.set_block(middle);
+ let joined = lw.s.m.phi(i32);
+ lw.s.m.add_incoming(joined, original, choose);
+ lw.s.m.add_incoming(joined, value, previous);
+ value = joined;
+ middle_value = Some(joined);
+ let stops = lw.cmp(Pred::Eq, mode, three);
+ lw.s.m.cond_br(stops, done, second);
+ lw.s.m.set_block(second);
+ }
+ let pred = lw.cur();
+ let body = lw.s.m.new_block();
+ let exit = lw.s.m.new_block();
+ lw.s.m.br(body);
+ lw.s.m.set_block(body);
+ let counter = lw.s.m.phi(i32);
+ let acc = lw.s.m.phi(i32);
+ lw.s.m.add_incoming(counter, zero, pred);
+ lw.s.m.add_incoming(acc, value, pred);
+ let next = lw.addc(counter, 1);
+ value = lw.add(acc, original);
+ value = lw.addc(value, round);
+ lw.s.m.add_incoming(counter, next, body);
+ lw.s.m.add_incoming(acc, value, body);
+ let again = lw.cmp(Pred::ULt, next, trips);
+ lw.s.m.cond_br(again, body, exit);
+ lw.s.m.set_block(exit);
+ }
+ let last = lw.cur();
+ lw.s.m.br(done);
+ lw.s.m.set_block(done);
+ let final_value = lw.s.m.phi(i32);
+ lw.s.m.add_incoming(final_value, middle_value.unwrap(), middle);
+ lw.s.m.add_incoming(final_value, value, last);
+ lw.s.raw_store(mem, offset, &[final_value]);
+ lw.s.m.ret();
+ lw.s.m.optimize();
+ let plan = lw.s.m.dispatch_plan(64).expect("partition branch fixture");
+ let stage = |b| plan.blocks.iter().position(|blocks| blocks.contains(&b)).unwrap();
+ assert!(plan.edges.iter().any(|edge| stage(edge.to) > stage(edge.from) + 1), "exercise a forward skip over an intermediate piece");
+ let chain = lw.s.split_compute(geometry, split.then_some(tid), 64).expect("split branch fixture");
+ assert!(chain.pieces.len() >= 3);
+ let whole = lw.s.finish_optimized(geometry, Some(32)).unwrap();
+ crate::gpu::dxil::validate::validate(&whole).expect("valid unsplit fixture");
+ let words = (threads * 12) as usize;
+ let initial: Vec<_> = (0..words + 16).map(|i| if i < words { i as u32 + 17 } else { 0xdeadbeef }).collect();
+ let expected: Vec<_> = initial.iter().enumerate().map(|(i, &v)| {
+ if i >= words { return v; }
+ match i as u32 % 4 {
+ 0 => 100_000 + i as u32,
+ 1 => v + 2 * (8 * v + 100),
+ 2 => v + 3 * (16 * v + 136),
+ _ => v + 4 * (8 * v + 36),
+ }
+ }).collect();
+ let reference = runner::dispatch(&whole, [2, 3, 2], &[], &initial).unwrap();
+ assert_eq!(reference, expected, "unsplit {threads}");
+ let result = runner::dispatch_split(&chain, [2, 3, 2], &initial).unwrap();
+ assert_eq!(result, expected, "split {threads}");
+ println!("CHAIN_BRANCH threads={threads} pieces={} scratch_words_per_group={} checked_words={words} guards=16", chain.pieces.len(), chain.dwords_per_group);
+ }
+ }
+
} |
PR #2080 — Arc A770 dispatch-chain parityTested revision GitHub PR #2080 was open at The sole T3 thread returned for #2080 was this run. The public PR conversation showed the author's RTX 5070 Ti test of the same fixtures and no visible independent Arc report or JJAutoCompare comment. This run adds Intel hardware coverage. Tested
$exe = 'L:/XclTooling/pr1512-tiling-edges-fddfa267/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
& $exe 'gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops' --exact --test-threads=1 --nocapture
$wave32 = $LASTEXITCODE
Write-Output "Wave32 test exit: $wave32"
& $exe 'gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange' --exact --test-threads=1 --nocapture
$wave64 = $LASTEXITCODE
Write-Output "Split-wave64 test exit: $wave64"
$global:LASTEXITCODE = if ($wave32) { $wave32 } else { $wave64 }
}
Both fixtures carry live per-lane values, including a packed 64-bit value, across the 16-loop program. The tests checked the whole dispatch against the fixture's independently computed expected vector and then compared the split chain's entire vector with the whole dispatch. Together, 288 words matched with zero differences. Each run filtered out 1,125 tests and exited 0. Total was 2 passed, 0 failed, 0 ignored, 0 explicit Not tested Native wave64, other GPUs, other fixtures or configurations, full workspace suite, retail titles, main-vs-head smoke runs, production D3D12.X dispatch or ExecuteIndirect, and pipeline build or dispatch performance. AI use T3 Code / Codex (gpt-6.2-sol) ran the existing tests, checked the results, and wrote this report. Logs and evidence are in |
|
Thanks, both. @JJAutoCompare: good to have the two chain tests passing on an Arc A770 (288 of 288 words). It's the first non-NVIDIA coverage for this. @WebIdentity1: those are the right cases to push on. Our seeded inputs for ef008c0f take one path per input, so forward edges that skip pieces and divergent early exits get less coverage there than in the unit tests. On the 3D grid: the scratch slot is indexed from the group ID as AI use: Claude Code (Claude Opus 5.5) wrote this reply. |
Adopt WebIdentity1's fixture from xcl-dev#2080. Lanes return early, skip ahead over a piece, or run different numbers of loop iterations. Check the whole and split outputs against the CPU model and guard words on a 2 x 3 x 2 dispatch grid for native wave32 and split wave64. Source: xcl-dev#2080 (comment) Assisted-by: OpenAI Codex (GPT-6) Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
|
@WebIdentity1 thanks, your fixture is now in the PR as 17a984b (test-only, The description check will fail until I add a regression run made on this head. That run is queued. AI use: Claude Code (Claude Opus 5.5) and Codex helpers adapted the fixture and ran the tests, and Claude Code wrote this comment. |
|
AMD RDNA4 data for #2080: the AMD driver builds the split form 8.6× faster. Across 17 split programs, building the whole pipelines takes 991 s; the pieces on 16 threads take 116 s. Even the plain sum of the pieces' build times is 15 % below the whole build. Every build succeeded, and both of the PR's chain tests pass. Setup
Method
Results (mean of 2 rounds; all 2 × 17 whole builds and all 2 × 162 piece builds succeeded)
GPU tests on this card
Read / inference
Not tested
AI use: Claude Code (Claude Opus 5.5) wrote the local timing patch, ran the census, timings and tests, and drafted this. Counts and timings only, no game data. |
|
@bielfreedom thanks, this is very useful: 8.6× on RDNA4 (991 → 116 s over 17 programs), with every build succeeding, is better than what I measured on NVIDIA. I'll add the three programs that build 2× slower than HLSL whole, and the memory peak, to the description. Good catch on On memory: 11.7–13.4 GB peak with 16 pieces building at once is a lot for a 16 GB machine. The PSO worker count and #2098's admission check for large builds (3 GiB of free commit per build) should bound it, but I haven't measured that on a small machine. I'll list it under Not tested. AI use: Claude Code (Claude Opus 5.5) wrote this comment. |
|
@bielfreedom correction to my reply above: I checked, and a native wave64 chain can't happen on this head. A dispatch chain is built only when the hardware wave is 32 ( AI use: Claude Code (Claude Opus 5.5) wrote this comment. |
|
@Kalmarv thanks for checking. That fits the census: on this adapter the 462 programs with a chain are the ones that run as wave32, and the native wave64 ones stay whole. "Native wave64 chains" in my Not tested list doesn't apply on this head.
I'll run the test that checks native wave64 stays whole on this card as soon as it's pushed. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this. |
|
Kalmarv, I used PortBridge to investigate the scratch-traffic follow-up on Grouping four dwords reduced the generated producer/consumer's raw memory operations from 39 to 11, without changing bytes or median GPU time. Keeping a fixed slot for first-piece scalars live on every crossing edge removed actual repeated word transfers. Later pieces only load such a word if an original instruction uses it. The tag, dispatch ordering and maximum scratch size stay the same. Across four RTX 4070 Ti SUPER processes on a generated three-dispatch chain, the larger grid moved from 47.104 to 32.768 µs and was faster in 31/32 paired trials. Each arm matched the expected digest for every lane and seed. The middle piece avoided 16 loads and 16 stores per lane that took it. An independent graph model covered skips, early exits and i64 words, including zero savings when no value qualifies. Source patch, exact extracted slot tests and both sets of raw timings. The GPU result uses authored synthetic shaders on physical wave32, including a two-wave workgroup. I have not measured the amount retained or GPU time on your actual example, or built all of XCL with the candidate. Early measurement on the real split plan would determine whether this narrow first-piece intersection is large enough. AI-assisted PortBridge engineering (OpenAI Codex). |
|
@akimfomin thanks, this goes after the right cost. The handoff is what keeps the split's GPU time at 1.57× the whole program on ef008c0f's late shading path, where each lane moves 1,866 dwords each way. 47 → 33 µs on the three-dispatch chain, with digests matching, is a good sign. I agree the next question is how much the real plans carry through a piece that doesn't use the value. I'm counting that now on the real split plans for ef008c0f, c3ae6819, fb1c6d2d and the rest of the 81 programs. For each chain I compare the dwords per lane stored today with two alternatives: store each value once at the cut where it's defined and load it only in the pieces that use it, and your narrower first-piece version. I'll post the numbers here. If the saving is large, I'd do it as a follow-up PR after this one rather than grow #2080. AI use: Claude Code (Claude Opus 5.5) wrote this comment. |
|
@bielfreedom thanks for the RDNA4 run of AI use: Claude Code (Claude Opus 5.5) wrote this. |
|
@akimfomin the counts on the real split plans, as promised. These are static sums over crossing edges, dwords per lane, stores / loads, not traffic weighted by the path taken:
If each value could be written once and read once per piece that uses it, the bound is 79 % (ef008c0f: 81 %). The narrow version, a first-piece value live on every crossing edge, finds no words in any of the 25 plans. So the general form is the one worth building. Separately, the same handoff turns out to matter for build time too. In one 18k-instruction ef008c0f piece, 38 % of the values the driver has to keep live across blocks are handoff values restored at the piece's entry and first used 8 or more blocks later. So I'm prototyping one change: a fixed slot per value, written once, and loaded where it's used. I'll measure both build time and GPU time, and it'll be a follow-up PR after #2080. The counting is our own; I haven't used your patch. AI use: Claude Code (Claude Opus 5.5) and Codex helpers made the counts, and Claude Code wrote this. |
|
@Kalmarv
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this. |
|
@bielfreedom thanks, I saw it. Your run is the only one that exercises the native-wave64 path, and it's credited under Tested in the description. AI use: Claude Code (Claude Opus 5.5) wrote this. |
|
Thanks for checking the actual plans, Kalmarv. That rules out our narrow candidate for the current 25. I used PortBridge to check one layout option for your broader design: reuse a scalar's slot only after its last consuming dispatch, and keep the original maximum stride as a cap. The strict control avoids same-dispatch reuse, separates overlapping i64 lifetimes, and reverts to the original layout when branch-exclusive values would otherwise expand it. For a value consumed by a phi, the load still has to dominate the selected incoming edge. 864 CPU lane/case checks. Separately, I measured the creation cost of the scratch resources, without running XCL. On RTX 4070 Ti SUPER, one 1 MiB default heap with distinct 64 KiB placed UAV-capable buffers took 0.302 vs 0.699 ms for four and 0.356 vs 2.811 ms for sixteen, including heap creation. One buffer favored the committed form (0.200 vs 0.260 ms). All 27 verification/timing pairs matched every byte. Raw calls, source, and limits. This is one driver's resource-creation microbenchmark. Real size counts per backing allocator and fence-safe retirement would determine whether the grouping is useful. AI-assisted PortBridge follow-up (OpenAI Codex). |
|
Linux, on the CPU only, at Setup: Fedora 44, Ryzen 9 9950X3D, Wine 11.21 Staging, no card used (lavapipe for XCL's pass). Retail title 1.0.2.1,
Read: Not tested: pipeline builds on a card under vkd3d-proton, the title on Linux, and what the pieces compute. AI use: Claude Code (Claude Fable 5.2) built the trees, ran the conversions and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
Adopt WebIdentity1's fixture from xcl-dev#2080. Lanes return early, skip ahead over a piece, or run different numbers of loop iterations. Check the whole and split outputs against the CPU model and guard words on a 2 x 3 x 2 dispatch grid for native wave32 and split wave64. Source: xcl-dev#2080 (comment) Assisted-by: OpenAI Codex (GPT-6) Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
12cd2fa to
8eefdef
Compare
|
A run with vkd3d-proton as the host D3D12. 3 of the new dispatch-chain GPU tests crash the test process inside vkd3d-proton. Tested
Not tested
AI use
|
|
@akimfomin, #2126 is the store-once, load-at-use layout for the real split plans. Each carried value gets one fixed slot, written once by the piece that defines it and loaded at the nearest common dominator of its uses. On the title's three largest programs it builds 1.7–2.1× faster cold than this PR's split. On the late shading path, the split's GPU time drops from 1.59× the whole program's to 1.23×. Your first-piece slot is the narrow case of it, and I've credited it there. The cost is scratch: 3.5–5.4× this PR's per group. Your reuse after the last consuming dispatch is the follow-up for that. It's linked from #2126's Not tested, but nobody has started it yet. AI use: Claude Code (Claude Opus 5.5) wrote this reply. OpenAI Codex (GPT-6.2) wrote #2126's change. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
@JoaoPauluu, thanks, this reproduces. It's vkd3d-proton 3.1's shader converter, not the dispatch chain's D3D12 calls.
A fix on our side would give each piece a single return block. I haven't written or tested it yet. AI use: a Claude Code (Claude Opus 5.5) helper reproduced and traced this, and Claude Code wrote this reply. |
|
@Kalmarv on the measured cost of the chain in the title you asked for: in the only stretch where this title presents with chains in use here (the start of the intro, ~2 fps), the chains are not where the GPU time goes, so this doesn't show a frame-time cost either way. Numbers, for what they're worth. Same machine and tree as my comment above (with the background whole build),
So: no frame-time cost of the split measurable here, and the title is GPU-bound on other programs first. I'll measure again once the world renders. AI-assisted. |
|
Third note on the scratch: it can be large after all, and the bounds are on Pushed, on top of this PR:
Suite on the pushed tree (AMD RDNA4, debug): 1270 passed, 2 failed (#2115, as before), 46 ignored; AI use: Claude Code (Claude Opus 5.5) wrote the code and this on the maintainer's behalf. |
|
Update on the precompile half of my note above: #2338 (@ChalanaGimhanaX) now builds the split pieces under One part stays cold after it. A split program's whole form is built at runtime under the same chained root signature, at AI use: Claude Code (Claude Opus 5.5), from reading |
|
@ivall a first title run of the total bound (NVIDIA, one run, about 80 s of dispatching): scratch alive never passed 430 MiB (46 over the 384 total) in 6,633 chained dispatches, one of which wanted 2,109 MiB in one slab. Setup: RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, 32 GB, Windows 11, release, a retail title.
Not tested: longer runs, AMD, #2322. AI use: Claude Code (Claude Opus 5.5) built and ran the tree, read both logs and wrote this; Claude Fable 5.2 checked the numbers against the logs; checked by a person before posting. |
…SOs in dispatch_chain Two runtime lifetime fixes in `real/dispatch_chain.rs` (follow-up to xcl-dev#2080): 1. When `alloc_pool::enabled()` is true and `alloc_pool::recording_backing(list)` returns `None` (e.g., console command lists and bundles not registered in `alloc_pool`), fall back to the caller's `allocator` instead of `0` so console-list split compute dispatches do not unconditionally degrade to the synchronous unsplit `chain.whole()` fallback. 2. Retain `Arc<Chain>` in `RECORDINGS[allocator]` whenever `allocator != 0` on both the `dispatch()` `whole` fallback and `ExecuteIndirect`'s `dispatch_chain::whole(list, pso, allocator)` path (deduplicating per allocator and dropping any duplicate `Arc<Chain>` outside `RECORDINGS.lock()`), so releasing the PSO (`forget(pso)`) while the command list is still in flight does not destroy the bound `whole` `ID3D12PipelineState` before `allocator_reset(allocator)`. Part of xcl-dev#2088 Part of xcl-dev#1269 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Plan for the whole-form stall that @pvfreis, @claudetools-gh and @KDenKC measured. I'm working on it now, to avoid duplicates. On an RTX 5070 Ti, The fix I'm writing makes ExecuteIndirect run the chain itself, so the whole form isn't needed there at all. A small XCL pass reads the title's argument and count buffers on the GPU and writes per-slab commands for each piece (root constants plus the dispatch, inside @ivall's bounded scratch). Then each piece runs as one ExecuteIndirect, with a UAV barrier between pieces. The whole form stays only for what can't be chained: bundles, no scratch, and signatures that change root arguments. AI use: Claude Code (Claude Opus 5.5); the measurements are from our run. |
|
Taking a small follow-up on main 0829441 (workstream 4 of #2088): make dispatch_slabs a lazy iterator and count slabs while recording. The current runtime builds a slab Vec before the no-scratch whole() fallback, and successful recording builds it twice. A bounded allocation regression with grid [1024,1024,1], most=1, requesting one slab measures 24 MiB on the current code; the lazy version allocates zero and emits the same sequence. CPU and wave32/split-wave64 GPU checks are in progress. This is separate from #2333 and the ExecuteIndirect implementation; noting the dispatch_slabs return-type change for that work. No claim that this caused a reported retail crash. AI use: Codex with subagents; exact model identifier unavailable in this session. |
|
Independent validation on Sequential release workspace results: 1272 passed, 0 failed, 46 ignored. The divergent forward-edge dispatch-chain tests passed on the RTX 3080 Ti with both 32 and 64 threads. The aggregate scratch memory budget test, reused edge payload tests and split Wave64 live-loop tests also passed. All 2000 shader fuzz seeds validated, including 1232 GPU comparisons. ChatGPT assisted with testing and report preparation. |
|
A data point on NVIDIA: with dispatch splitting on, a retail title stops at its world load when its first chained dispatches run; with Setup: RTX 4070 SUPER 12 GB (wave32-only, split wave64), driver 616.92, Ryzen 7 5700X, 32 GB, Windows 10 19045, release. Not plain
In runs 1–3 the last 2 s before the stop had a burst of 1,417–7,579 dispatches and then the title's threads submitted nothing more; the chained-dispatch count did not grow after it (105 / 98 / 50 until the run was stopped minutes later). So it looks like a CPU-side stall at or right after the first chained dispatches rather than a GPU hang (no TDR in 50+ s). I could not see where the threads wait (no debugger on this machine), and did not check which programs those first chains were. Not tested: plain Update – where it waits. With #2333 (
So once the first split programs are dispatched indirectly, each needs its unsplit pipeline built on the title's thread (8–10 s cold here), and nothing builds it ahead: the precompile only makes the whole program under the title's root signature ( Not tested (update): a precompile that also builds the whole program under the chain's root signature. AI use: Claude Code (Claude Opus 5.5) made the runs and wrote this; posted with my OK. |
|
@Eterst @claudetools-gh #2372 builds a split program's whole form on the PSO workers, under It's not shown to fix your trees, and the budget's skips have costs of their own (see Not tested there). The fix I'd rather have, running an ExecuteIndirect as chained pieces so the whole form is rarely needed, is still being built. AI use: Claude Code (Claude Opus 5.5) wrote this comment. |
…SOs in dispatch_chain Three runtime lifetime fixes in `real/dispatch_chain.rs`, `bind.rs`, and `list_x.rs` (follow-up to xcl-dev#2080): 1. When `alloc_pool::enabled()` is true and `alloc_pool::recording_backing(list)` returns `None` (e.g., console command lists and bundles not registered in `alloc_pool`), fall back to the caller's `allocator` instead of `0` so console-list split compute dispatches do not unconditionally degrade to the synchronous unsplit `chain.whole()` fallback. 2. In `list_x::try_split_for_wait`, register newly created mid-list Wait split segments with `alloc_pool::created_on(p as usize, pc_alloc, ty.0)` (and `real::dispatch_chain::list_reset(p as usize)`) so after an allocator swap their split compute scratch and retained PSOs key to the active PC backing allocator `pc_alloc` rather than falling back to the title allocator (which a subsequent `Reset()` can reuse and reset while the split segment on `pc_alloc` is still alive). 3. Retain `Arc<Chain>` in `RECORDINGS[allocator]` whenever `allocator != 0` on both the `dispatch()` `whole` fallback and `ExecuteIndirect`'s `dispatch_chain::whole(list, pso, allocator)` path (deduplicating per allocator and dropping any duplicate `Arc<Chain>` outside `RECORDINGS.lock()`), so releasing the PSO (`forget(pso)`) while the command list is still in flight does not destroy the bound `whole` `ID3D12PipelineState` before `allocator_reset(allocator)`. Part of xcl-dev#2088 Part of xcl-dev#1269 Assisted-by: Google Antigravity (Gemini 4 Neon)
When direct DXIL translation splits a large compute program into a dispatch chain (#2080, under XCL_DIRECT_DXIL=1 or automatically for enormous compute shaders), the runtime builds each piece under dispatch_chain_root_signature and caches its driver blob as .chain.pso. xcl shaders --precompile --pipelines ignored Compiled::dispatch_chain and instead built only the unsplit whole shader under abi_root_signature_with (.pso), which neither the split runtime path nor the Chain::whole() fallback loads. On two split retail compute shaders (RTX 3060, XCL_DIRECT_DXIL=1, XCL_PIPELINE_THREADS=4), prebuild wall time dropped from 117.0 s (0/16 .chain.pso blobs) to 9.2 s cold and 0.4 s warm (16/16 .chain.pso blobs reused). Part of #1833, #2088. Assisted-by: Google Antigravity (Gemini 4 Neon)
…SOs in dispatch_chain Fix four lifetime/bookkeeping issues around `dispatch_chain` and `alloc_pool`: 1. `dispatch_chain::resolve_allocator` previously returned `0` when `alloc_pool::recording_backing(list)` was `None` (untracked / direct PC list or `XCL_ALLOC_SWAP=0`), dropping scratch and retained-PSO cleanup for that list. Fall back to `caller_alloc` (keeping `resolve_allocator` non-zero when `caller_alloc != 0`). 2. `dispatch_chain::dispatch_whole` previously dropped the resolved whole `ID3D12PipelineState` immediately after `SetPipelineState` instead of retaining it against the backing allocator until reset/release, risking use-after-free while GPU execution is in flight. Retain it on `resolve_allocator(list, caller_alloc)`. 3. `list_x::try_split_for_wait` (`None` spare branch) created a fresh mid-list Wait split segment on `pc_alloc = alloc_pool::current(alloc)` without calling `alloc_pool::created_on(p as usize, pc_alloc, ty.0)` (or `real::dispatch_chain::list_reset`), leaving `recording_backing` as `None` after an allocator swap. Register the fresh segment on `pc_alloc` so `resolve_allocator` tracks the swapped backing allocator. 4. `alloc_pool::created_on` used `s.types.entry(raw).or_insert(ty)` instead of `s.types.insert(raw, ty)` (unlike `reset_list`), preserving stale allocator types when a non-adopted test allocator address was reused by a different command-list type. Overwrite with the newly created list's type (`s.types.insert(raw, ty)`). Add unit tests covering `resolve_allocator` / whole-PSO retention and fresh Wait-split segment tracking across an `alloc_pool` swap. Part of xcl-dev#2080 Part of xcl-dev#1452 Assisted-by: Google Antigravity (Gemini 4 Neon)
Part of #1269. The NVIDIA driver's compute pipeline build time grows faster than linearly with program size, roughly N^1.47 on an RTX 5070 Ti. So the title's largest direct-route programs take 14–23 s each to build cold on
main, even after #2034 made them smaller. Cut into pieces of about 12,500 DXIL instructions, the same work builds in parallel on the PSO workers in 2.2–2.5 s.What is in it
crates/xcl/src/gpu/dxil/module/split.rs: partitions the optimized compute entry at CFG edges. A dispatch can't jump back to an earlier one, so each strongly connected component (every loop) stays in one piece. The values live across each crossing edge go to a per-dispatch scratch UAV, one lane-contiguous plane per live dword, indexed by group and logical wave lane. The two wave32 halves of a wave64 stay correct across dispatches.crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs,pso.rs,pso_async.rs: one pipeline per piece, built on the PSO workers. Direct Dispatch records the chain as consecutive dispatches with UAV ordering between them. ExecuteIndirect builds and uses the whole form on demand.XCL_DIRECT_SPLIT_INSTRUCTIONSsets the target instructions per piece (default 12500, 0 disables). It's documented in the README. The split applies to programs on the direct route: all of them withXCL_DIRECT_DXIL=1, and, since Recompiler: enormous compute programs take the direct DXIL translator #2120, the enormous HLSL programs that are rerouted there by default.compute split: piece N of M refusedwarning instead of silently. @ivall found that since Recompiler: an image_load after an image_store of the same image reads the store #2156 noCS_RaytracingResolveprogram split for this reason (comment). Test:dispatch_chain_declares_typed_uav_loads_only_where_they_are, which fails without the fix under the DXC 1.9 validator.BUILDINGcontext, so a title thread waiting for the chain makes all its pieces wanted. A chained pipeline keeps its driver disk blob under its own.chain.psoname, so it no longer overwrites, or reads, the title's own blob for the same DXIL.dispatch_chain_wave32_live_loops,dispatch_chain_wave64_live_loops_and_exchange): they compare a split program that has live values across loops, and a wave64 half exchange, with its unsplit form.dispatch_chain_native_wave64_builds_whole(commit6c34370, test only): a program that native wave64 hardware runs as wave64 gets no chain and keeps its whole pipeline, because chains are built only for 32-wide hardware waves. On a wave64 adapter it also runs the whole pipeline and checks its output. On the RTX 5070 Ti it compiles and validates, and skips the GPU part (no native wave64). @bielfreedom ran it on an RX 9070 XT (RDNA4), where it passed with no skip (comment).dispatch_chain_divergent_forward_edges_3d, a fixture by @WebIdentity1 (commite2db0c0, test only). On a 2×3×2 grid, lanes return early, skip a piece, or run different numbers of loop iterations. The test checks whole and split outputs and guard words against a CPU model, for native wave32 and split wave64.Tested
Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, release, DXC 1.9.2609.
Cold pipeline build (fresh process, 16 threads, implicit caches off), against the whole program from
main:ef008c0f is this head's output; c3ae6819 and fb1c6d2d are from
413e0c0, before the scratch layout change. The slowest piece sets each wall time.Output on the GPU, ef008c0f, two seeded inputs, 64 groups (an early-exit path and the late shading path; a CPU trace of the second runs every piece of a 5-way split and 9 of 10 of a 10-way one): the whole and split forms each write 2048 words, 0 of them different, and match the expected 2048 texels.
GPU time, ef008c0f: at the card's steady P3 state (a compute-only load doesn't hold full clocks, and the clocks weren't locked; each form reproduces within 1% across two jobs, with all forms taking turns in one process), whole 112.5 µs and split 176.8 µs (1.57×) on the late shading path, whole 17.6 µs and split 36.3 µs (2.06×) on the early-exit path. That's over 1.5×: the handoff moves about 30 MB per dispatch on the shading path, and cutting it is follow-up work. Launch plus barrier is under 1 µs per piece.
In the title (120 s,
XCL_DIRECT_DXIL=1, this change at1444f61plus a dispatch trace): 13 programs split into 54 pieces, and 74 chained dispatches ran, all after 70 s (the regression run below, on this head, has 117); exit 0, no device removal. Every compute program the trace saw was dispatched through plain Dispatch until 63.5 s; 33 later ones go through single-command ExecuteIndirect and so use the whole form.AMD RDNA4, measured by @bielfreedom (comment), RX 9070 XT, Ryzen 7 7700, on
af2bd61: across 17 split programs, the whole pipelines take 991 s to build and the pieces on 16 threads take 116 s (8.6×). Every build succeeds, and the two chain tests pass. Peak process memory was 11.7–13.4 GB with up to 16 pieces building at once.Linux, checked by @Royalflamejlh (comment), CPU only, on
17a984b: vkd3d-proton's dxil-spirv turns 4,125 of the 4,130 pieces (478 split programs) into SPIR-V that passesspirv-val. The other 5 hit its known crash (Direct DXIL: xcl pipelines workers overflow their 512 MB stack on big compute programs under Wine #1805) on loops that already crash it in the whole program. With Recompiler: direct DXIL gives every loop head and block one back edge #1860 merged in, all 4,130 convert.Checked by @ettehn (comment) on
6c34370, DXC 1.8.2502: a local compute record that gave 0 pieces before the typed-UAV fix gives 12, and the whole form and every piece pass the validator. With a test against an isolated disk cache, the chained request reads only its.chain.psoblob and the title's own blob stays a hit. With two workers, a helper's piece becomes wanted when the title waits for the chain, and does not without the inheritedBUILDING.cargo test --release --offline --workspace -- --test-threads=4on413e0c0: 1156 passed, 0 failed, 46 ignored, with 24 skip notices (no native wave64, three unsupported per-lane FP cases, no heap windows). Onaf2bd61the two new GPU tests pass: 96 wave32 and 192 split-wave64 output words match the unsplit form, 64-bit values and cross-half exchange included. On17a984ball threedispatch_chaintests pass. The new one splits into three pieces in each geometry, and its 384 and 768 words plus 16 guards match the CPU model in both the whole and split forms.In the title on an RTX 4090, run by @Raghav314 (comment):
main1a0bbe3with6c34370merged, 300 s cold (no DXIL or driver blobs),XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1. 33 programs split into 179 pieces, and 89 chained dispatches ran. The longest cold compute build was 7.9 s. No removal or crash. The world load still stops presenting at about 74 s: 47 of the 57 cold compute builds (146 s of driver time) came after the last present, one after another, so bounding each build doesn't remove that stop by itself. For reference, on another tree (D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) #2057) on the same machine the longest was 12 s, with the same stop.Cold build on an RTX 3060, measured by @pvfreis (comment), on
40d1b15plus the typed-UAV fix, switch windows, 12 threads, driver caches off, median of 3: five programs split into 11–14 pieces each and every piece builds. Whole against all pieces built: ef008c0f 49.4 → 9.1 s, ab570963 41.6 → 5.3 s, 33743bd6 37.1 → 3.8 s, c3ae6819 80.9 → 14.5 s, fb1c6d2d 63.7 → 9.1 s (5.5–9.7×). Without the fix, all five are refused withFlags must match usage.AMD Radeon RX 9070, regression pair by @Toons29 (comment), Ryzen 7 7800X3D, on
40d1b15(this branch before the latest rebase), 60 s of a title on the default route:main568e7db1566 frames and this PR 1632, peak commit 14592 / 14565 MB, no crash or device removal in either.cargo test --workspace -- --test-threads=4(debug) on6c34370, rebased ontomain9633138: 1246 passed, 2 failed, 46 ignored. The two failures,device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaaandpso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator, fail onmain9633138too; Tests: two expectations that no longer match the code #2245 fixed both onmainsince. 25 SKIPPED notices: no native wave64 on this card, three per-lane FP16 forms the per-lane lowering refuses, and no heap windows.Regression run
The branch was rebased onto
main9633138. The conflicts and what changed with them: the translated-cache identity inpso.rs(#2174's compact-nest tag kept, the split tag after it); #2064's container check, now also on the whole form and each piece of a cached chain; #2176 and #2178 inpso_async.rs(the queue here takes closures, so the spared-build resend and the orphan check moved intoenqueue); and the test fixtures, which #2194's merging of straight-line blocks left with too few cut points, so they now branch on the lane index.scripts/smoke.ps1 -Seconds 120, the same retail title, one after the other on the machine under Tested, release builds from clean trees.main9633138(this PR's base):this PR,
6c34370:PR vs
main: 1310 / 1323 frames (99 %), peak commit 29471 / 29175 MB (101 %); device removals 0 and crashes 0 on the PR run, 0 and 0 onmain.Both runs use
XCL_DIRECT_DXIL=1and start with the same private XCL pipeline cache, holding only the pipeline list; the driver's own cache was left alone. The PR run loggedcompute split: 29 programs split, 132 pieces built, 117 chained dispatches issuedat 120 s (0 by 60 s, all 117 by 70 s), and nopiece ... refusedwarning. Before the rebase,8eefdeflogged 25 programs, 117 pieces, 90 chains in the same setup; how far the title gets before it stops varies between runs. Both runs present no frames in their last 6 s, for a reason this change doesn't touch.Not tested
master(30b0eb9) converts the same pieces as well as it converts the whole programs: 4,125 of 4,130, all valid, and the 5 failures are Direct DXIL: xcl pipelines workers overflow their 512 MB stack on big compute programs under Wine #1805's. The three tests that crash on 3.1 pass with it under Wine on an RTX 2060. Giving each piece a single return block doesn't fix 3.1 by itself (282 crashes and 1,152 invalid of the rest, in the same pass). WithoutXCL_DIRECT_DXIL=1only the enormous programs Recompiler: enormous compute programs take the direct DXIL translator #2120 reroutes can split.af2bd61(only the split module's tests ran there).XCL_DIRECT_DXIL=1.Scope. This PR splits wave32 programs and single-wave 64×1×1 wave64 programs without group shared memory or UAV atomics (only AND/OR atomics whose results are unused are allowed); everything else keeps the whole pipeline. ExecuteIndirect also uses the whole form. A follow-up PR is in progress for multi-wave wave64 groups (8×16 and 16×16), which covers the cascade-shadow programs: in the 120 s run, seven of them, 70–125k instructions each, are declined for their group shape alone and build one at a time for 11–26 s each. Group shared memory, atomics and ExecuteIndirect come after that.
AI use
OpenAI Codex (GPT-6) wrote the split pass, the runtime chain and the tests. Claude Code (Claude Opus 5.5) helpers ran the driver timings and GPU checks, and Claude Code wrote this description and opened the PR.
🤖 Generated with Claude Code