Shaders: select v_readfirstlane_b32 source lane from the EXEC guard #2828

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2830 into main
fuzeofficlal commented 2026-11-25 21:38:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:38:52Z.


Problem

Lower::valu drops the branchless lane guard (st.guards[b][i]) for every instruction with a scalar destination (Some(Operand::Scalar { .. }) => None). While scalar destinations are indeed written unconditionally regardless of EXEC (already enforced by Lower::write_i), v_readfirstlane_b32 still uses EXEC to select which source lane to read (lowest active bit of EXEC, or lane 0 when EXEC == 0; compare crates/victory-shader/src/range.rs:162-164).

When EXEC is narrowed without branching (e.g., via v_cmpx_* or s_and_saveexec_b32 + s_xor_b32), dropping guard causes v_readfirstlane_b32 to emit an unguarded dx.op.waveReadLaneFirst.i32 over the full host wave, silently reading inactive lane 0 instead of the first active guarded lane.

Fix

  • In Lower::valu, keep self.guard(b, i)? for non-waterfall v_readfirstlane_b32 (waterfall reads and v_readlane_b32 still skip self.guard).
  • In Lower::valu_op ("v_readfirstlane_b32"), when guard is Some(g), compute the lowest active lane from dx.op.waveActiveBallot(g) with dx.op.unaryBits.i32 (FirstbitLo, falling back to lane 0 when both ballot words are zero) and read via dx.op.waveReadLaneAt.i32. Unguarded v_readfirstlane_b32 keeps emitting dx.op.waveReadLaneFirst.i32, helper_reads_own is preserved, and write_i still writes the scalar destination unconditionally.

Verification

  • Portable unit test emit::lower::tests::readfirstlane_uses_the_exec_guard_to_select_a_lane (28/28 in emit::lower::tests): confirms guarded v_readfirstlane_b32 emits waveActiveBallot + waveReadLaneAt.i32 (and sets wave_ops), while unguarded emits waveReadLaneFirst.i32.
  • Device + WARP + dxil.dll test emit::valu_tests::guarded_readfirstlane_broadcasts_after_exec_is_restored: verifies v_cmpx_le_u32 (lanes 2..), s_and_saveexec_b32 + s_xor_b32 (lanes 3..), and empty-EXEC v_cmpx_eq_u32 (falls back to lane 0) after restoring EXEC, passing on RTX 5090, WARP, and Windows SDK 10.0.26100.0 dxil.dll.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --features host): 0 warnings.
  • cargo xtask policy: 184 files ok.

Host Wave-Width Scope

