shader(fold): sign-extend negative inline constants in upper mask9 half #2983

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

@⁠RanoGames on GitHub · 2026-11-29 19:12 UTC · original
RanoGames:fix/fold-mask9-negative-upper → main · +38 −0 · 1 files · 1 commits · open

What it changes

Fixes mask9 in crates/victory-shader/src/fold.rs when folding 64-lane VALU instructions (such as v_cndmask_b32 and *_co_ci_u32 carry-in) into lower/upper 32-lane halves:

  • Inline positive integers 129..=192 and 32-bit literals 255 already mapped to 128 (0) in upper(half) (Half::B / Half::BSwap).
  • Inline negative integers 193..=208 (-1..=-16) sign-extend to -1 (0xFFFF_FFFF, code 193) in bits 32..63 (matching halves()), but mask9 previously returned Ok(code) unchanged for 194..=208, clearing bits in lanes 32..35 on the upper half.
  • Added 193..=208 if upper(half) => Ok(193) and unit test fold::tests::mask9_sign_extends_negative_inline_constants_in_upper_half.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit + folded_tests in victory-shader)
  • Before: mask9(194..=208, Half::B | Half::BSwap, ...) returned 194..=208 (-2..=-16) instead of 193 (-1, all 32 upper lanes set).
  • After: mask9(193..=208, Half::B | Half::BSwap, ...) returns 193.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): Wave64 folded to 2x Wave32 (emit::folded_tests + fold::tests)
  • cargo test passed for the crates it touches: yes (cargo test --locked -p victory-shader --lib -- fold::tests emit::folded_tests: 18 passed, 0 failed; cargo xtask policy --staged passed)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
**@⁠RanoGames** on GitHub · 2026-11-29 19:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2983) `RanoGames:fix/fold-mask9-negative-upper` → `main` · +38 −0 · 1 files · 1 commits · open ## What it changes Fixes `mask9` in `crates/victory-shader/src/fold.rs` when folding 64-lane VALU instructions (such as `v_cndmask_b32` and `*_co_ci_u32` carry-in) into lower/upper 32-lane halves: - Inline positive integers `129..=192` and 32-bit literals `255` already mapped to `128` (`0`) in `upper(half)` (`Half::B` / `Half::BSwap`). - Inline negative integers `193..=208` (`-1..=-16`) sign-extend to `-1` (`0xFFFF_FFFF`, code `193`) in bits `32..63` (matching `halves()`), but `mask9` previously returned `Ok(code)` unchanged for `194..=208`, clearing bits in lanes `32..35` on the upper half. - Added `193..=208 if upper(half) => Ok(193)` and unit test `fold::tests::mask9_sign_extends_negative_inline_constants_in_upper_half`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit + `folded_tests` in `victory-shader`) - Before: `mask9(194..=208, Half::B | Half::BSwap, ...)` returned `194..=208` (`-2..=-16`) instead of `193` (`-1`, all 32 upper lanes set). - After: `mask9(193..=208, Half::B | Half::BSwap, ...)` returns `193`. - For shader changes, the wave sizes tested (32 and/or 64 lanes): Wave64 folded to 2x Wave32 (`emit::folded_tests` + `fold::tests`) - `cargo test` passed for the crates it touches: yes (`cargo test --locked -p victory-shader --lib -- fold::tests emit::folded_tests`: 18 passed, 0 failed; `cargo xtask policy --staged` passed) ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:13:39 +00:00
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/2983/head:github-bot/gh-2983'
git switch 'github-bot/gh-2983'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2983'
git switch 'github-bot/gh-2983'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2983'
git switch 'github-bot/gh-2983'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2983'
git switch 'main'
git merge --squash 'github-bot/gh-2983'
git switch 'main'
git merge --ff-only 'github-bot/gh-2983'
git switch 'main'
git merge 'github-bot/gh-2983'
git push origin 'main'
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/trustno1-coder--VIctory-NVIDIA!2983
No description provided.