Repository navigation
Recompiler/D3D12.X: rebase #2353 (multi-wave/LDS dispatch chains) and split two-pass mesh producers - #3504
Recompiler/D3D12.X: rebase #2353 (multi-wave/LDS dispatch chains) and split two-pass mesh producers#3504Kalmarv wants to merge 11 commits into
Conversation
65b7be4 to
ae6816b
Compare
ae6816b to
3ee900b
Compare
3ee900b to
f8d879a
Compare
Single-wave 2D/3D native wave32 compute groups (y * z > 1, total <= 32) no longer allocate @xcl_wt or emit the wave-index atomic and barriers, since tid equals WaveGetLaneIndex(). Multi-wave 2D/3D groups also skip the trailing barrier unless sharing xcl_lds[8191]. Extend direct DXIL compute dispatch splitting to all full-wave native wave32 threadgroup shapes without guest LDS (total >= 32, total % 32 == 0): size per-group scratch by total threads, preserve @xcl_wt only as the wave-ID prefix for multi-wave 2D/3D groups while gating the wave64 exchange state machine on xcl_xs, select FlattenedThreadIdInGroup() for multi-wave 1D groups, and recompute Feature::WaveOps per piece so pieces without wave ops validate. Part of xcl-dev#1269, xcl-dev#2088. Assisted-by: Antigravity (Gemini 4 Neon)
Use the workgroup's flat logical thread ID for the continuation of each wave32 half. Keep each counter signal with its peer wait, and transfer the per-half arrival counters and double-buffered exchange slots at a group-wide rendezvous between pieces. Wave allocation starts afresh in each piece. Leave guest LDS and partial guest waves on the whole path. Exercise four wave64s with different exchange epochs across repeated cuts and compare every output word to the whole shader and a CPU oracle. Assisted-by: OpenAI Codex (GPT-6) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adopt WebIdentity1's four-wave fixture. Two guest waves return at different points while the other waves keep exchanging. Compare the whole shader and the dispatch chain to the CPU oracle across a 3D grid. Source: xcl-dev#2097 (comment) Assisted-by: OpenAI Codex (GPT-6) Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
The dispatch-chain splitter kept every program with guest LDS whole: its mutable-global check refused xcl_lds, and its scan refused LDS loads, stores and atomics and guest barriers. Now the LDS (with the split form's exchange words at its top) is copied to the per-group scratch at each piece exit and back at the next piece's start, like the exchange slots of several split waves. Geps into it can cross a cut as their index. In the split form the lane counter lives in the LDS too, so a piece meets once more before restoring over it. One console wave follows the guest's scalar control flow, so any cut keeps its guest barriers paired. A group of several waves can branch and return apart: a piece of such a program starts only at a component every thread enters exactly once (no earlier edge jumps past it, no earlier block returns), and a loop that reads the LDS (a load or an atomic), which could poll for another wave's write past a cut, keeps the program whole.
Large direct DXIL compute shaders with guest LDS stayed whole when a single native wave32 was laid out across multiple group dimensions, or when a full guest wave64 used two hardware wave32 halves. Admit native wave32 LDS groups by their 32-thread count. Pass the flat split lane ID for a 64-thread LDS group so each piece can replay lane allocation before restoring LDS. Exercise three wave32 shapes and an 8x4x2 split wave64 group, and reject a two-wave native LDS group. Earlier measurements on an RTX 3060 with cold caches compared whole pipeline builds with pieces built in parallel: 219287eb2f6021fe 217.2 s -> 9.2 s 7b468aa4210b1810 74.9 s -> 5.9 s df45a39c275d0db5 65.7 s -> 4.0 s Assisted-by: OpenAI Codex (GPT-6.2 Sol) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rier A program of several hardware waves whose guest s_barrier became the early-exit-safe barrier (`Lw::safe_barrier_sync`: groupshared `xcl_bar`, a live-wave count and an arrival/generation word, polled with atomics) stayed whole: the planner refused the `xcl_bar` global, its atomics and fences. A retail title's 253 KB mesh producer (128 threads, split wave64, no LDS) had no other blocker. The planner now lets the barrier through. Its two words are saved and restored at each cut like the LDS, and a GEP into it is transported by its index. Its group syncs are allowed only in `Block(0)` (its set-up), where every thread starts; its polls use TGSM fences only. Cuts need not be where the whole group passes: pieces follow the program's flow (components in topological order) and keep a loop whole, so a wave polling at a barrier in a piece waits only for waves that reach that barrier in that piece or have already arrived. Test: four hardware waves, three barriers between wave-divergent loops and branches, cut into 14 pieces where the waves do not pass together; results and the barrier words (four waves alive, generation 3) match the whole program on an RTX 5070 Ti. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The compute pass of a two-pass mesh pipeline (the console mesh program writing one record per group) was always one compute pipeline. A retail title's 253 KB foliage producer took the NVIDIA driver 6.7 s cold, the longest compile of the pipelines its world needs. The direct translator now plans a chain for an `Entry::Mesh` (split wave64, a multiple of 64 threads, no LDS but a single wave's) as it does for a compute program, and the translation keeps it (`TwoPass::cs_chain`). `finish_two_pass` builds the pieces with `dispatch_chain::build` when the whole form is not ready from a cache (memory, disk or pipeline library); a library being built keeps the whole. A direct DispatchMesh runs the chain; an ExecuteIndirect runs the chain's whole form (`whole_ready`; skipped while it is still being built), and XCL_TWO_PASS_BATCH=2 does not defer a chain. Measured on an RTX 5070 Ti, 8 cold graphics/mesh recipes replayed with `xcl shaders --graphics-records --threads 8`, translation warm, driver cache off: wall 6.99 / 7.09 / 7.09 s before, 6.13 / 6.12 / 6.18 s after; peak commit 1.07 - 1.13 GB before, 0.93 - 0.96 GB after. The foliage producer's 6.65 - 6.76 s became four pieces of 71 - 113 KB (longest 1.73 - 1.84 s), a 123 KB depth producer's 2.53 s two pieces (longest 1.17 - 1.26 s). The batch is now bound by its 300 KB graphics pipelines (4.8 - 6.0 s). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2bbfff6 to
dac9378
Compare
|
Independent Windows Release check of The mesh fixture's pixel and record checks use an ordinary compute producer. Its direct-backend slice passes OpenAI Codex (GPT-6.2 Sol) assisted with source review and Windows verification. |
|
Thank you @ettehn for the independent RTX 5070 Ti verification on |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check claim |
1 similar comment
|
merge-check claim |
|
merge-check |
|
Ran the Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, All 28 tests in that module pass here, including the dispatch-chain cases of the description ( Not tested: the full workspace suite, the 24-thread cold archive precompile, the 29-minute live title run, a retail title in Series X mode, native wave64 hosts, AMD and Intel GPUs, Wine, release profile, game data. AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
bmjask
left a comment
There was a problem hiding this comment.
Review of dac93786: 2 finding(s). 2 are inline.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| // whole group passes. A loop that reads the LDS (a load or an atomic) | ||
| // may poll it until another wave writes past a cut, so such a loop | ||
| // keeps the program whole. | ||
| let plan = self.m.dispatch_plan(limit, lds.filter(|_| multi).map(|_| &reads))?; |
There was a problem hiding this comment.
The rule that cuts only where the whole group meets is applied only to programs with guest LDS (lds.filter(|_| multi)). Multi-wave programs whose only shared state is xcl_bar (the early-exit-safe barrier) are planned with uniform = None, so a cut can fall where waves are on different paths to their next S_BARRIER. Take native wave32 [64,1,1], or split wave64 [128,1,1] with no LDS, where wave 0 reaches an s_barrier in block X and wave 1 one in block Y, which is legal on RDNA since any barrier counts. If X lands in piece k and Y in piece k+1, wave 0 polls xcl_bar in piece k while wave 1 has already gone to the checkpoint at the end of piece k. Wave 0 spins 2^20 iterations, takes the timeout path, decrements alive and stops counting, so later barriers don't wait for it. The result is wrong values and a large GPU stall per group. Applying the uniform-cut rule whenever the group has more than one wave, LDS or not, would avoid it.
| return Ok(()); | ||
| } | ||
| // (a compute pass cut into a chain runs its whole form: the group counts are the GPU's) | ||
| let whole = match super::real::dispatch_chain::whole_ready(tp.compute)? { |
There was a problem hiding this comment.
Two-pass ExecuteIndirect of a chained mesh producer now needs the separately built whole form. While it's Late, the draw is skipped with an Err, and when cs_goes_on() is false the title thread compiles it synchronously. Before, finish_two_pass built one whole compute PSO that indirect mesh draws used. Now the pieces are built at PSO creation, and the first indirect draw queues a second compile of the whole program: the PR's own 253 KB producer takes 5.1 s on NVIDIA. Until then, every ExecuteIndirect(DispatchMesh) with that PSO logs "still being built" and is dropped, so geometry is missing for seconds. With cs_goes_on() off, the render thread stalls ~5 s, the stall this PR set out to remove, and driver work roughly doubles. Running the companion dispatch through dispatch_chain::execute_indirect (as compute indirect does), or not chaining producers that are only drawn indirectly, would avoid it.
|
Closing as superseded: all 11 commits from this PR landed on Thanks @bmjask for the two inline correctness findings ( |
Rebases #2353 (by @zohaiblazuli, @joeypercia, @saintwolf — multi-wave & guest-LDS compute dispatch chains) cleanly onto current
mainand stacks two-pass mesh-producerDispatchChainsplitting (using the early-exit-safe barrier) on top.What is in it
[32, 1, 1], carry wave64 partner exchanges across dispatch pieces, keep exited guest waves in dispatch checkpoints, split direct compute programs with guest LDS of any shape, and reconcile spin exchanges with the timeout path.crates/xcl/src/gpu/dxil/module/split.rs: cut dispatch chains with the early-exit-safe barrier.crates/xcl/src/hle/d3d12x/: build and run two-pass mesh producers as dispatch chains.Tested
scripts/smoke.ps1on this exact head queued next.Regression run
main:PR head:
Not tested
AI use