Shaders: allow abs/neg source modifiers on v_cvt_{u16,i16}_f16 #668

Closed
github-bot wants to merge 1 commit from gh-pr/668/head into gh-pr/668/base
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 06:27 UTC · original
fix/valu16-omod-and-cvt-saturation → main · +92 −3 · 2 files · 1 commits · closed without merging

Allow VOP3 abs/neg source modifiers on v_cvt_u16_f16 and v_cvt_i16_f16 in valu16_op (crates/victory-shader/src/emit/lower.rs).

Motivation

v_cvt_u16_f16 and v_cvt_i16_f16 already read their f16 operand via half_fsrc, which applies VOP3 abs/neg modifiers, and already saturate to 16-bit integer bounds on main (commit 2af66ff1). However, the guard right above the integer match rejected v.abs != 0 || v.neg != 0 for all arms, including these two float-source conversions.

Changes

  • crates/victory-shader/src/emit/lower.rs: exempt v_cvt_u16_f16 and v_cvt_i16_f16 from the v.abs != 0 || v.neg != 0 rejection while keeping v.clamp || v.omod != 0 rejected and keeping all integer-source 16-bit ops unchanged.
  • crates/victory-shader/src/emit/valu_tests.rs: add cvt_16bit_int_from_f16_saturates_and_honors_modifiers covering v_cvt_u16_f16 (including |src0|) and v_cvt_i16_f16 (including -src0), NaN, infinities, and out-of-range saturation.

Verified locally on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib cvt_16bit_int_from_f16_saturates_and_honors_modifiers — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 06:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/668) `fix/valu16-omod-and-cvt-saturation` → `main` · +92 −3 · 2 files · 1 commits · closed without merging Allow VOP3 `abs`/`neg` source modifiers on `v_cvt_u16_f16` and `v_cvt_i16_f16` in `valu16_op` (`crates/victory-shader/src/emit/lower.rs`). ### Motivation `v_cvt_u16_f16` and `v_cvt_i16_f16` already read their `f16` operand via `half_fsrc`, which applies VOP3 `abs`/`neg` modifiers, and already saturate to 16-bit integer bounds on `main` (commit `2af66ff1`). However, the guard right above the integer `match` rejected `v.abs != 0 || v.neg != 0` for all arms, including these two float-source conversions. ### Changes - `crates/victory-shader/src/emit/lower.rs`: exempt `v_cvt_u16_f16` and `v_cvt_i16_f16` from the `v.abs != 0 || v.neg != 0` rejection while keeping `v.clamp || v.omod != 0` rejected and keeping all integer-source 16-bit ops unchanged. - `crates/victory-shader/src/emit/valu_tests.rs`: add `cvt_16bit_int_from_f16_saturates_and_honors_modifiers` covering `v_cvt_u16_f16` (including `|src0|`) and `v_cvt_i16_f16` (including `-src0`), NaN, infinities, and out-of-range saturation. Verified locally on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib cvt_16bit_int_from_f16_saturates_and_honors_modifiers` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) AI-assisted (Gemini 4 Neon).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:12:14 +00:00
github-bot closed this pull request 2026-11-26 04:12:14 +00:00
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:16 UTC · original

AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of run_cases (local adapter-selection patch, not part of this PR); cargo test -p victory-shader --release valu_tests at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept.

  • With this PR, f16_omod_applies_before_clamp and cvt_16bit_int_from_f16_saturates_and_honors_modifiers pass on both AMD GPUs.
  • Negative control: both fail on both GPUs without the fix, so the tests do catch the change on AMD hardware.
**@⁠slint6614-dev** on GitHub · 2026-11-24 10:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7128561226) AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of `run_cases` (local adapter-selection patch, not part of this PR); `cargo test -p victory-shader --release valu_tests` at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept. - With this PR, `f16_omod_applies_before_clamp` and `cvt_16bit_int_from_f16_saturates_and_honors_modifiers` pass on both AMD GPUs. - Negative control: both fail on both GPUs without the fix, so the tests do catch the change on AMD hardware.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 12:17 UTC · original

Rebased onto latest \main\ (\ fe310e): kept upstream's f32-clamped saturation for \ cvt{u16,i16}_f16\ while retaining \ 16\ \ .omod\ (before \clamp) and \bs/
eg\ source modifiers on \ cvt{u16,i16}_f16. Re-verified with \cargo test -p victory-shader\ (122 passed, 0 failed on Windows 11 / RTX 5090 + WARP), \cargo clippy -p victory-shader --all-targets\ (0 warnings), and \cargo xtask policy. AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 12:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7131231821) Rebased onto latest \main\ (\ fe310e\): kept upstream's f32-clamped saturation for \ _cvt_{u16,i16}_f16\ while retaining \ 16\ \ .omod\ (before \clamp\) and \bs\/\ eg\ source modifiers on \ _cvt_{u16,i16}_f16\. Re-verified with \cargo test -p victory-shader\ (122 passed, 0 failed on Windows 11 / RTX 5090 + WARP), \cargo clippy -p victory-shader --all-targets\ (0 warnings), and \cargo xtask policy\. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:33 UTC · original · edited 2026-11-25 22:28 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7148638267) · edited 2026-11-25 22:28 UTC <!-- victory-triage v1 head=19c82b9e7785fdc9c34329c6975aee7c8165193c verdict=needs-rebase at=2026-11-25T22:32:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/valu_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 02:54 UTC · original

Rebased cleanly onto latest origin/main (940d32f, head aca82f4) resolving the tail conflict in crates/victory-shader/src/emit/valu_tests.rs.

Re-verified locally on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • f16_omod_applies_before_clamp and v_cvt_u16_i16_f16_* — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Ready for review. AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 02:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7151349002) Rebased cleanly onto latest `origin/main` (`940d32f`, head `aca82f4`) resolving the tail conflict in `crates/victory-shader/src/emit/valu_tests.rs`. Re-verified locally on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `f16_omod_applies_before_clamp` and `v_cvt_u16_i16_f16_*` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Ready for review. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 03:46 UTC · original

Addressed the triage feedback:

  • Split out the f16 omod change (until RDNA2 f16 omod denormal behavior is measured on hardware) so this PR is now strictly scoped to allowing abs/neg on v_cvt_{u16,i16}_f16.
  • Minimized the lower.rs diff to a 4-line guard update (no moved integer match block).
  • Updated the PR title and description to match the focused scope and kept the end-to-end GPU+WARP test (cvt_16bit_int_from_f16_saturates_and_honors_modifiers).

Re-verified locally on RTX 5090 + WARP, cargo clippy -p victory-shader --all-targets (0 warnings), and cargo xtask policy (ok).

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 03:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7152225017) Addressed the triage feedback: - Split out the `f16` `omod` change (until RDNA2 f16 omod denormal behavior is measured on hardware) so this PR is now strictly scoped to allowing `abs`/`neg` on `v_cvt_{u16,i16}_f16`. - Minimized the `lower.rs` diff to a 4-line guard update (no moved integer match block). - Updated the PR title and description to match the focused scope and kept the end-to-end GPU+WARP test (`cvt_16bit_int_from_f16_saturates_and_honors_modifiers`). Re-verified locally on RTX 5090 + WARP, `cargo clippy -p victory-shader --all-targets` (0 warnings), and `cargo xtask policy` (ok). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-26 00:53 UTC · original

Closing this PR — stepping back from code contributions on this account. Feel free to reuse the approach if helpful.

**@⁠DenRakEiw** on GitHub · 2026-11-26 00:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7179224080) Closing this PR — stepping back from code contributions on this account. Feel free to reuse the approach if helpful.

Pull request closed

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!668
No description provided.