shader: follow constant/uniform prefix terms, u32 products, and readfirstlane in wave sections #516

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

@⁠Sheffy007 on GitHub · 2026-11-27 23:17 UTC · original
Sheffy007:feat/whole-wave-section-shapes → main · +494 −55 · 5 files · 1 commits · open

Summary

  • Follow constant (Sym::K), uniform (Sym::Uni), and idempotent reduction (Sym::Red) active-lane terms in v_cndmask_b32 inside whole-wave sections (for example v_cndmask_b32 vdst, 0, s_stride, s_mask for constant-stride prefix scans), as well as constant scalar lane-select masks (s_mov_b32 / s_mov_b64 of row or half bitmasks) without requiring EXEC saves/restores.
  • Record per-lane uniform shapes (such as lane wave - 1 of a Shape::Prefix inclusive scan) in Lower::section_lanes so a constant-lane v_readlane_b32 after the section evaluates the total reduction cleanly even when lane wave - 1 was inactive before the section.
  • Follow 32-bit integer WaveActiveProduct reductions (v_mul_lo_u32 and s_mul_i32, identity 1) across single and split wave64 host waves (halves_reduce), while keeping prefix products refused.
  • Follow v_readfirstlane_b32 under a known constant EXEC mask (exec.trailing_zeros()) both inside a whole-wave section and immediately after one (Lower::section_rfl).

Verification

  • Unit tests in victory_shader::emit::wave::tests:
    • whole_wave_const_uniform_cndmask_const_masks_mulu_and_readfirstlane_lower (covering both wave64 single-wave and wave32_host split-wave translation, plus negative refusal checks for prefix products and non-identity inactive inputs)
  • Metal GPU value test in victory_gpu::native::tests::split_wave_tests:
    • whole_wave_const_uniform_prefixes_integer_products_and_readfirstlane_run_across_halves
  • cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtask
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy

Closes #512
Refs #4, #258
cc @⁠Olima34

**@⁠Sheffy007** on GitHub · 2026-11-27 23:17 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/512) `Sheffy007:feat/whole-wave-section-shapes` → `main` · +494 −55 · 5 files · 1 commits · open ## Summary - Follow constant (`Sym::K`), uniform (`Sym::Uni`), and idempotent reduction (`Sym::Red`) active-lane terms in `v_cndmask_b32` inside whole-wave sections (for example `v_cndmask_b32 vdst, 0, s_stride, s_mask` for constant-stride prefix scans), as well as constant scalar lane-select masks (`s_mov_b32` / `s_mov_b64` of row or half bitmasks) without requiring `EXEC` saves/restores. - Record per-lane uniform shapes (such as lane `wave - 1` of a `Shape::Prefix` inclusive scan) in `Lower::section_lanes` so a constant-lane `v_readlane_b32` after the section evaluates the total reduction cleanly even when lane `wave - 1` was inactive before the section. - Follow 32-bit integer `WaveActiveProduct` reductions (`v_mul_lo_u32` and `s_mul_i32`, identity `1`) across single and split wave64 host waves (`halves_reduce`), while keeping prefix products refused. - Follow `v_readfirstlane_b32` under a known constant `EXEC` mask (`exec.trailing_zeros()`) both inside a whole-wave section and immediately after one (`Lower::section_rfl`). ## Verification - Unit tests in `victory_shader::emit::wave::tests`: - `whole_wave_const_uniform_cndmask_const_masks_mulu_and_readfirstlane_lower` (covering both wave64 single-wave and `wave32_host` split-wave translation, plus negative refusal checks for prefix products and non-identity inactive inputs) - Metal GPU value test in `victory_gpu::native::tests::split_wave_tests`: - `whole_wave_const_uniform_prefixes_integer_products_and_readfirstlane_run_across_halves` - `cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtask` - `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy` Closes #512 Refs #4, #258 cc @⁠Olima34
In whole-wave reduction and prefix sections:
- accept uniform, constant, and idempotent reduction active-lane terms in
  v_cndmask_b32 as well as constant scalar lane-select masks (row/half
  bitmasks loaded via s_mov_b32 or s_mov_b64), and preserve per-lane uniform
  shapes (such as lane 63 of an inclusive prefix) in section_lanes;
