d3d12-shader: Wave64 loop convergence, lane provenance, and wide/sub-dword paired LDS (D3D12-SHADER-PAIRED-WAVE64-EXACTNESS) #2662

Manually merged
github merged 4 commits from github-bot/gh-2662 into gh-pr/2662/base 2026-11-30 05:50:24 +00:00 AGit
Owner

@⁠zmasi on GitHub · 2026-11-30 00:09 UTC · original
zmasi:fix/d3d12-shader-paired-water-and-wave64 → main · +1914 −207 · 6 files · 4 commits · merged 2026-11-30 05:45 UTC

Claimed in the coordination issue as: D3D12-SHADER-PAIRED-WAVE64-EXACTNESS (#2570, #2570)

What and why

Fixes D3D12-SHADER-PAIRED-WAVE64-EXACTNESS across d3d12/crates/leonida-shader/src/emit/{mod.rs, wave.rs, paired.rs, lower.rs, paired_tests.rs, wave64_tests.rs}:

  1. Default host half-wave loop convergence (LEONIDA_LOOPS_WAVE=1), partial-group host_wide masking + dead-half-wave exit, and fixpoint loop-region tracking:
    • Previously, loops_wave defaulted to 0 when LEONIDA_LOOPS_WAVE was unset, leaving threads that exited per-lane loops on earlier iterations in independent sub-warps on 32-lane hosts (NVIDIA), which corrupted post-loop waveActiveBallot / exchange_halves / v_readfirstlane / v_mbcnt tile appends (CS_TransmissionVolumetrics_GenerateTiles 1aa247ed3653b616 and boundary tile classifiers). loops_wave now defaults to 1 for Wave64 compute programs on 32-lane hosts while keeping LEONIDA_LOOPS_WAVE=0 as an explicit opt-out (after trustno1-coder/VIctory-NVIDIA 64d4931, GPL-3.0).
    • In Lower::wave_wide, the host_wide branch now masks mine by self.partial_active (And(mine, a) for any, Or(mine, Xor(a, true)) for !any) and combines with waveAnyTrue(a) when an entire 32-lane host half-wave is unlaunched (waveAnyTrue(a) == false) so dead half-waves exit on iteration 1 and reach post-loop barriers cleanly instead of spinning to LOOP_LIMIT.
    • Previously, lower::lane_regions (all_lane_blocks, branches_around) treated per-lane loop exit, continue, or guarded-break blocks as wave-converged whenever post-dominated across later iterations. lane_regions now intersects each retreating edge's backward walk from latch with forward reachability from head (keeping exact natural loops on reducible CFGs and exact loop SCCs on irreducible CFGs without leaking into entry block 0), merges loop bodies sharing head, and closes the non-post-dominated walk to a fixpoint over full_by_head whenever a per-lane branch reaches head or exits full_body directly or through intermediate blocks (while keeping diamond if/else joins and nested loops inside uniform outer loops unexpanded).
  2. Preserve source lane provenance in whole-wave sections (Sym::Own(Value, u32) & Shape::Lane(Value, u32)):
    • Previously, wave.rs tracked initial lane values as Sym::Own(Value) without their source lane index 0..wave, miscompiling fixed-lane broadcasts inside whole-wave sections (s_or_saveexec_b64 -1 .. v_readlane_b32 s_dst, v_src, <lane>) into per-lane identity reads (Shape::Value(v_src)).
    • Sym::Own(Value, u32) and Shape::Lane(Value, u32) now preserve the exact source console lane 0..63, lowered across both halves in paired_shape and through console_lane_read (with half-wave refusal and cached every_lane_block full-wave convergence checks) in Lower::shape (after edsuuu/VI-BR-PORT cf3394b and TaynanGT/Vice-Tay 5e588e8, GPL-3.0).
  3. Align paired_cross v_readlane_b32 with Lower::valu:
    • paired_inst intercepted v_readlane_b32 before Lower::valu, bypassing Resources::restored_lanes and post-section Section::reads. paired_cross now lowers both across lower and upper paired halves (self.both / put_lanes) before general lane shuffles and applies memory_guard in v_readfirstlane_b32 and ds_bpermute_b32.
  4. Bounds-checked multi-dword, strided-64, and sub-dword LDS lowering in paired.rs alongside _rtn atomics, ds_cmpst_rtn_b32, and ds_sub CAS loops:
    • Extends supports_paired_lds and paired_lds to ds_read_b64/_b96/_b128, ds_write_b64/_b96/_b128, ds_read2_b64, ds_write2_b64, ds_read2st64_b32/_b64, ds_write2st64_b32/_b64, and sub-dword ds_read_{u8,i8,u16,i16} / ds_write_{b8,b16} (plus _d16 and _d16_hi), using atomic Rmw::And + Rmw::Or for sub-dword writes so lower and upper console lanes sharing an LDS dword never clobber each other, preserving multi-wave barriers_on_every_way, _rtn integer atomics, ds_cmpst_rtn_b32, and Lower::lds_int_sub compare-exchange loops for ds_sub_u32 / ds_sub_rtn_u32 / 0 - x adds, and guarding every dword access by index < dwords so out-of-bounds reads/returns yield 0 and out-of-bounds writes drop cleanly (after TaynanGT/Vice-Tay 5e588e8, fxceless/victory-fork, and voidopcode/vilocity add4873 / 5c8149f, GPL-3.0).
  5. Support spilled and thread-counted (USER_DISPATCH_THREADS_X) Wave64 compute programs and 1-D BeforeWide rescue in paired:
    • Removes the spill::is_spilled refusal in emit::paired and decouples the BeforeWide paired fallback from the 2-D tile check (while keeping widen()'s barrier-heavy fallback gated on tile unless LEONIDA_WAVE_WIDE_LAST=all) so refused 1-D [64, 1, 1] groups with divergent cross-half LDS regions translate cleanly.
    • Computes independent lower and upper partial_active masks in Lower::run(counted = true) against console group width cs.threads[0] without early-exiting host threads needed at LDS barriers, swaps partial_active in LaneState / swap_lanes, and applies per-half partial_active / launched across mask_dword, scc_some, wave_wide, and paired_f64_constant_sum.

Tested

  • Red (origin/main):
    • Reproduced all target failures on Windows 11 + NVIDIA GeForce RTX 3090: all_lane_blocks left per-lane loop latches, shared-latch / direct continue loop bodies, and guarded-break blocks true; whole_wave_section_fixed_lane_broadcast_preserves_lane_provenance returned 0x12340000 + t instead of 0x12340000 + lane; unmasked host_wide loops in partial thread-counted halves/exchange dispatches spun to LOOP_LIMIT; and paired_readlane_after_whole_wave_section_and_restored_parked_scalar, paired_lds_wide_strided_and_subdword_accesses_across_halves, the_lds_operations_the_paired_form_takes, and paired_partial_thread_counted_dispatch_masks_both_halves_and_keeps_barriers failed with Unsupported / assertion errors.
  • Green:
    • cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4 (default & --features host) -> 22/22 passed (GenerateTiles 64-group post-loop append + 1-D refused group rescue, multi-wave barriers_on_every_way, fixed-lane whole-wave broadcasts across lane in [0, 19, 31, 32, 37, 63] and start in [0, 16, 40], Section::reads + restored_lanes, ds_read_b64/_b96/_b128 + OOB + 2st64_b32/_b64 + concurrent b8/u8/i8/b16/u16/i16 + _d16/_d16_hi + ds_sub_rtn_u32 CAS loop + ds_cmpst_rtn_b32 + OOB return 0, spilled partial thread-counted [2, 1, 1] dispatches in both paired and host_wide halves/exchange modes including iteration-1 dead-half-wave exit proof, and direct/trampolined/shared-latch continue, guarded break, irreducible 2-entry loop, and diamond/nested-loop non-expansion CFG checks).
    • cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib wave64_tests -- --test-threads=4 (default & --features host) -> 30/30 passed; lds_subtracts (--features host) -> 2/2 passed; emit::tests -> 23/23 passed.
    • cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets (default & --features host) -> 0 warnings on touched code.
    • python -I scripts/check_no_game_data.py -> 0 issues.

GPUs tested: NVIDIA GeForce RTX 3090 (driver 610.88) and Microsoft WARP, Windows 11 Pro (26200)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: d3d12/crates/leonida-shader DXIL backend; docs/design.md covers tools/rdna2spirv.py)
**@⁠zmasi** on GitHub · 2026-11-30 00:09 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2662) `zmasi:fix/d3d12-shader-paired-water-and-wave64` → `main` · +1914 −207 · 6 files · 4 commits · merged 2026-11-30 05:45 UTC Claimed in the coordination issue as: D3D12-SHADER-PAIRED-WAVE64-EXACTNESS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/2570, https://git.gtahub.st/github/ubiquitarianism--leonida/issues/2570) ### What and why Fixes `D3D12-SHADER-PAIRED-WAVE64-EXACTNESS` across `d3d12/crates/leonida-shader/src/emit/{mod.rs, wave.rs, paired.rs, lower.rs, paired_tests.rs, wave64_tests.rs}`: 1. **Default host half-wave loop convergence (`LEONIDA_LOOPS_WAVE=1`), partial-group `host_wide` masking + dead-half-wave exit, and fixpoint loop-region tracking**: - Previously, `loops_wave` defaulted to `0` when `LEONIDA_LOOPS_WAVE` was unset, leaving threads that exited per-lane loops on earlier iterations in independent sub-warps on 32-lane hosts (`NVIDIA`), which corrupted post-loop `waveActiveBallot` / `exchange_halves` / `v_readfirstlane` / `v_mbcnt` tile appends (`CS_TransmissionVolumetrics_GenerateTiles` `1aa247ed3653b616` and boundary tile classifiers). `loops_wave` now defaults to `1` for Wave64 compute programs on 32-lane hosts while keeping `LEONIDA_LOOPS_WAVE=0` as an explicit opt-out (after `trustno1-coder/VIctory-NVIDIA` `64d4931`, GPL-3.0). - In `Lower::wave_wide`, the `host_wide` branch now masks `mine` by `self.partial_active` (`And(mine, a)` for `any`, `Or(mine, Xor(a, true))` for `!any`) and combines with `waveAnyTrue(a)` when an entire 32-lane host half-wave is unlaunched (`waveAnyTrue(a) == false`) so dead half-waves exit on iteration 1 and reach post-loop barriers cleanly instead of spinning to `LOOP_LIMIT`. - Previously, `lower::lane_regions` (`all_lane_blocks`, `branches_around`) treated per-lane loop exit, `continue`, or guarded-`break` blocks as wave-converged whenever post-dominated across later iterations. `lane_regions` now intersects each retreating edge's backward walk from `latch` with forward reachability from `head` (keeping exact natural loops on reducible CFGs and exact loop SCCs on irreducible CFGs without leaking into entry block `0`), merges loop bodies sharing `head`, and closes the non-post-dominated walk to a fixpoint over `full_by_head` whenever a per-lane branch reaches `head` or exits `full_body` directly or through intermediate blocks (while keeping diamond `if/else` joins and nested loops inside uniform outer loops unexpanded). 2. **Preserve source lane provenance in whole-wave sections (`Sym::Own(Value, u32)` & `Shape::Lane(Value, u32)`)**: - Previously, `wave.rs` tracked initial lane values as `Sym::Own(Value)` without their source lane index `0..wave`, miscompiling fixed-lane broadcasts inside whole-wave sections (`s_or_saveexec_b64 -1` .. `v_readlane_b32 s_dst, v_src, <lane>`) into per-lane identity reads (`Shape::Value(v_src)`). - `Sym::Own(Value, u32)` and `Shape::Lane(Value, u32)` now preserve the exact source console lane `0..63`, lowered across both halves in `paired_shape` and through `console_lane_read` (with half-wave refusal and cached `every_lane_block` full-wave convergence checks) in `Lower::shape` (after `edsuuu/VI-BR-PORT` `cf3394b` and `TaynanGT/Vice-Tay` `5e588e8`, GPL-3.0). 3. **Align `paired_cross` `v_readlane_b32` with `Lower::valu`**: - `paired_inst` intercepted `v_readlane_b32` before `Lower::valu`, bypassing `Resources::restored_lanes` and post-section `Section::reads`. `paired_cross` now lowers both across lower and upper paired halves (`self.both` / `put_lanes`) before general lane shuffles and applies `memory_guard` in `v_readfirstlane_b32` and `ds_bpermute_b32`. 4. **Bounds-checked multi-dword, strided-64, and sub-dword LDS lowering in `paired.rs` alongside `_rtn` atomics, `ds_cmpst_rtn_b32`, and `ds_sub` CAS loops**: - Extends `supports_paired_lds` and `paired_lds` to `ds_read_b64`/`_b96`/`_b128`, `ds_write_b64`/`_b96`/`_b128`, `ds_read2_b64`, `ds_write2_b64`, `ds_read2st64_b32`/`_b64`, `ds_write2st64_b32`/`_b64`, and sub-dword `ds_read_{u8,i8,u16,i16}` / `ds_write_{b8,b16}` (plus `_d16` and `_d16_hi`), using atomic `Rmw::And` + `Rmw::Or` for sub-dword writes so lower and upper console lanes sharing an LDS dword never clobber each other, preserving multi-wave `barriers_on_every_way`, `_rtn` integer atomics, `ds_cmpst_rtn_b32`, and `Lower::lds_int_sub` compare-exchange loops for `ds_sub_u32` / `ds_sub_rtn_u32` / `0 - x` adds, and guarding every dword access by `index < dwords` so out-of-bounds reads/returns yield `0` and out-of-bounds writes drop cleanly (after `TaynanGT/Vice-Tay` `5e588e8`, `fxceless/victory-fork`, and `voidopcode/vilocity` `add4873` / `5c8149f`, GPL-3.0). 5. **Support spilled and thread-counted (`USER_DISPATCH_THREADS_X`) Wave64 compute programs and 1-D `BeforeWide` rescue in `paired`**: - Removes the `spill::is_spilled` refusal in `emit::paired` and decouples the `BeforeWide` `paired` fallback from the 2-D `tile` check (while keeping `widen()`'s barrier-heavy fallback gated on `tile` unless `LEONIDA_WAVE_WIDE_LAST=all`) so refused 1-D `[64, 1, 1]` groups with divergent cross-half LDS regions translate cleanly. - Computes independent lower and upper `partial_active` masks in `Lower::run(counted = true)` against console group width `cs.threads[0]` without early-exiting host threads needed at LDS barriers, swaps `partial_active` in `LaneState` / `swap_lanes`, and applies per-half `partial_active` / `launched` across `mask_dword`, `scc_some`, `wave_wide`, and `paired_f64_constant_sum`. ### Tested - **Red (`origin/main`)**: - Reproduced all target failures on Windows 11 + NVIDIA GeForce RTX 3090: `all_lane_blocks` left per-lane loop latches, shared-latch / direct `continue` loop bodies, and guarded-`break` blocks `true`; `whole_wave_section_fixed_lane_broadcast_preserves_lane_provenance` returned `0x12340000 + t` instead of `0x12340000 + lane`; unmasked `host_wide` loops in partial thread-counted `halves`/`exchange` dispatches spun to `LOOP_LIMIT`; and `paired_readlane_after_whole_wave_section_and_restored_parked_scalar`, `paired_lds_wide_strided_and_subdword_accesses_across_halves`, `the_lds_operations_the_paired_form_takes`, and `paired_partial_thread_counted_dispatch_masks_both_halves_and_keeps_barriers` failed with `Unsupported` / assertion errors. - **Green**: - `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4` (default & `--features host`) -> `22/22` passed (`GenerateTiles` 64-group post-loop append + 1-D refused group rescue, multi-wave `barriers_on_every_way`, fixed-lane whole-wave broadcasts across `lane in [0, 19, 31, 32, 37, 63]` and `start in [0, 16, 40]`, `Section::reads` + `restored_lanes`, `ds_read_b64`/`_b96`/`_b128` + OOB + `2st64_b32`/`_b64` + concurrent `b8`/`u8`/`i8`/`b16`/`u16`/`i16` + `_d16`/`_d16_hi` + `ds_sub_rtn_u32` CAS loop + `ds_cmpst_rtn_b32` + OOB return `0`, spilled partial thread-counted `[2, 1, 1]` dispatches in both `paired` and `host_wide` `halves`/`exchange` modes including iteration-1 dead-half-wave exit proof, and direct/trampolined/shared-latch `continue`, guarded `break`, irreducible 2-entry loop, and diamond/nested-loop non-expansion CFG checks). - `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib wave64_tests -- --test-threads=4` (default & `--features host`) -> `30/30` passed; `lds_subtracts` (`--features host`) -> `2/2` passed; `emit::tests` -> `23/23` passed. - `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets` (default & `--features host`) -> `0` warnings on touched code. - `python -I scripts/check_no_game_data.py` -> `0` issues. GPUs tested: NVIDIA GeForce RTX 3090 (driver 610.88) and Microsoft WARP, Windows 11 Pro (26200) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: `d3d12/crates/leonida-shader` DXIL backend; `docs/design.md` covers `tools/rdna2spirv.py`)
Fixes six Wave64-on-Wave32 translation and lowering gaps across
`d3d12/crates/leonida-shader/src/emit/{mod.rs, wave.rs, paired.rs, lower.rs}`:

