Recompiler: wave-local remap and null guard cut cold compute PSO compiles #2554

Open
github-bot wants to merge 1 commit from github-bot/gh-2554 into main AGit
Owner

@⁠brandostrong on GitHub · 2026-11-25 22:45 UTC · original
brandostrong:wave-local-remap → main · +380 −48 · 10 files · 1 commits · open

Cold CreateComputePipelineState for a large split-wave64 compute program (a 1.5 MB cascade-shadow
resolve) was 38.3 s on an RTX 4090. Driver time tracks control-flow complexity, not bytes. Two
XCL-generated constructs dominate it: the wave64 exchange's spin loop (~16 s, its mere presence)
and the per-accessor out-of-window guard branch (~6 s, duplicated at every heap access). This PR
removes both, losslessly, for the programs where they are not needed.

What is in it

  • Memory: null descriptors for out-of-window heap accesses — console_heap.rs adds two null
    raw UAVs just past the window slots (MEM_NULL_LOAD reads 0, MEM_NULL_STORE discards writes);
    general allocation starts after them. No behaviour change until the emit path uses them.
  • Recompiler: branchless window guard via null descriptors — emit.rs mem_accessors redirects
    out-of-window load/store to the null descriptors with a select (no divergent branch);
    interlocked accessors keep the guard (they must return 0 and not modify). Differential test:
    out-of-window load/store/interlocked semantics unchanged.
  • Recompiler: wave-local compute runs one console wave per group — a split-wave64 compute program
    that shares nothing across its console waves (no LDS, no s_barrier) gets one console wave per
    hardware group, so the exchange's two halves are the whole group and meet with a group barrier
    instead of the spin loop. The console view is preserved (group id = hw id / ratio, thread id
    adds the wave offset); dispatch_ratio / dispatch_dim tell the runtime to launch ratio
    hardware groups per console group along dim, applied at dispatch_chain::dispatch. Indirect
    dispatch (ExecuteIndirect) reads group counts from the title's buffer on the GPU, so the CPU ratio
    cannot scale them: a lazily-built non-remapped fallback PSO (remap_fallback in real.rs, swapped
    in at bind.rs) is bound instead for a remapped pipeline, driven by Options.no_remap. forget_pso
    now clears the per-PSO dispatch ratio, so a reused PSO address no longer inherits a stale one.
    Differential test: a wave-local compute program gives identical output remapped; a non-wave-local one
    is unchanged.

