shader: lower compute constant lane masks via flat group index without WaveSize(64) #3496

Open
danielibabet wants to merge 2 commits from upstream-pr/3496 into main
danielibabet commented 2026-11-27 10:08:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-27T10:08:39Z.


Compute and mesh shaders that branch on or select with a constant 64-bit lane mask (\Atom::Constant) or an inline constant mask in \ _cndmask_b32\ previously forced \WaveSize(64), causing Wave32-only GPUs (NVIDIA RTX / Intel Arc) to reject the pipeline with \E_INVALIDARG.

Because console compute/mesh waves are consecutive runs of \wave\ flat group threads, a constant mask only depends on \ lattenedThreadIdInGroup & (wave - 1)\ and does not need \WaveSize(64)\ or \dx.op.waveGetLaneIndex.

What changes

  • Compute/mesh shaders no longer treat \Atom::Constant\ as requiring \console_lanes\ / \WaveSize(64).
  • \Atom::Constant\ and inline-constant \ _cndmask_b32\ masks lower via \ lat_console_lane\ (\ lattenedThreadIdInGroup & (wave - 1)) + \lane_bit_of.

Tests

  • \const_mask_tests::constant_lane_masks_in_compute_omit_wave_size_and_wave_ops: verifies \wave_size == None\ and !wave_ops.
  • \const_mask_tests::constant_lane_masks_2d_wave64_match_console_lanes_on_gpu_and_warp: runs a [16, 8, 1]\ (128-thread, 2-wave) Wave64 compute shader with \s[20:21]\ on host GPU + WARP and checks all 128 outputs.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5524821552 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3496). Originally posted by [danielibabet](https://github.com/danielibabet) on 2026-11-27T10:08:39Z. --- Compute and mesh shaders that branch on or select with a constant 64-bit lane mask (\Atom::Constant\) or an inline constant mask in \ _cndmask_b32\ previously forced \WaveSize(64)\, causing Wave32-only GPUs (NVIDIA RTX / Intel Arc) to reject the pipeline with \E_INVALIDARG\. Because console compute/mesh waves are consecutive runs of \wave\ flat group threads, a constant mask only depends on \ lattenedThreadIdInGroup & (wave - 1)\ and does not need \WaveSize(64)\ or \dx.op.waveGetLaneIndex\. **What changes** - Compute/mesh shaders no longer treat \Atom::Constant\ as requiring \console_lanes\ / \WaveSize(64)\. - \Atom::Constant\ and inline-constant \ _cndmask_b32\ masks lower via \ lat_console_lane\ (\ lattenedThreadIdInGroup & (wave - 1)\) + \lane_bit_of\. **Tests** - \const_mask_tests::constant_lane_masks_in_compute_omit_wave_size_and_wave_ops\: verifies \wave_size == None\ and \!wave_ops\. - \const_mask_tests::constant_lane_masks_2d_wave64_match_console_lanes_on_gpu_and_warp\: runs a \[16, 8, 1]\ (128-thread, 2-wave) Wave64 compute shader with \s[20:21]\ on host GPU + WARP and checks all 128 outputs.
cloph-dsp commented 2026-11-27 10:20:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T10:20:04Z.


Independent Windows CPU verification of PR #3496 (head 836fb58f5e436573b04995f3e19a2376656c642e, base 63bcca43c6a00a758510398fa43096ce7e4f7df0).

  • cargo test --locked -p victory-shader --lib -- emit::lower::const_mask_tests::constant_lane_masks_in_compute_omit_wave_size_and_wave_ops --exact --test-threads=1 --quiet → 1 passed, 0 failed, 305 filtered, exit 0.
  • git diff --check 63bcca4 HEAD → clean (exit 0).
  • Negative control: git grep -F constant_lane_masks_in_compute_omit_wave_size_and_wave_ops 63bcca4 -- crates/victory-shader/src/emit/const_mask_tests.rs → no hit (exit 1), so the test is new on this PR.

Environment: Windows, Rust 1.100.0/MSVC, per-worktree CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2. Only the named synthetic CPU test was replayed; the GPU/WARP test constant_lane_masks_2d_wave64_match_console_lanes_on_gpu_and_warp and the full suite were not run here. No game data, assets, extracted shaders or DRM involved. AI-assisted (Hy4 flash). GPU/driver: N/A for this CPU-only test.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7215759406 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3496#issuecomment-7215759406). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T10:20:04Z. --- Independent Windows CPU verification of PR #3496 (head `836fb58f5e436573b04995f3e19a2376656c642e`, base `63bcca43c6a00a758510398fa43096ce7e4f7df0`). - `cargo test --locked -p victory-shader --lib -- emit::lower::const_mask_tests::constant_lane_masks_in_compute_omit_wave_size_and_wave_ops --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 305 filtered, exit 0. - `git diff --check 63bcca4 HEAD` → clean (exit 0). - Negative control: `git grep -F constant_lane_masks_in_compute_omit_wave_size_and_wave_ops 63bcca4 -- crates/victory-shader/src/emit/const_mask_tests.rs` → no hit (exit 1), so the test is new on this PR. Environment: Windows, Rust 1.100.0/MSVC, per-worktree `CARGO_TARGET_DIR`, `CARGO_BUILD_JOBS=2`. Only the named synthetic CPU test was replayed; the GPU/WARP test `constant_lane_masks_2d_wave64_match_console_lanes_on_gpu_and_warp` and the full suite were not run here. No game data, assets, extracted shaders or DRM involved. AI-assisted (Hy4 flash). GPU/driver: N/A for this CPU-only test.
AurumCarlos commented 2026-11-27 10:46:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-27T10:46:21Z.

Review: COMMENTED


The flat-index lane looks right for compute (console waves are runs of consecutive flat ids). Three points:

  • The v_cndmask_b32 half is #2792's change. The cndmasks selector chain in Lower::new (lower.rs:589) is the same hunk as #2792 (legayclightning22), which triage marked merge candidate, so the two will conflict. Dropping it here (or stacking on #2792) would keep this PR to the Atom::Constant part.
  • Neither test exercises & (wave - 1) (flat_console_lane, lower.rs:3042). Both use a single [8, 8, 1] wave64 group, where the flat index already is the console lane, so a version without the mask passes them too. Modelling the GPU test's two masks, dropping the & gives 0/64 wrong lanes for [8, 8, 1] wave64, but 62/128 for [16, 8, 1] wave64 and 4/64 for [8, 8, 1] with wave64: false. One of those shapes would cover it. Also, LLVM's gfx1030 assembler refuses an inline constant as the _e64 mask in both wave sizes (and disassembles 0x85 there as an invalid immediate), so the s[20:21] case is the one to rely on.
  • The description stops mid-sentence ("rejected by Wave32-only GPUs such as NVIDIA RTX and Intel Arc with "; the backticks look shell-escaped), so the second fix, the evidence (which programs this unblocks) and the test results are missing.
<!-- greyfinch-sync:Marvisak/VIctory:review:6086957777 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3496#pullrequestreview-6086957777). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-27T10:46:21Z. **Review:** COMMENTED --- The flat-index lane looks right for compute (console waves are runs of consecutive flat ids). Three points: - **The `v_cndmask_b32` half is #2792's change.** The `cndmasks` selector chain in `Lower::new` (`lower.rs:589`) is the same hunk as #2792 (legayclightning22), which triage marked merge candidate, so the two will conflict. Dropping it here (or stacking on #2792) would keep this PR to the `Atom::Constant` part. - **Neither test exercises `& (wave - 1)`** (`flat_console_lane`, `lower.rs:3042`). Both use a single `[8, 8, 1]` wave64 group, where the flat index already is the console lane, so a version without the mask passes them too. Modelling the GPU test's two masks, dropping the `&` gives 0/64 wrong lanes for `[8, 8, 1]` wave64, but 62/128 for `[16, 8, 1]` wave64 and 4/64 for `[8, 8, 1]` with `wave64: false`. One of those shapes would cover it. Also, LLVM's gfx1030 assembler refuses an inline constant as the `_e64` mask in both wave sizes (and disassembles `0x85` there as an invalid immediate), so the `s[20:21]` case is the one to rely on. - The description stops mid-sentence ("rejected by Wave32-only GPUs such as NVIDIA RTX and Intel Arc with \"; the backticks look shell-escaped), so the second fix, the evidence (which programs this unblocks) and the test results are missing.
oddmaniv commented 2026-11-27 10:58:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oddmaniv on 2026-11-27T10:58:14Z.


Independent verification of the PR author's concurrent WARP pipeline/draw test at 836fb58f5e436573b04995f3e19a2376656c642e.

cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture

Tree Result
Unmodified PR head 1 passed, 0 failed, 0 ignored; native exit 0
Unmodified main 1 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 1 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7216524811 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3496#issuecomment-7216524811). Originally posted by [oddmaniv](https://github.com/oddmaniv) on 2026-11-27T10:58:14Z. --- Independent verification of the PR author's concurrent WARP pipeline/draw test at `836fb58f5e436573b04995f3e19a2376656c642e`. `cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture` | Tree | Result | | --- | --- | | Unmodified PR head | 1 passed, 0 failed, 0 ignored; native exit 0 | | Unmodified main | 1 passed, 0 failed, 0 ignored; native exit 0 | | PR patch applied to pinned main | 1 passed, 0 failed, 0 ignored; native exit 0 | Main baseline pin: `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits. This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed. AI-assisted verification.
ColorMeBoom commented 2026-11-27 13:15:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T13:15:31Z.


AMD run: RX 5700 XT (RDNA1; the driver reports 32–64 lanes, so it may pick either; no mesh shaders), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. The PR head was merged onto main 63bcca4, tests ran on the native adapter (VICTORY_WARP unset), no game files. Head 836fb58.

  • const_mask tests: 2 passed, 0 failed. That includes constant_lane_masks_2d_wave64_match_console_lanes_on_gpu_and_warp, which opens the native adapter (Host::new(false) succeeds on this card) and then WARP. Its hardware loop doesn't print, so this is the assertion passing, not a printed readback.
  • Full victory-shader suite (--features host): 304 passed, 0 failed, 3 ignored.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7219253512 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3496#issuecomment-7219253512). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-27T13:15:31Z. --- **AMD run: RX 5700 XT** (RDNA1; the driver reports 32–64 lanes, so it may pick either; no mesh shaders), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. The PR head was merged onto `main` `63bcca4`, tests ran on the native adapter (`VICTORY_WARP` unset), no game files. Head `836fb58`. - `const_mask` tests: **2 passed, 0 failed**. That includes `constant_lane_masks_2d_wave64_match_console_lanes_on_gpu_and_warp`, which opens the native adapter (`Host::new(false)` succeeds on this card) and then WARP. Its hardware loop doesn't print, so this is the assertion passing, not a printed readback. - Full `victory-shader` suite (`--features host`): **304 passed, 0 failed, 3 ignored**. AI use: Claude Code (Claude Opus 5.5).
danielibabet commented 2026-12-01 09:31:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-12-01T09:31:00Z.


Thanks @AurumCarlos!

Updated pr/constant-lane-mask:

  1. Dropped the _cndmask_b32 cndmasks selector hunk so this PR no longer overlaps with #2792.
  2. Updated the GPU/WARP test to [16, 8, 1] (128 threads = 2 Wave64 waves) with s[20:21] (removing the inline
<!-- greyfinch-sync:Marvisak/VIctory:comment:7306813664 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3496#issuecomment-7306813664). Originally posted by [danielibabet](https://github.com/danielibabet) on 2026-12-01T09:31:00Z. --- Thanks @AurumCarlos! Updated pr/constant-lane-mask: 1. Dropped the _cndmask_b32 cndmasks selector hunk so this PR no longer overlaps with #2792. 2. Updated the GPU/WARP test to [16, 8, 1] (128 threads = 2 Wave64 waves) with s[20:21] (removing the inline
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/3496:upstream-pr/3496'
git switch 'upstream-pr/3496'

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/3496'
git switch 'upstream-pr/3496'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3496'
git switch 'upstream-pr/3496'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3496'
git switch 'main'
git merge --squash 'upstream-pr/3496'
git switch 'main'
git merge --ff-only 'upstream-pr/3496'
git switch 'main'
git merge 'upstream-pr/3496'
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!3496
No description provided.