1. Host half-wave loop convergence & natural-loop region tracking:
   - Default `LEONIDA_LOOPS_WAVE` to `1` when unset (`0` opts out) so Wave64
     compute shaders on 32-lane hosts keep each host half-wave converged
     across per-lane loops before post-loop ballots, exchanges, and
     first-lane reads (`CS_TransmissionVolumetrics_GenerateTiles` and tile
     classifiers; after trustno1-coder/VIctory-NVIDIA 64d4931, GPL-3.0).
   - Teach `lower::lane_regions` (`all_lane_blocks`, `branches_around`) to
     include natural-loop bodies exited per lane so loop headers, mid-loop
     breaks, and latches are never misclassified as executed by every lane on
     subsequent iterations, while reconverged post-dominating blocks after a
     single-exit loop remain wave-converged.

2. Fixed-lane provenance in whole-wave sections (`wave.rs`, `paired.rs`,
   `lower.rs`):
   - Track source lane provenance in `Sym::Own(Value, u32)` and emit
     `Shape::Lane(Value, u32)` when a whole-wave section broadcasts a fixed
     console lane (`v_readlane_b32` into SGPR or copied VGPR) instead of
     collapsing to each lane's own value (`Shape::Value`).
   - Lower `Shape::Lane` across lower/upper paired halves in `paired_shape`
     and via `console_lane_read` with half-wave and full-wave convergence
     checks in `Lower::shape` (after edsuuu/VI-BR-PORT cf3394b and
     TaynanGT/Vice-Tay 5e588e8, GPL-3.0).