Tested

  • hardware: RTX 4090 (NVIDIA), driver 32.0.16.1664, CPU i9-13900K, Windows 11 Pro build 26200,
    rustc 1.100.0, release
  • cargo test --workspace --release -- --test-threads=4: 1220 passed, 1 failed, 26 ignored (the 26
    are wave64 GPU tests that skip on this 32-lane NVIDIA adapter; the 1 failure is the same
    pre-existing lower_dxil test below)
  • cargo test -p xcl --lib --release recomp: 373 passed, 1 failed, 19 ignored — the 1 failure is
    lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, pre-existing
    on this NVIDIA adapter (present on clean main 68a284a; CI has no GPU), not from this change
  • goal measure xcl shaders shaders.rpf --measure-pso 062468c09af883b9 --windows 4 with
    XCL_HEAP_WINDOWS=1: median 12.33 s / 13.79 s over two runs (was 38.3 s), DXIL 1.50 MB → 1.08 MB
  • head-vs-main cold --measure-pso (repeat 1, same run window, uncontended), the 4 largest compute
    records: cascade-shadow 73fb752d7f62c3a5 17.9 s vs 53.1 s (−66 %), 062468c09af883b9 19.4 s vs
    42.5 s (−54 %); irradiance 517e7bab67ece93f 21.9 s vs 23.4 s (−6 %), 193d9a08bf6784bd 20.2 s vs
    21.1 s (−4 %). The win is concentrated on the wave64-spin cascade class; the irradiance records are
    not spin-dominated. Single cold samples are load-sensitive (the target's repeat-3 median above is 12.33 s)

Regression run

  • not run here: scripts/smoke.ps1 on a retail title was not executed for this PR (see Not tested).
    Help wanted: a scripts/smoke.ps1 -Game <title> run on main and on this head from anyone with a
    retail title (wave64 or wave32 adapter) would close the regression gap — post the two xcl-smoke
    blocks to #42.

Not tested

  • AMD / other drivers (measured on NVIDIA 4090 only; the levers change emitted DXIL, so they are
    driver-general by construction, but not measured on AMD)
  • indirect dispatch of a remapped program is handled by the fallback PSO but is not exercised by a GPU
    test (no title in the suite indirect-dispatches a wave-local remapped program); the fallback's
    translation is covered by the no_remap unit test
  • multi-dimensional and LDS/barrier compute groups (remap scoped to wave-local, clean multiple of 64)
  • the direct-DXIL path (XCL_DIRECT_DXIL=1) — remap is in the HLSL path only
  • no regression run on a retail title (scripts/smoke.ps1 not run); the change is validated by the
    recomp GPU suite and the head-vs-main compile benchmark above

AI use

  • Claude Code; wrote the code, the tests, and this description
**@⁠brandostrong** on GitHub · 2026-11-25 22:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2554) `brandostrong:wave-local-remap` → `main` · +380 −48 · 10 files · 1 commits · open Cold `CreateComputePipelineState` for a large split-wave64 compute program (a 1.5 MB cascade-shadow resolve) was 38.3 s on an RTX 4090. Driver time tracks control-flow complexity, not bytes. Two XCL-generated constructs dominate it: the wave64 exchange's spin loop (~16 s, its mere presence) and the per-accessor out-of-window guard branch (~6 s, duplicated at every heap access). This PR removes both, losslessly, for the programs where they are not needed. **What is in it** - `Memory: null descriptors for out-of-window heap accesses` — `console_heap.rs` adds two null raw UAVs just past the window slots (`MEM_NULL_LOAD` reads 0, `MEM_NULL_STORE` discards writes); general allocation starts after them. No behaviour change until the emit path uses them. - `Recompiler: branchless window guard via null descriptors` — `emit.rs` `mem_accessors` redirects out-of-window load/store to the null descriptors with a `select` (no divergent branch); interlocked accessors keep the guard (they must return 0 *and* not modify). Differential test: out-of-window load/store/interlocked semantics unchanged. - `Recompiler: wave-local compute runs one console wave per group` — a split-wave64 compute program that shares nothing across its console waves (no LDS, no `s_barrier`) gets one console wave per hardware group, so the exchange's two halves are the whole group and meet with a group barrier instead of the spin loop. The console view is preserved (group id = hw id / ratio, thread id adds the wave offset); `dispatch_ratio` / `dispatch_dim` tell the runtime to launch `ratio` hardware groups per console group along `dim`, applied at `dispatch_chain::dispatch`. Indirect dispatch (`ExecuteIndirect`) reads group counts from the title's buffer on the GPU, so the CPU ratio cannot scale them: a lazily-built non-remapped fallback PSO (`remap_fallback` in `real.rs`, swapped in at `bind.rs`) is bound instead for a remapped pipeline, driven by `Options.no_remap`. `forget_pso` now clears the per-PSO dispatch ratio, so a reused PSO address no longer inherits a stale one. Differential test: a wave-local compute program gives identical output remapped; a non-wave-local one is unchanged. **Tested** - hardware: RTX 4090 (NVIDIA), driver 32.0.16.1664, CPU i9-13900K, Windows 11 Pro build 26200, rustc 1.100.0, release - `cargo test --workspace --release -- --test-threads=4`: 1220 passed, 1 failed, 26 ignored (the 26 are wave64 GPU tests that skip on this 32-lane NVIDIA adapter; the 1 failure is the same pre-existing `lower_dxil` test below) - `cargo test -p xcl --lib --release recomp`: 373 passed, 1 failed, 19 ignored — the 1 failure is `lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, pre-existing on this NVIDIA adapter (present on clean `main` 68a284a; CI has no GPU), not from this change - goal measure `xcl shaders shaders.rpf --measure-pso 062468c09af883b9 --windows 4` with `XCL_HEAP_WINDOWS=1`: median 12.33 s / 13.79 s over two runs (was 38.3 s), DXIL 1.50 MB → 1.08 MB - head-vs-main cold `--measure-pso` (repeat 1, same run window, uncontended), the 4 largest compute records: cascade-shadow `73fb752d7f62c3a5` 17.9 s vs 53.1 s (−66 %), `062468c09af883b9` 19.4 s vs 42.5 s (−54 %); irradiance `517e7bab67ece93f` 21.9 s vs 23.4 s (−6 %), `193d9a08bf6784bd` 20.2 s vs 21.1 s (−4 %). The win is concentrated on the wave64-spin cascade class; the irradiance records are not spin-dominated. Single cold samples are load-sensitive (the target's repeat-3 median above is 12.33 s) **Regression run** - not run here: `scripts/smoke.ps1` on a retail title was not executed for this PR (see Not tested). **Help wanted:** a `scripts/smoke.ps1 -Game <title>` run on `main` and on this head from anyone with a retail title (wave64 or wave32 adapter) would close the regression gap — post the two `xcl-smoke` blocks to [#42](https://github.com/ivall/xcl/issues/42). **Not tested** - AMD / other drivers (measured on NVIDIA 4090 only; the levers change emitted DXIL, so they are driver-general by construction, but not measured on AMD) - indirect dispatch of a remapped program is handled by the fallback PSO but is not exercised by a GPU test (no title in the suite indirect-dispatches a wave-local remapped program); the fallback's translation is covered by the `no_remap` unit test - multi-dimensional and LDS/barrier compute groups (remap scoped to wave-local, clean multiple of 64) - the direct-DXIL path (`XCL_DIRECT_DXIL=1`) — remap is in the HLSL path only - no regression run on a retail title (`scripts/smoke.ps1` not run); the change is validated by the recomp GPU suite and the head-vs-main compile benchmark above **AI use** - Claude Code; wrote the code, the tests, and this description
Cold CreateComputePipelineState for a 1.5 MB split-wave64 cascade-shadow
resolve was 38.3 s on an RTX 4090. Driver time tracks control-flow
complexity, not bytes; two XCL-generated constructs dominate it: the wave64
exchange's spin loop (~16 s, its mere presence) and the per-accessor
out-of-window guard branch (~6 s, duplicated at every heap access).

A compute program that shares nothing across its console waves (no LDS, no
s_barrier) is wave-local: mapping one console wave per hardware group makes
the exchange's two halves the whole group, so it meets with a group barrier
instead of the spin loop. The console view is preserved (group id = hw id /
ratio, thread id adds the wave offset); dispatch_ratio/dispatch_dim tell the
runtime to launch ratio groups per console group. Indirect dispatch reads
group counts from the title's buffer on the GPU, so a lazily-built
non-remapped fallback PSO is bound instead for a remapped pipeline.
forget_pso now clears the per-PSO ratio so a reused address is not stale.

Out-of-window heap loads/stores redirect to two null descriptors (read 0,
discard writes) via a select, dropping the divergent branch; interlocked
accessors keep the guard (they must return 0 and not modify).

Measured on an RTX 4090: target record 062468c09af883b9 --measure-pso
--windows 4 median 12.33 s (was 38.3 s), DXIL 1.50 -> 1.08 MB. Cold head vs
main (repeat 1, same window): 19.4 vs 42.5 s (-54%) and 17.9 vs 53.1 s
(-66%) on the cascade class. recomp GPU suite green (1220/1/26; the 1 failure
is a pre-existing lower_dxil test on this 32-lane adapter).

Co-Authored-By: Claude Code <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:40 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 23:06 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (crates/xcl/src/gpu/recomp/pso.rs) — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 23:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7177164359) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`crates/xcl/src/gpu/recomp/pso.rs`) — needs a rebase before it can be tested.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 23:15 UTC · original

AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: no failure from this PR in the GPU suite. I did not measure cold PSO compile times, which is what the "not measured on AMD" line is about.

Head ca6f17b tested as is (on its base 68a284a), because it no longer applies on current main 08db802: emit.rs and pso.rs conflict. Debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4, card chosen with XCL_ADAPTER:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010): 648 passed, 3 failed, 22 ignored, 6 SKIPPED. Two of the failures are the AMD fuzz seeds tracked in #2115.
  • RTX 3060 (driver 32.0.16.1088): 650 passed, 1 failed, 22 ignored, 24 SKIPPED.

The remaining failure on both cards is gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (group barriers in the program: left 3, right 1). It fails the same way on the base 68a284a without this PR, on both cards, and it passes on current main. So it comes from the old base, and a rebase should clear it.

Not tested: cold --measure-pso timings on AMD (no retail pack used here), Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 23:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7177326676) AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: no failure from this PR in the GPU suite. I did not measure cold PSO compile times, which is what the "not measured on AMD" line is about. Head `ca6f17b` tested as is (on its base `68a284a`), because it no longer applies on current `main` `08db802`: `emit.rs` and `pso.rs` conflict. Debug, Windows 11 Pro 26200, `cargo test -p xcl --lib -- gpu:: --test-threads=4`, card chosen with `XCL_ADAPTER`: - **RX 9070 XT** (RDNA4, driver 32.0.32029.2010): 648 passed, 3 failed, 22 ignored, 6 SKIPPED. Two of the failures are the AMD fuzz seeds tracked in #2115. - **RTX 3060** (driver 32.0.16.1088): 650 passed, 1 failed, 22 ignored, 24 SKIPPED. The remaining failure on both cards is `gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` (group barriers in the program: left 3, right 1). It fails the same way on the base `68a284a` without this PR, on both cards, and it passes on current `main`. So it comes from the old base, and a rebase should clear it. Not tested: cold `--measure-pso` timings on AMD (no retail pack used here), Intel, a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠bielfreedom on GitHub · 2026-11-26 01:55 UTC · original