Consistent with main's unguarded v_readfirstlane_b32 lowering (waveReadLaneFirst.i32), this guarded lowering (waveActiveBallot + firstbitlow + waveReadLaneAt.i32) operates within each host wave and does not add v_readfirstlane_b32 to console_lanes (WaveSize), avoiding WaveSize(64) PSO rejection on 32-wide hosts; shaders that already require console wave width continue to pin WaveSize via console_lanes.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6614277087 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:38:52Z. --- ### Problem `Lower::valu` drops the branchless lane guard (`st.guards[b][i]`) for every instruction with a scalar destination (`Some(Operand::Scalar { .. }) => None`). While scalar destinations are indeed written unconditionally regardless of `EXEC` (already enforced by `Lower::write_i`), `v_readfirstlane_b32` still uses `EXEC` to select **which source lane** to read (lowest active bit of `EXEC`, or lane 0 when `EXEC == 0`; compare `crates/victory-shader/src/range.rs:162-164`). When `EXEC` is narrowed without branching (e.g., via `v_cmpx_*` or `s_and_saveexec_b32` + `s_xor_b32`), dropping `guard` causes `v_readfirstlane_b32` to emit an unguarded `dx.op.waveReadLaneFirst.i32` over the full host wave, silently reading inactive lane 0 instead of the first active guarded lane. ### Fix - In `Lower::valu`, keep `self.guard(b, i)?` for non-waterfall `v_readfirstlane_b32` (waterfall reads and `v_readlane_b32` still skip `self.guard`). - In `Lower::valu_op` (`"v_readfirstlane_b32"`), when `guard` is `Some(g)`, compute the lowest active lane from `dx.op.waveActiveBallot(g)` with `dx.op.unaryBits.i32` (`FirstbitLo`, falling back to lane `0` when both ballot words are zero) and read via `dx.op.waveReadLaneAt.i32`. Unguarded `v_readfirstlane_b32` keeps emitting `dx.op.waveReadLaneFirst.i32`, `helper_reads_own` is preserved, and `write_i` still writes the scalar destination unconditionally. ### Verification - Portable unit test `emit::lower::tests::readfirstlane_uses_the_exec_guard_to_select_a_lane` (`28/28` in `emit::lower::tests`): confirms guarded `v_readfirstlane_b32` emits `waveActiveBallot` + `waveReadLaneAt.i32` (and sets `wave_ops`), while unguarded emits `waveReadLaneFirst.i32`. - Device + WARP + `dxil.dll` test `emit::valu_tests::guarded_readfirstlane_broadcasts_after_exec_is_restored`: verifies `v_cmpx_le_u32` (lanes `2..`), `s_and_saveexec_b32` + `s_xor_b32` (lanes `3..`), and empty-`EXEC` `v_cmpx_eq_u32` (falls back to lane 0) after restoring `EXEC`, passing on RTX 5090, WARP, and Windows SDK `10.0.26100.0` `dxil.dll`. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--features host`): 0 warnings. - `cargo xtask policy`: 184 files ok. ### Host Wave-Width Scope Consistent with `main`'s unguarded `v_readfirstlane_b32` lowering (`waveReadLaneFirst.i32`), this guarded lowering (`waveActiveBallot` + `firstbitlow` + `waveReadLaneAt.i32`) operates within each host wave and does not add `v_readfirstlane_b32` to `console_lanes` (`WaveSize`), avoiding `WaveSize(64)` PSO rejection on 32-wide hosts; shaders that already require console wave width continue to pin `WaveSize` via `console_lanes`.
kotekompotek commented 2026-11-25 21:57:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:57:09Z.

Review: COMMENTED


Correct readfirstlane semantics: hardware v_readfirstlane_b32 reads lane ff1(EXEC), but waveReadLaneFirst under emulation uses the whole wave — a divergent-region call silently picked the wrong lane. Ballot-of-guard + cttz(lo) / cttz(hi)+32 reproduces ff1(EXEC) exactly, the empty-EXEC->lane0 fallback is deterministic, and the waterfall-reads carve-out keeps the proven per-lane fast path. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065542833 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#pullrequestreview-6065542833). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:57:09Z. **Review:** COMMENTED --- Correct readfirstlane semantics: hardware v_readfirstlane_b32 reads lane ff1(EXEC), but waveReadLaneFirst under emulation uses the whole wave — a divergent-region call silently picked the wrong lane. Ballot-of-guard + cttz(lo) / cttz(hi)+32 reproduces ff1(EXEC) exactly, the empty-EXEC->lane0 fallback is deterministic, and the waterfall-reads carve-out keeps the proven per-lane fast path. LGTM.
ligmaSec commented 2026-11-25 22:04:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ligmaSec on 2026-11-25T21:47:18Z.


I tried the guarded read on a downstream tree with your ballot + lane selection from 36eb5f6, using pinned vkd3d-proton and Mesa llvmpipe (8-lane subgroups). The four-thread compute case passed a real UAV readback. With lane values equal to thread index + 1 and EXEC selecting lanes 2 and 3, main returned four 1s and the candidate returned four 3s. Unguarded and empty-EXEC controls both returned four 1s.

One case for the numerical test is a console Wave32 group spanning two narrower host waves. With 16 threads, lane values equal to thread index + 1, and EXEC narrowed to thread indices >= 10, every thread must get 11 after restoring EXEC. The baseline gave eight 1s then eight 9s. The candidate gave eight 1s then eight 11s. The first host wave sees an empty ballot even though the console wave has active lanes. Both shaders had an unconstrained host wave size. An expected value calculated from each host wave’s own first value can miss this case.