3. Paired `v_readlane_b32` parity with `Lower::valu` (`paired.rs`):
   - Handle `Resources::restored_lanes` (uniform scalars parked in scratch
     VGPRs clobbered by unmodelled whole-wave instructions) and post-section
     `Section::reads` before general cross-lane shuffles in `paired_cross`.

4. Bounds-checked multi-dword, strided-64, and sub-dword paired LDS
   (`paired.rs`):
   - Extend `supports_paired_lds` and `paired_lds` to `_b64`/`_b96`/`_b128`,
     `ds_read2`/`ds_write2` (`_b32`/`_b64`), `ds_read2st64`/`ds_write2st64`
     (`_b32`/`_b64`), and sub-dword `_u8`/`_i8`/`_u16`/`_i16`/`_b8`/`_b16`
     (including `_d16` and `_d16_hi`), using `Rmw::And` + `Rmw::Or` for
     sub-dword writes so paired halves sharing an LDS dword never clobber
     each other, and guarding every dword index by `index < dwords` (after
     TaynanGT/Vice-Tay 5e588e8 and fxceless/victory-fork, GPL-3.0).

5. Spilled & thread-counted (`USER_DISPATCH_THREADS_X`) paired compute
   programs (`mod.rs`, `paired.rs`, `lower.rs`):
   - Allow spilled Wave64 compute programs in `emit::paired` and decouple the
     `BeforeWide` `paired` fallback from the 2-D `tile` gate so refused 1-D
     Wave64 groups with divergent cross-half LDS regions are rescued cleanly.
   - Compute per-half `partial_active` masks in `Lower::run(counted = true)`
     against console group width `cs.threads[0]` without early-exiting host
     threads needed at LDS barriers, swap `partial_active` in `swap_lanes`,
     and apply `partial_active` / `launched` / `memory_guard` across
     `mask_dword`, `scc_some`, `wave_wide`, `paired_f64_constant_sum`, and
     `paired_cross`.