- follow integer WaveActiveProduct reductions formed by v_mul_lo_u32 and
  s_mul_i32 (identity 1) across split wave64 halves;
- follow v_readfirstlane_b32 under a known constant EXEC mask both inside
  and immediately after a section.

Closes #508
Refs #4, #258
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 23:19:06 +00:00
Author
Owner

@⁠Olima34 on GitHub · 2026-11-27 23:21 UTC · original

Thanks @⁠Sheffy007, this is right on our current focus. We're now working on translator coverage, to get as many refused world shaders as possible to translate, and whole-wave sections are one of the larger families. We'll run #516 over our boot corpora (4,921 translated and 4,129 refused containers), by output fingerprint as for #468, and post gained / lost / changed per stage here. We'll also note the overlap with marcus-4's #442 and with your own #452 and #468 where they touch the same sections.

**@⁠Olima34** on GitHub · 2026-11-27 23:21 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/512#issuecomment-7230073436) Thanks @⁠Sheffy007, this is right on our current focus. We're now working on translator coverage, to get as many refused world shaders as possible to translate, and whole-wave sections are one of the larger families. We'll run #516 over our boot corpora (4,921 translated and 4,129 refused containers), by output fingerprint as for #468, and post gained / lost / changed per stage here. We'll also note the overlap with marcus-4's #442 and with your own #452 and #468 where they touch the same sections.
github-bot force-pushed github-bot/gh-512 from 5f6f1fa60b to b864cf7215 2026-11-28 00:35:39 +00:00 Compare
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 01:31 UTC · original

Thanks for this PR! An offline check of b864cf72, with no game run:

Corpus sweep (examples/sweep + tools/corpus/compare.sh), measured on main a6a58361, which translates shaders the same way as current main 226645f9. Main → main + #516:

set newly translated output changed regressions
A (4,921 boot shaders) 0 0 0
B (4,129 boot shaders) 0 0 0
W (21,600 world shaders) 0 0 0

No shader in these three sets has a whole-wave section of the kind #516 handles as its first refusal, so this is a no-regression check rather than a coverage measurement.

Checks: on an earlier main (b998bb65) + #516, the tests (victory-gpu on arm64, victory-hle, victory, xtask, victory-shader), Windows clippy (-D warnings) and cargo xtask policy all pass. CI is green on b864cf72.

Merging on a6a58361:

  • #516 merges cleanly with #452, #468 and #520.
  • With #442, the only conflict is in split_wave_tests.rs: both PRs add GPU tests at the same spot.
**@⁠Olima34** on GitHub · 2026-11-28 01:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/512#issuecomment-7231731611) Thanks for this PR! An offline check of b864cf72, with no game run: **Corpus sweep** (`examples/sweep` + `tools/corpus/compare.sh`), measured on main a6a58361, which translates shaders the same way as current main 226645f9. Main → main + #516: | set | newly translated | output changed | regressions | |---|---|---|---| | A (4,921 boot shaders) | 0 | 0 | 0 | | B (4,129 boot shaders) | 0 | 0 | 0 | | W (21,600 world shaders) | 0 | 0 | 0 | No shader in these three sets has a whole-wave section of the kind #516 handles as its first refusal, so this is a no-regression check rather than a coverage measurement. **Checks:** on an earlier main (b998bb65) + #516, the tests (victory-gpu on arm64, victory-hle, victory, xtask, victory-shader), Windows clippy (`-D warnings`) and `cargo xtask policy` all pass. CI is green on b864cf72. **Merging on a6a58361:** - #516 merges cleanly with #452, #468 and #520. - With #442, the only conflict is in `split_wave_tests.rs`: both PRs add GPU tests at the same spot.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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