Skip to content

Recompiler: take native compute mask branches across the whole wave - #1910

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
Kalmarv:whole-wave-branches
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
Kalmarv:whole-wave-branches

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1269. Builds on #1866 (merged), the mixed-mask SCC fix.

What is in it

  • Compute shaders with complete native hardware waves keep all lanes on the same console control-flow path. VCC and EXEC zero tests inspect the full mask. Scalar mask operations set SCC from the full result, including comparisons and WQM.
  • The mask analysis treats the branch decision as independent of each lane's mask bit. Vector writes and memory side effects retain their EXEC guards where needed. Split waves, partial final waves, graphics and the kernel test ABI keep their existing lowering.
  • The regression programs cover VCC bits outside EXEC, both branch polarities, a mismatch confined to the high half of a native wave64, loop-carried SCC, and mixed mask/number operands.

Tested

  • Windows 11 Pro build 26200, Ryzen 9 9950X, GeForce RTX 5070 Ti (driver 610.74), rustc 1.99.0 MSVC, release build, DXC 1.9.2609.5.
  • cargo test --offline --release --workspace -- --test-threads=4: 962 passed, 0 failed, 43 ignored. 22 skip notices (18 native wave64, 3 unsupported f16 cases, 1 heap windows). All ten new native wave32 GPU readbacks passed.
  • Native compute survey with four switch-selected memory windows: the per-lane form produces DXIL for 579 of 2,689 compute programs on this change, up from 316 on Per-lane: track the SCC of mixed mask and number operations #1866 (+263, none lost). 8 of the 19 slowest programs (all native wave32) and both of the two largest (native wave64, translation only) now take it; none did before. The scan was on 6df9a936, the same change before the rebase onto main.
  • In a cold-driver timing comparison on the original implementation (a9658976 on Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) #1745), the eight hot native wave32 programs took 43.6 s with per-lane heap windows and 37.9 s with HLSL heap windows. Two of eight were faster on the per-lane path. With switch windows the corresponding totals were 164.4 s and 87.5 s. One sample per form and program.

Regression run

scripts/smoke.ps1, the same retail title for 60 s each, one after the other on the machine under Tested, release builds from clean trees.