Verification (Windows 11 + NVIDIA GeForce RTX 3090 D3D12 & WARP):
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4`: 20/20 passed (6 new Red->Green hardware + unit tests).
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader -- --test-threads=4`: 359 passed, 0 failed.
- `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets`: 0 warnings on touched code.
- `python -I scripts/check_no_game_data.py`: 0 issues.

AI-assisted.
Follow-up fixes for Wave64-on-Wave32 lowering and loop-region analysis:

1. `Lower::wave_wide` `host_wide` partial-group masking (`lower.rs`):
   - Mask `mine` by `self.partial_active` (`And(mine, a)` for `any`,
     `Or(mine, Xor(a, true))` for `!any`) in the `host_wide` branch so
     unlaunched threads kept in the wave for barriers (`USER_DISPATCH_THREADS_X`
     in spilled `halves`/`exchange` Wave64 compute programs) never hold
     `waveAnyTrue` true until `LOOP_LIMIT` or keep `waveAllTrue` false.

2. Multi-latch & irreducible loop region precision (`lower.rs`):
   - Intersect each retreating edge's backward walk from `latch` with forward
     reachability from `head` so irreducible multi-entry loops capture only the
     exact loop SCC without leaking into entry block `0` or preheaders.
   - Merge all loop bodies sharing `head` so per-lane `continue` back-edges
     (direct or trampolined) before a uniform latch mark post-dominating
     loop-body blocks `all_lane_blocks == false` and include the `continue`
     branch in `branches_around`.