This was synthetic, with the lowering adapted to our tree. Shapes already requiring the console wave width are a good independent case to keep. Could you cover the split-host-wave case or document the width assumption on this PR?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175538829 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#issuecomment-7175538829). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-11-25T21:47:18Z. --- I tried the guarded read on a downstream tree with your ballot + lane selection from `36eb5f6`, using pinned vkd3d-proton and Mesa llvmpipe (8-lane subgroups). The four-thread compute case passed a real UAV readback. With lane values equal to thread index + 1 and EXEC selecting lanes 2 and 3, main returned four 1s and the candidate returned four 3s. Unguarded and empty-EXEC controls both returned four 1s. One case for the numerical test is a console Wave32 group spanning two narrower host waves. With 16 threads, lane values equal to thread index + 1, and EXEC narrowed to thread indices >= 10, every thread must get 11 after restoring EXEC. The baseline gave eight 1s then eight 9s. The candidate gave eight 1s then eight 11s. The first host wave sees an empty ballot even though the console wave has active lanes. Both shaders had an unconstrained host wave size. An expected value calculated from each host wave’s own first value can miss this case. This was synthetic, with the lowering adapted to our tree. Shapes already requiring the console wave width are a good independent case to keep. Could you cover the split-host-wave case or document the width assumption on this PR?
fuzeofficlal commented 2026-11-25 23:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:32:21Z.


Thanks for testing 36eb5f6 on vkd3d-proton + llvmpipe (8-lane subgroups) and verifying the 4-thread UAV readback!

Good catch on the split-host-wave case. That behavior matches main's existing wave-width assumption for v_readfirstlane_b32: in emit/lower.rs (console_lanes), s.wave_size = Some(wave) is only emitted for compute shaders using explicit lane-index / swizzle / permute / DPP / opaque-mask ops (and single-wave LDS without barriers), not for v_readfirstlane_b32 itself — so both main's unguarded waveReadLaneFirst.i32 and this PR's guarded waveActiveBallot + firstbitlow + waveReadLaneAt.i32 operate per host wave unless the shader already pins WaveSize.

Adding v_readfirstlane_b32 unconditionally to console_lanes would set WaveSize(64) on Wave64 compute shaders (which fails PSO creation on 32-wide NVIDIA hosts), and graphics/mesh stages cannot specify WaveSize in DXIL anyway. I'll note this host-wave scope explicitly in the PR description so the assumption is clear.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176488072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#issuecomment-7176488072). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T22:32:21Z. --- Thanks for testing `36eb5f6` on vkd3d-proton + llvmpipe (8-lane subgroups) and verifying the 4-thread UAV readback! Good catch on the split-host-wave case. That behavior matches `main`'s existing wave-width assumption for `v_readfirstlane_b32`: in `emit/lower.rs` (`console_lanes`), `s.wave_size = Some(wave)` is only emitted for compute shaders using explicit lane-index / swizzle / permute / DPP / opaque-mask ops (and single-wave LDS without barriers), not for `v_readfirstlane_b32` itself — so both `main`'s unguarded `waveReadLaneFirst.i32` and this PR's guarded `waveActiveBallot` + `firstbitlow` + `waveReadLaneAt.i32` operate per host wave unless the shader already pins `WaveSize`. Adding `v_readfirstlane_b32` unconditionally to `console_lanes` would set `WaveSize(64)` on Wave64 compute shaders (which fails PSO creation on 32-wide NVIDIA hosts), and graphics/mesh stages cannot specify `WaveSize` in DXIL anyway. I'll note this host-wave scope explicitly in the PR description so the assumption is clear.
futurepro62 commented 2026-11-26 00:03:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-25T23:33:33Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 36eb5f6 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 775 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: readfirstlane_uses_the_exec_guard_to_select_a_lane, guarded_readfirstlane_broadcasts_after_exec_is_restored.
  • --skip leaves out tests that fail on main 842b0cb on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7177729989 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#issuecomment-7177729989). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T23:33:33Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `36eb5f6` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **775 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `readfirstlane_uses_the_exec_guard_to_select_a_lane`, `guarded_readfirstlane_broadcasts_after_exec_is_restored`. - `--skip` leaves out tests that fail on main `842b0cb` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Dukestar69 commented 2026-11-26 02:28:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T02:28:25Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):

  • cargo test -p victory-shader --lib emit::valu_tests::guarded_readfirstlane_broadcasts_after_exec_is_restored: 1 passed, 0 failed (RTX 5090 hardware + WARP).
  • cargo test -p victory-shader --lib emit::lower::tests::readfirstlane_uses_the_exec_guard_to_select_a_lane: 1 passed, 0 failed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6067757851 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#pullrequestreview-6067757851). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T02:28:25Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, `dxil.dll` validator active): - `cargo test -p victory-shader --lib emit::valu_tests::guarded_readfirstlane_broadcasts_after_exec_is_restored`: **1 passed, 0 failed** (RTX 5090 hardware + WARP). - `cargo test -p victory-shader --lib emit::lower::tests::readfirstlane_uses_the_exec_guard_to_select_a_lane`: **1 passed, 0 failed**. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-26 03:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:23:17Z.