AMD Windows, for the "not measured on AMD" line: on an RX 9070 XT (native wave64) this PR does not change the DXIL of any of the 2,689 retail compute programs, with switch or heap windows. So there is no AMD driver time to measure; the gain is on the split-wave64 path, which GPUs with 64-lane waves do not take.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010. Ryzen 7 7700, 32 GB RAM, Windows 11, release.
  • Builds: this PR at ca6f17b and its base 68a284a, each with a local patch in xcl shaders that writes every program's DXIL size and hash to a file.
  • Offline: xcl shaders <retail shaders.rpf> --precompile --only cs with XCL_DIRECT_DXIL=1, a fresh translation cache per run.
windows base 68a284a this PR programs changed
switch (default) 876,842,304 B 876,842,304 B 0 of 2,689
heap (XCL_HEAP_WINDOWS=1) 731,495,396 B 731,495,396 B 0 of 2,689

I did not run the GPU suite (DarkPanda69 did, above) or a title.

AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.

**@⁠bielfreedom** on GitHub · 2026-11-26 01:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7180281283) **AMD Windows, for the "not measured on AMD" line: on an RX 9070 XT (native wave64) this PR does not change the DXIL of any of the 2,689 retail compute programs, with switch or heap windows. So there is no AMD driver time to measure; the gain is on the split-wave64 path, which GPUs with 64-lane waves do not take.** **Setup** - GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010. Ryzen 7 7700, 32 GB RAM, Windows 11, release. - Builds: this PR at `ca6f17b` and its base `68a284a`, each with a local patch in `xcl shaders` that writes every program's DXIL size and hash to a file. - Offline: `xcl shaders <retail shaders.rpf> --precompile --only cs` with `XCL_DIRECT_DXIL=1`, a fresh translation cache per run. | windows | base `68a284a` | this PR | programs changed | |---|---:|---:|---:| | switch (default) | 876,842,304 B | 876,842,304 B | 0 of 2,689 | | heap (`XCL_HEAP_WINDOWS=1`) | 731,495,396 B | 731,495,396 B | 0 of 2,689 | I did not run the GPU suite (DarkPanda69 did, above) or a title. **AI use:** Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/emit.rs
  • crates/xcl/src/gpu/recomp/pso.rs
  • crates/xcl/src/hle/d3d12x/real.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2554/head:github-bot/gh-2554'
git switch 'github-bot/gh-2554'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2554'
git switch 'github-bot/gh-2554'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2554'
git switch 'github-bot/gh-2554'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2554'
git switch 'main'
git merge --squash 'github-bot/gh-2554'
git switch 'main'
git merge --ff-only 'github-bot/gh-2554'
git switch 'main'
git merge 'github-bot/gh-2554'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.