3. Paired readlane parity, cached `all_lane_blocks`, and expanded tests
   (`paired.rs`, `lower.rs`, `paired_tests.rs`, `wave64_tests.rs`):
   - Evaluate `restored_lanes` and post-section `Section::reads` across both
     paired halves via `self.both` / `put_lanes` instead of mirroring `lo`.
   - Cache `all_lane_blocks(self.x.st)` on `Lower` (`every_lane_block`) and
     co-locate `console_lane_read` right below `Lower::shape`.
   - Update `wave64_tests` mode-`0` assertion text and add runtime RTX + WARP
     coverage for `ds_write_b8`/`ds_read_u8`/`ds_read_i8`, `_d16`/`_d16_hi`
     half preservation, `ds_write_b128`/`ds_read_b96`/`ds_read_b128`,
     `ds_write2st64_b64`/`ds_read2st64_b64`, counted `host_wide` loops
     (`s_cbranch_execnz` & `s_cbranch_execz`), per-lane `continue` before a
     uniform latch with cross-half LDS, and irreducible 2-entry loop CFGs.

Verification (Windows 11 + NVIDIA GeForce RTX 3090 D3D12 & Microsoft WARP):
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4`: 21/21 passed.
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader -- --test-threads=4`: 360 passed, 0 failed.
- `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets`: 0 warnings on touched code.
- `python -I scripts/check_no_game_data.py`: 0 issues.