Automated triage for the maintainers.

Lower::valu dropped the branchless EXEC guard for every scalar destination. v_readfirstlane_b32 still picks its source lane from EXEC (the lowest active lane, or lane 0 when EXEC is empty), so after a v_cmpx/s_and_saveexec without a branch it read the wrong lane. With a guard it now ballots the guard, takes the lowest set bit (lane 0 when empty) and reads that lane. Waterfall reads and the unguarded case keep waveReadLaneFirst. The tests check the emitted ops and run on hardware/WARP, and ligmaSec reproduced the fix on another host. The limitation for a console wave split across narrower host waves is the same as on main.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180757268 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#issuecomment-7180757268). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:23:17Z. --- <!-- victory-triage v1 head=36eb5f6f013b32abc5c1b4b71e874749d1c35bf7 verdict=merge-candidate at=2026-11-26T02:23:12Z --> Automated triage for the maintainers. `Lower::valu` dropped the branchless EXEC guard for every scalar destination. `v_readfirstlane_b32` still picks its source lane from EXEC (the lowest active lane, or lane 0 when EXEC is empty), so after a `v_cmpx`/`s_and_saveexec` without a branch it read the wrong lane. With a guard it now ballots the guard, takes the lowest set bit (lane 0 when empty) and reads that lane. Waterfall reads and the unguarded case keep `waveReadLaneFirst`. The tests check the emitted ops and run on hardware/WARP, and ligmaSec reproduced the fix on another host. The limitation for a console wave split across narrower host waves is the same as on `main`. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Lyrnc commented 2026-11-26 18:38:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T18:38:34Z.


Wave64 hardware check of 36eb5f6.

Checked against a hardware table measured on an AMD Radeon iGPU (gfx1036, RDNA 2, Ryzen 7 9800X3D) in native
wave64: 64 cross-lane instructions x 8 EXEC masks (all, lo32, hi32, all but lane 0, alternate lanes, lane 40 alone,
lanes 31+32, a sparse mask). Each case was assembled with the same assembler, run through VIctory as a wave64
compute program of 64 threads on the same Radeon through D3D12 (WaveSize 64, dxil.dll validated), and all 64
lanes compared with the hardware. EXEC is narrowed two ways: straight-line (v_cmpx_ne_u32, lowered with a lane
guard) and branched (s_and_saveexec_b64 + s_cbranch_execz, a DXIL if). Windows 11, Rust pinned, debug.
No game files were used.

Tested (merged with #1312 onto main 63bcca4; Radeon, wave64):

  • Straight-line narrowing: v_readfirstlane_b32 s20, v4 (v4 = lane + 1) is exact for all 8 masks with this PR.
    On main, 4 of 8 are wrong, every mask whose first lane is not 0: hi32 gives lanes 32-63 the value 1 instead
    of 33; all-but-lane-0 gives 1 instead of 2; lane 40 alone gives 1 instead of 41; lanes 31+32 give 1 instead of 32.
  • Branched form: exact on main and with the PR (8/8).
  • No other instruction of the table changed result.
  • A wave64 GPU test (readfirstlane under hi32, all but lane 0, lane 40, lanes 31+32): fails on main, passes with
    this PR.

The host-wave width note, measured on AMD too: a wave64 program whose only lane operation is
v_readfirstlane_b32 declares no WaveSize, and the AMD driver ran it as two waves of 32 on this 32..64 host.
With full EXEC, lanes 32-63 got lane 32's value (0x21 instead of 0x1), on main and with this PR alike. So the scope
in the description applies on AMD hosts as well, not only on 32..32 ones. Programs that also read lane ids
(v_mbcnt, DPP, swizzle, permute, readlane) declare WaveSize(64) and are exact.

Not tested: NVIDIA for this PR (the table is wave64), the title.

AI use: Claude Code (Claude Opus 5.5) built the harness and the hardware table, ran them on the GPU above and wrote this report; the numbers come from those runs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7200692202 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2830#issuecomment-7200692202). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-26T18:38:34Z. --- Wave64 hardware check of `36eb5f6`. Checked against a hardware table measured on an AMD Radeon iGPU (gfx1036, RDNA 2, Ryzen 7 9800X3D) in native wave64: 64 cross-lane instructions x 8 EXEC masks (all, lo32, hi32, all but lane 0, alternate lanes, lane 40 alone, lanes 31+32, a sparse mask). Each case was assembled with the same assembler, run through VIctory as a wave64 compute program of 64 threads on the same Radeon through D3D12 (WaveSize 64, dxil.dll validated), and all 64 lanes compared with the hardware. EXEC is narrowed two ways: straight-line (`v_cmpx_ne_u32`, lowered with a lane guard) and branched (`s_and_saveexec_b64` + `s_cbranch_execz`, a DXIL `if`). Windows 11, Rust pinned, debug. No game files were used. **Tested** (merged with #1312 onto main 63bcca4; Radeon, wave64): - Straight-line narrowing: `v_readfirstlane_b32 s20, v4` (v4 = lane + 1) is exact for all 8 masks with this PR. On main, 4 of 8 are wrong, every mask whose first lane is not 0: hi32 gives lanes 32-63 the value 1 instead of 33; all-but-lane-0 gives 1 instead of 2; lane 40 alone gives 1 instead of 41; lanes 31+32 give 1 instead of 32. - Branched form: exact on main and with the PR (8/8). - No other instruction of the table changed result. - A wave64 GPU test (readfirstlane under hi32, all but lane 0, lane 40, lanes 31+32): fails on main, passes with this PR. **The host-wave width note, measured on AMD too:** a wave64 program whose only lane operation is `v_readfirstlane_b32` declares no `WaveSize`, and the AMD driver ran it as two waves of 32 on this 32..64 host. With full EXEC, lanes 32-63 got lane 32's value (0x21 instead of 0x1), on main and with this PR alike. So the scope in the description applies on AMD hosts as well, not only on 32..32 ones. Programs that also read lane ids (`v_mbcnt`, DPP, swizzle, permute, readlane) declare WaveSize(64) and are exact. **Not tested:** NVIDIA for this PR (the table is wave64), the title. **AI use:** Claude Code (Claude Opus 5.5) built the harness and the hardware table, ran them on the GPU above and wrote this report; the numbers come from those runs.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2830:upstream-pr/2830'
git switch 'upstream-pr/2830'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2830'
git switch 'upstream-pr/2830'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2830'
git switch 'upstream-pr/2830'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2830'
git switch 'main'
git merge --squash 'upstream-pr/2830'
git switch 'main'
git merge --ff-only 'upstream-pr/2830'
git switch 'main'
git merge 'upstream-pr/2830'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2828
No description provided.