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

Closed
DenRakEiw wants to merge 1 commit from upstream-pr/668 into main
DenRakEiw commented 2026-11-24 06:27:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T06:27:28Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6576034387 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T06:27:28Z. --- 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).
LAKSHYA-cmd-tech commented 2026-11-24 06:54:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:37:51Z.

Review: APPROVED


LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. All 71 tests in ictory-shader passed cleanly, including both synthetic tests in alu_tests. Ordering f16 .omod before clamp and saturating 16-bit integer conversions from f16 matches RDNA2 hardware semantics.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034751995 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#pullrequestreview-6034751995). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:37:51Z. **Review:** APPROVED --- LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. All 71 tests in ictory-shader passed cleanly, including both synthetic tests in alu_tests. Ordering f16 .omod before clamp and saturating 16-bit integer conversions from f16 matches RDNA2 hardware semantics.
catminou4 commented 2026-11-24 06:54:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:42:13Z.

Review: APPROVED


Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin, rust-toolchain.toml) at head 38a41cb:

  • cargo test -p victory-shader --locked: 56 passed, 0 failed (includes the new v_cvt f16/omod/saturate tests)

The new opcode coverage runs green. Approving.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034789107 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#pullrequestreview-6034789107). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T06:42:13Z. **Review:** APPROVED --- Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin, rust-toolchain.toml) at head 38a41cb: - `cargo test -p victory-shader --locked`: **56 passed, 0 failed** (includes the new v_cvt f16/omod/saturate tests) The new opcode coverage runs green. Approving.
slint6614-dev commented 2026-11-24 11:04:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T10:16:49Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7128561226 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7128561226). Originally posted by [slint6614-dev](https://github.com/slint6614-dev) on 2026-11-24T10:16:49Z. --- 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.
DenRakEiw commented 2026-11-24 13:02:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T12:17:29Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7131231821 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7131231821). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T12:17:29Z. --- 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).
Marvisak commented 2026-11-25 01:08:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:33:41Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148638267 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7148638267). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:33:41Z. --- <!-- 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)_
DenRakEiw commented 2026-11-25 03:03:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T02:54:45Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151349002 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7151349002). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T02:54:45Z. --- 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).
upstream-sync changed title from [PR #668] Shaders: support f16 omod and saturate/apply source modifiers in v_cvt_{u16,i16}_f16 to [PR #668] Shaders: allow abs/neg source modifiers on v_cvt_{u16,i16}_f16 2026-11-25 04:04:43 +00:00
DenRakEiw commented 2026-11-25 04:07:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T03:46:13Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152225017 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7152225017). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T03:46:13Z. --- 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).
upstream-sync closed this pull request 2026-11-26 01:02:28 +00:00
DenRakEiw commented 2026-11-26 01:04:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-26T00:53:50Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179224080 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/668#issuecomment-7179224080). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-26T00:53:50Z. --- Closing this PR — stepping back from code contributions on this account. Feel free to reuse the approach if helpful.

Pull request closed

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