AI-assisted.
Follow-up fixes for Wave64-on-Wave32 loop-region analysis and partial-group
`host_wide` loops:

1. Fixpoint closure over `full_by_head` in `lower::lane_regions` (`lower.rs`):
   - Replace the pre-walk `sub_loops` check with a monotone fixpoint over
     `full_by_head` (`expanded`), expanding any enclosing loop `full_body`
     with `full_body[d]` whenever the non-post-dominated walk reaches `head`,
     leaves `full_body`, or reaches a block with an edge to `head` or outside
     `full_body`.
   - Captures shared-latch per-lane `continue` branches and guarded `break`
     exits inside per-lane branches while keeping diamond `if/else` joins and
     nested per-lane loops inside uniform outer loops unexpanded.

2. Dead half-wave early exit in `Lower::wave_wide` (`lower.rs`):
   - When an entire 32-lane host half-wave is unlaunched (`waveAnyTrue(a) ==
     false`, e.g. lanes `32..63` when `USER_DISPATCH_THREADS_X <= 32`), combine
     `host_wide`'s branch result with `waveAnyTrue(a)` (`And` when `taken`
     cycles back to `b` and `!any`, `Or(!waveAnyTrue(a))` when `not_taken`
     cycles back to `b` and `any`) so dead half-waves exit on iteration 1 and
     reach post-loop barriers cleanly instead of spinning to `LOOP_LIMIT`.