main 62265d3 (this PR's base):

xcl-smoke v1
commit: 62265d3bbde2255f849fb650cc29872df91a4cf0
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1303 (PresentX 1303)
presents per 2 s (last 3): 17 31 59
device removals: 0
crashes: 0
peak commit: 27222 MB

this PR, 714d8c7:

xcl-smoke v1
commit: 714d8c7bfece821ecb270b48b19920cdb2373d01
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1284 (PresentX 1284)
presents per 2 s (last 3): 18 41 41
device removals: 0
crashes: 0
peak commit: 27411 MB

PR vs main: 1284 / 1303 frames (99 %), peak commit 27411 / 27222 MB (101 %); device removals 0 and crashes 0 on the PR run, 0 and 0 on main.

The workspace run and the pack count under Tested ran on 6df9a93, this change before its rebases onto main (now 62265d3, which includes #1866); both rebases applied without conflicts. On 0a28873 the CPU control-flow test and all ten native wave32 GPU readbacks passed with no skip; on f583e01, gpu::recomp passed 265 / 0 / 18. A separate NVIDIA driver build was running in another process during both runs.

Not tested

  • Native wave64 on physical hardware. CPU tests cover wave64, and the two largest native wave64 programs were checked for translation only.
  • Full output equivalence on the retail programs. The smoke pair is a regression check of the title. The synthetic readbacks exercise the new branch semantics.

AI use

OpenAI Codex (GPT-6.2) implemented the lowering and the tests, measured pack coverage and drafted this description. Claude Code (Claude Opus 5.5) edited it and opened the PR; no person reviewed the code before posting.

🤖 Generated with Claude Code

@Kalmarv
Kalmarv force-pushed the whole-wave-branches branch from 6df9a93 to 0a28873 Compare November 24, 2026 23:03

@Melow-code Melow-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole-wave mask check for compute is the right direction — partial masks cause divergence that the console shader does not expect. The SCC tracking for mask ops needs an AMD wave64 test before merge, since NVIDIA wave32 and AMD wave64 disagree on exec-zero semantics.

@thehollowedone

Copy link
Copy Markdown

Independent Windows check of 0a28873 on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11.

With XCL_DIRECT_DXIL=1 XCL_PER_LANE=1, I passed the stock branch fixture through the production console shader translator in three configurations. The native 32-thread group selected per-lane DXIL and wrote 5 in all 32 lanes. The 31-thread group selected per-instruction DXIL and wrote 9 in all 31 lanes because the predicate's lane 31 was absent. Split wave64 also selected per-instruction DXIL and wrote 5 in all 64 lanes when lane 63 set VCC. The selected DXIL and the HLSL reference each matched all 96 readback words in every case, including the untouched sentinels.

cargo test --offline --locked -p xcl --lib branch -- --nocapture --test-threads=1: 18 passed, including the stock native-wave tests and the scratch routing fixture. Zero skips. Synthetic inputs.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the fixture and drafted this report.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@ruipedro-pinheiro thanks. We have no AMD card here, so we can't run that ourselves. What the change does on native wave64 now:

  • The whole-wave path is taken only when every hardware wave of the group is complete. On native wave64 that's a full 64-lane wave, so an EXEC-zero test reads all 64 bits there, as on the console. Partial last waves, split wave64 on 32-lane hardware, graphics and the kernel test ABI keep the existing per-instruction lowering. @thehollowedone's check above shows the 31-thread and split-wave64 cases taking that path on NVIDIA.
  • The CPU test native_wave_branches_keep_inactive_lanes_in_scalar_control_flow covers wave64, including a mismatch only in the high half. The GPU readback native_wave_branches_on_the_gpu skips without native wave64, so it has only run on 32-lane hardware so far.

@eizispark @DarkPanda69, you ran native wave64 on #1912 and #1866: could one of you run this on 0a28873?

cargo test -p xcl --lib -- native_wave_branches --nocapture --test-threads=1

It needs to report that native_wave_branches_on_the_gpu ran without a skip.

AI use: Claude Code (Claude Opus 5.5) wrote this.

@Kalmarv
Kalmarv force-pushed the whole-wave-branches branch from 0a28873 to f583e01 Compare November 24, 2026 23:47
@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Head is now f583e01: restacked on #1866's c61f53d after review fixes there and on #1912. The whole-wave change itself is unchanged. gpu::recomp on an RTX 5070 Ti: 265 passed, 0 failed, 18 ignored. @eizispark @DarkPanda69 if you run the native wave64 check I asked about above, please use f583e01.

AI use: Claude Code (Claude Opus 5.5) wrote this.

Keep complete native compute waves together across console branches. Reduce mask results at their scalar producers and ballot VCC independently of EXEC. Model each uniform edge separately from lane reach so vector writes retain their EXEC guards.
@Kalmarv
Kalmarv force-pushed the whole-wave-branches branch from f583e01 to 714d8c7 Compare November 24, 2026 23:49
@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

#1866 is merged, so this is rebased onto main 62265d3 (clean) and is no longer stacked: head 714d8c7, one commit, the same change. @eizispark @DarkPanda69, for the native wave64 check, 714d8c7 is the head to use.

AI use: Claude Code (Claude Opus 5.5) wrote this.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit 714d8c7

@Kalmarv Ran on rebased head 714d8c7bfece821ecb270b48b19920cdb2373d01 (clean on main 62265d3) on RX 9070 XT (native wave32 + wave64): pass.

  1. Requested command on unmodified 714d8c7 (2 passed, 0 failed, 0 skipped):
    cargo test -p xcl --lib -- native_wave_branches --nocapture --test-threads=1
    
    running 2 tests
    test gpu::recomp::lower::tests::native_wave_branches_keep_inactive_lanes_in_scalar_control_flow ... ok
    test gpu::recomp::lower_dxil::tests::native_wave_branches_on_the_gpu ... ok
    
    test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 962 filtered out; finished in 0.16s
    
  2. Test-coverage note & native-wave64 GPU check:
    • In 714d8c7, native_wave_branches_on_the_gpu (crates/xcl/src/gpu/recomp/lower_dxil.rs:756-768) calls gpu() (which only checks gpu_waves(), 32-lane support) and only loops wave_branch_cases(false) (cs.threads = [32, 1, 1], super::compute(&decode(&lines), &cs, false)), so unmodified 714d8c7 only dispatches the 32-lane GPU cases even on native wave64 hardware.
    • In a discarded local check on RX 9070 XT (runner::wave64_supported() == Ok(true)), we extended native_wave_branches_on_the_gpu to also run wave_branch_cases(true) (cs.threads = [64, 1, 1], super::compute(&decode(lines), &cs, true), runner::dispatch(&dxil, [1, 1, 1], &[], &[0; 64])): all 8/8 native-wave64 cases (where only lane 63 sets VCC, testing the lo | hi 64-lane ballot) compiled, dispatched in a hardware 64-lane wave, and returned [expected; 64] alongside 10/10 wave32 cases.

Tested (unmodified 714d8c7)

  • Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke
  • Unfiltered cargo test --workspace --no-fail-fast -- --test-threads=4: 986 passed, 2 failed, 45 ignored (8 skipped), with 0 new failures:
    • Only the 2 pre-existing #1679 AMD fuzz seeds failed (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3 seed 1599)
    • 8 skipped: 6 gpu::recomp::lower_dxil::tests f16/f32 direct-DXIL per-lane cases refused where #1426 semantics differ from the console's; shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required, 0x887A002D); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • Native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) passed

Regression run (scripts/smoke.ps1, 60 s, warm shader/driver cache, unmodified 714d8c7)
main (20cf13022f764208384c610c2ae6a3f4eed201a2):

xcl-smoke v1
commit: 20cf13022f764208384c610c2ae6a3f4eed201a2
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14859 MB

PR (714d8c7bfece821ecb270b48b19920cdb2373d01):

xcl-smoke v1
commit: 714d8c7bfece821ecb270b48b19920cdb2373d01
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1676 (PresentX 1676)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14863 MB

Not tested

  • retail run with XCL_DIRECT_DXIL=1 + XCL_PER_LANE=1 past the menus

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon) audited the test coverage, ran the native wave64 GPU checks, workspace test suite, and 60-second retail smoke pair, and formatted this report.

@Kalmarv

Kalmarv commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@ruipedro-pinheiro @eizispark's run above covers the AMD native wave64 case you asked for: on an RX 9070 XT (native wave32 and wave64), native_wave_branches passed on 714d8c7 (2 passed, 0 failed, 0 skipped), so the GPU readback ran on native wave64 hardware. Thanks @eizispark.

AI use: Claude Code (Claude Opus 5.5) wrote this.

@raylitebull
raylitebull merged commit 6567c5f into xcl-dev:main Nov 25, 2026
2 of 3 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
, xcl-dev#1910)

Brings main to full parity with upstream/main (6567c5f):
- xcl-dev#1937: declare triangle topology for translated mesh PSOs
- xcl-dev#1772: default DepthEnable to false in stream_pipeline when DSVFormat is UNKNOWN
- xcl-dev#1910: take native compute mask branches across the whole wave

Assisted-by: Antigravity (Gemini 4)
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants