Shaders: lower v_mov_b32 abs/neg modifiers bitwise #2548

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

@⁠fuzeofficlal on GitHub · 2026-11-25 15:38 UTC · original
fuzeofficlal:fix/shader-vmov-b32-bitwise-modifiers-883 → main · +126 −41 · 2 files · 1 commits · open

Refs #883

Summary

Ports the remaining v_mov_b32 half of #883 (AscilCH's cacf6ad, with Co-authored-by preserved) onto current main (v_cndmask_b32 already landed there):

  • On RDNA2, source abs and neg modifiers on v_mov_b32 clear or flip bit 31 bitwise without flushing subnormal values or quieting sNaN payloads unless a floating-point output modifier (clamp or omod) is active.
  • Extracts Lower::src_bits in crates/victory-shader/src/emit/lower.rs (preserving DPP src0, low16_src, and SDWA byte/word selection before applying And 0x7FFF_FFFF / Xor 0x8000_0000), sharing it across Lower::src, v_mov_b32, and v_cndmask_b32.
  • Routes v_mov_b32 through as_float + write_f only when v.clamp || v.omod != 0.

Verification

  • Added emit::valu_tests::v_mov_b32_modifiers_are_bitwise (crates/victory-shader/src/emit/valu_tests.rs) covering v_mov_b32_e64 (-v1, |v1|, -|v1|), v_mov_b32_sdwa (-v1, -v1.w0, |sext(v1.b0)|) across normals, ±0.0, ±inf, min/max ±denormal, ±sNaN, and payload ±qNaN, plus v_mov_b32_e64 with clamp and omod = mul:2.
  • Negative control against unpatched lower.rs reproduces subnormal flushing (0x0000_0001 -> 0x8000_0000 instead of 0x8000_0001).
  • cargo test -p victory-shader --lib emit::valu_tests (passed on both RTX 5090 hardware and D3D12 WARP, validated with dxil.dll)
  • cargo clippy -p victory-shader --all-targets -- -D warnings (default and --no-default-features)
  • cargo xtask policy
**@⁠fuzeofficlal** on GitHub · 2026-11-25 15:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2548) `fuzeofficlal:fix/shader-vmov-b32-bitwise-modifiers-883` → `main` · +126 −41 · 2 files · 1 commits · open Refs #883 ## Summary Ports the remaining `v_mov_b32` half of #883 (`AscilCH`'s `cacf6ad`, with `Co-authored-by` preserved) onto current `main` (`v_cndmask_b32` already landed there): - On RDNA2, source `abs` and `neg` modifiers on `v_mov_b32` clear or flip bit 31 bitwise without flushing subnormal values or quieting `sNaN` payloads unless a floating-point output modifier (`clamp` or `omod`) is active. - Extracts `Lower::src_bits` in `crates/victory-shader/src/emit/lower.rs` (preserving DPP `src0`, `low16_src`, and SDWA byte/word selection before applying `And 0x7FFF_FFFF` / `Xor 0x8000_0000`), sharing it across `Lower::src`, `v_mov_b32`, and `v_cndmask_b32`. - Routes `v_mov_b32` through `as_float` + `write_f` only when `v.clamp || v.omod != 0`. ## Verification - Added `emit::valu_tests::v_mov_b32_modifiers_are_bitwise` (`crates/victory-shader/src/emit/valu_tests.rs`) covering `v_mov_b32_e64` (`-v1`, `|v1|`, `-|v1|`), `v_mov_b32_sdwa` (`-v1`, `-v1.w0`, `|sext(v1.b0)|`) across normals, `±0.0`, `±inf`, min/max `±denormal`, `±sNaN`, and payload `±qNaN`, plus `v_mov_b32_e64` with `clamp` and `omod = mul:2`. - Negative control against unpatched `lower.rs` reproduces subnormal flushing (`0x0000_0001 -> 0x8000_0000` instead of `0x8000_0001`). - `cargo test -p victory-shader --lib emit::valu_tests` (passed on both RTX 5090 hardware and D3D12 WARP, validated with `dxil.dll`) - `cargo clippy -p victory-shader --all-targets -- -D warnings` (default and `--no-default-features`) - `cargo xtask policy`
On RDNA2, source abs/neg on v_mov_b32 clears or flips bit 31 bitwise without quieting sNaN or flushing denormals unless a float output modifier (clamp/omod) is active. Extract Lower::src_bits to apply SDWA selection and bitwise abs/neg consistently for both v_mov_b32 and v_cndmask_b32, and only convert to float for write_f when clamp or omod is set.

Co-authored-by: AscilCH <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:56 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:35 UTC · original · edited 2026-11-26 03:23 UTC

Automated triage for the maintainers.

Verdict: merge candidate (unchanged). The new head is a rebase onto current main, and it merges cleanly. I reread the whole diff. Lower::src_bits (crates/victory-shader/src/emit/lower.rs) applies abs/neg to the bits after the DPP, low16 and SDWA selection. Lower::src still refuses modifiers on other integer operations. v_mov_b32 goes through the float path only with clamp/omod. v_cndmask_b32 now uses the shared helper in place of its own copy of the same loop. The test in valu_tests.rs is unchanged in what it covers.

As noted before, #1275 makes the same change on an old base, and only one of the two should land.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2548#issuecomment-7171128276) · edited 2026-11-26 03:23 UTC <!-- victory-triage v1 head=f3809a892f860c761e338326add17c30c2af0125 verdict=merge-candidate at=2026-11-26T03:23:25Z --> Automated triage for the maintainers. **Verdict: merge candidate (unchanged).** The new head is a rebase onto current `main`, and it merges cleanly. I reread the whole diff. `Lower::src_bits` (`crates/victory-shader/src/emit/lower.rs`) applies `abs`/`neg` to the bits after the DPP, `low16` and SDWA selection. `Lower::src` still refuses modifiers on other integer operations. `v_mov_b32` goes through the float path only with `clamp`/`omod`. `v_cndmask_b32` now uses the shared helper in place of its own copy of the same loop. The test in `valu_tests.rs` is unchanged in what it covers. As noted before, #1275 makes the same change on an old base, and only one of the two should land. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠brainbudt on GitHub · 2026-11-25 21:10 UTC · original

Note

🤖 Gemini 4 Neon (with GPT-6.2 Astra, Mistral Large 4, and DeepSeek V4.1 Flash) responding on behalf of brainbudt

APPROVE — independently verified cc7e263 merged onto main (13f91ca).

  • Windows 11 WARP: 31/31 VALU tests passed, including exact-bit checks for -0.0, subnormals, signaling and quiet NaNs, and combined abs/neg. Negative control with main's lowering confirmed negating 0x00000001 returned 0x80000000 instead of 0x80000001; this PR preserves the payload.
  • Microsoft DXIL Validator (1.9.2609.5): accepted 8/8 containers (all 7 regression shaders plus an additional DPP shader whose disassembly shows WaveReadLaneAt -> and i32 -> xor i32).
  • Windows MSVC: cargo check -p victory-shader --target x86_64-pc-windows-msvc --tests --locked passed.
**@⁠brainbudt** on GitHub · 2026-11-25 21:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2548#issuecomment-7174720927) > [!NOTE] > 🤖 **Gemini 4 Neon (with GPT-6.2 Astra, Mistral Large 4, and DeepSeek V4.1 Flash) responding on behalf of brainbudt** **APPROVE** — independently verified `cc7e263` merged onto `main` (`13f91ca`). - **Windows 11 WARP:** 31/31 VALU tests passed, including exact-bit checks for `-0.0`, subnormals, signaling and quiet NaNs, and combined `abs`/`neg`. Negative control with `main`'s lowering confirmed negating `0x00000001` returned `0x80000000` instead of `0x80000001`; this PR preserves the payload. - **Microsoft DXIL Validator (`1.9.2609.5`):** accepted 8/8 containers (all 7 regression shaders plus an additional DPP shader whose disassembly shows `WaveReadLaneAt -> and i32 -> xor i32`). - **Windows MSVC:** `cargo check -p victory-shader --target x86_64-pc-windows-msvc --tests --locked` passed.
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/2548/head:github-bot/gh-2548'
git switch 'github-bot/gh-2548'

Merge

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