3. Regression coverage (`paired_tests.rs`):
   - Verify live on RTX 3090 + WARP that lane 40's `v6` equals `1` when
     `active_in_group <= 32` and `4` when `active_in_group > 32`, and add unit
     assertions for shared-latch `continue`, guarded `break` inside a per-lane
     branch, diamond `if/else` non-expansion, and nested-loop non-expansion.

Verification (Windows 11 + NVIDIA GeForce RTX 3090 D3D12 & Microsoft WARP):
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib paired_tests -- --test-threads=4`: 21/21 passed.
- `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib wave64_tests -- --test-threads=4`: 30/30 passed.
- `cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-shader --all-targets`: 0 warnings on touched code.
- `python -I scripts/check_no_game_data.py`: 0 issues.

AI-assisted.
Integrates multi-wave barriers_on_every_way, _rtn paired LDS atomics, ds_cmpst_rtn_b32, and ds_sub_u32 compare-exchange loops alongside multi-dword/sub-dword paired LDS, default LEONIDA_LOOPS_WAVE=1, monotone fixpoint lane_regions, partial_active host_wide masking, and Sym::Own lane provenance.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 00:12:15 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-30 00:47 UTC · original

Native D3D12 Wave64 verification on RTX 4090 (NVIDIA 616.64, Windows 11 build 26300, MSVC, Rust 1.98.1, SDK 26100 DXIL validator). I merged ab78da371 onto b8bd37111 (tree 9be32c2d3).

  • Exact tree, cargo test --locked -p leonida-shader --features host --lib: paired_tests 22/22, wave64_tests 30/30, lds_subtracts 2/2. These filters mix CPU and GPU assertions.
  • I reran the paired wide, strided, and sub-dword LDS fixture with adapter logging after each successful dispatch. DXGI resolved all seven hardware dispatches to the RTX 4090, and the fixture passed its output assertions.
  • Three older Wave64 tests returned early after the hardware rejected their pipeline. The same three returned early on unmodified b8bd37111 under the same toolchain and driver.

Synthetic inputs only. AI-assisted with OpenAI Codex (GPT-6.2 Sol).

**@⁠ecox982745** on GitHub · 2026-11-30 00:47 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2662#issuecomment-7265577174) Native D3D12 Wave64 verification on RTX 4090 (NVIDIA 616.64, Windows 11 build 26300, MSVC, Rust 1.98.1, SDK 26100 DXIL validator). I merged `ab78da371` onto `b8bd37111` (tree `9be32c2d3`). - Exact tree, `cargo test --locked -p leonida-shader --features host --lib`: `paired_tests` 22/22, `wave64_tests` 30/30, `lds_subtracts` 2/2. These filters mix CPU and GPU assertions. - I reran the paired wide, strided, and sub-dword LDS fixture with adapter logging after each successful dispatch. DXGI resolved all seven hardware dispatches to the RTX 4090, and the fixture passed its output assertions. - Three older Wave64 tests returned early after the hardware rejected their pipeline. The same three returned early on unmodified `b8bd37111` under the same toolchain and driver. Synthetic inputs only. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Author
Owner

@⁠merzleckeier on GitHub · 2026-11-30 00:50 UTC · original

Independent Wave64 verification on Wine and RADV. I merged ab78da371 into main b8bd37111 (tree 9be32c2d3) and built the Win64 leonida-shader tests with --features host. Wine 11.22 and VKD3D-Proton 71cae091, RTX 4070 SUPER (620.73.04) and Radeon Raphael (RADV 26.3.1).

  • MEASURED The unmodified build reported 22 paired_tests and 30 wave64_tests passed on each GPU. The wave64_tests total includes three optional native-Wave64 hardware paths that logged not run on NVIDIA and one 32-lane-only flag-dispatch path skipped on RADV.
  • MEASURED I added three test-only log lines after successful readback and reran the six new focused tests on both devices. Each GPU completed 81 hardware readbacks and passed the unchanged assertions, covering post-loop append, fixed-lane broadcasts, parked scalar restoration, wide/sub-dword LDS, partial groups and the dead-half-wave loop exit. The adapters reported wave limits 32–32 and 32–64 respectively. Wine’s WARP-labeled entries still used the selected physical adapter.
  • MEASURED The full native Linux shader unit suite reported 224 passed and 2 ignored on both plain main and the merged tree.

Synthetic fixtures only. AI-assisted with OpenAI Codex.

**@⁠merzleckeier** on GitHub · 2026-11-30 00:50 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2662#issuecomment-7265627437) Independent Wave64 verification on Wine and RADV. I merged `ab78da371` into `main` `b8bd37111` (tree `9be32c2d3`) and built the Win64 `leonida-shader` tests with `--features host`. Wine 11.22 and VKD3D-Proton `71cae091`, RTX 4070 SUPER (620.73.04) and Radeon Raphael (RADV 26.3.1). - **MEASURED** The unmodified build reported 22 `paired_tests` and 30 `wave64_tests` passed on each GPU. The `wave64_tests` total includes three optional native-Wave64 hardware paths that logged `not run` on NVIDIA and one 32-lane-only flag-dispatch path skipped on RADV. - **MEASURED** I added three test-only log lines after successful readback and reran the six new focused tests on both devices. Each GPU completed 81 hardware readbacks and passed the unchanged assertions, covering post-loop append, fixed-lane broadcasts, parked scalar restoration, wide/sub-dword LDS, partial groups and the dead-half-wave loop exit. The adapters reported wave limits 32–32 and 32–64 respectively. Wine’s WARP-labeled entries still used the selected physical adapter. - **MEASURED** The full native Linux shader unit suite reported 224 passed and 2 ignored on both plain `main` and the merged tree. Synthetic fixtures only. AI-assisted with OpenAI Codex.
github-bot changed target branch from main to gh-pr/2662/base 2026-11-30 05:50:15 +00:00
github manually merged commit ab78da3718 into gh-pr/2662/base 2026-11-30 05:50:17 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!2662
No description provided.