Shaders: lower v_mad_{u16,i16} and saturating clamp on 16-bit integer ops #1211

Open
ESAT586 wants to merge 1 commit from upstream-pr/1211 into main
ESAT586 commented 2026-11-24 16:26:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-24T16:26:15Z.


AI Disclosure — Generated & Verified by Gemini 4 Neon (High Mode) (Not Written by a Human Engineer)
This diagnosis, RDNA2 ISA implementation, and synthetic GPU/WARP test suite were authored and verified end-to-end by Gemini 4 Neon (High Mode), submitted transparently on behalf of @ESAT586. All builds, clippy checks, DXIL validation, and GPU/WARP tests below were executed locally on real hardware (NVIDIA GeForce RTX 3060 Ti, Windows 11, Rust 1.98.1). No game data was used.

What's wrong

In crates/victory-shader/src/emit/lower.rs (valu16 / valu16_op):

  1. v_mad_u16 (VOP3 0x340) and v_mad_i16 (VOP3 0x35e) are decoded in gfx10/opcodes.rs but not lowered, causing shaders using 16-bit integer multiply-add to fail lowering.
  2. valu16_op rejects v.clamp on all 16-bit integer ops with Err("modifiers on a 16-bit integer operation"), even though under the AMD RDNA2 ISA clamp = 1 selects saturating 16-bit arithmetic on v_add_nc_u16, v_sub_nc_u16, v_subrev_nc_u16, v_mad_u16, and v_mad_i16.

Fix

  • Add v_mad_u16 and v_mad_i16 to valu16's INT list and compute a * b + d in 32 bits (half_src zero-extended for _u16, sign-extended for _i16), preserving the untouched destination half via write_half.
  • Allow v.clamp specifically on v_add_nc_u16, v_sub_nc_u16, v_subrev_nc_u16, v_mad_u16, and v_mad_i16:
    • v_add_nc_u16 / v_mad_u16: clamp to 0xFFFF via IUGT (u16::MAX * u16::MAX + u16::MAX <= u32::MAX, never wraps u32).
    • v_sub_nc_u16 / v_subrev_nc_u16: clamp to 0 via SLT (result is in [-65535, 65535]).
    • v_mad_i16: clamp to [-32768, 32767] via SLT/SGT (|r| <= 32768 * 32768 + 32768 < 2^31, never wraps i32).
    • Non-saturating 16-bit integer ops keep rejecting v.clamp.
  • Add emit::valu_tests::v_mad_16_and_int16_clamp_match_rdna2 in crates/victory-shader/src/emit/valu_tests.rs testing wrapping & saturating v_mad_u16, v_mad_i16, v_add_nc_u16 clamp, v_sub_nc_u16 clamp, and upper-half preservation.

Verification (Real GPU + WARP + CI Gates)

Tested on Windows 11, NVIDIA GeForce RTX 3060 Ti (driver 32.0.16.1656), Rust 1.98.1:

  • cargo test -p victory-shader --lib v_mad_16_and_int16_clamp_match_rdna2: ok (dxil.dll validator + RTX 3060 Ti hardware + Microsoft WARP)
  • cargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignored
  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass (0 warnings)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (0 warnings)
  • cargo xtask policy: asset policy: 154 files ok

Scope & Non-Overlap

  • Independent complement to #1142 (which covers packed VOP3P v_pk_*); this PR covers single-lane valu16 (v_mad_u16, v_mad_i16, and 16-bit integer clamp). Checked open PRs and issues — no overlap.
  • Not tested: against retail title shader packages (synthetic fixtures only, no game data).
<!-- greyfinch-sync:Marvisak/VIctory:issue:5476140991 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-24T16:26:15Z. --- > **AI Disclosure — Generated & Verified by Gemini 4 Neon (High Mode) (Not Written by a Human Engineer)** > This diagnosis, RDNA2 ISA implementation, and synthetic GPU/WARP test suite were authored and verified end-to-end by **Gemini 4 Neon (High Mode)**, submitted transparently on behalf of `@ESAT586`. All builds, clippy checks, DXIL validation, and GPU/WARP tests below were executed locally on real hardware (`NVIDIA GeForce RTX 3060 Ti`, Windows 11, Rust `1.98.1`). **No game data was used.** ## What's wrong In `crates/victory-shader/src/emit/lower.rs` (`valu16` / `valu16_op`): 1. `v_mad_u16` (`VOP3 0x340`) and `v_mad_i16` (`VOP3 0x35e`) are decoded in `gfx10/opcodes.rs` but not lowered, causing shaders using 16-bit integer multiply-add to fail lowering. 2. `valu16_op` rejects `v.clamp` on all 16-bit integer ops with `Err("modifiers on a 16-bit integer operation")`, even though under the AMD RDNA2 ISA `clamp = 1` selects saturating 16-bit arithmetic on `v_add_nc_u16`, `v_sub_nc_u16`, `v_subrev_nc_u16`, `v_mad_u16`, and `v_mad_i16`. ## Fix - Add `v_mad_u16` and `v_mad_i16` to `valu16`'s `INT` list and compute `a * b + d` in 32 bits (`half_src` zero-extended for `_u16`, sign-extended for `_i16`), preserving the untouched destination half via `write_half`. - Allow `v.clamp` specifically on `v_add_nc_u16`, `v_sub_nc_u16`, `v_subrev_nc_u16`, `v_mad_u16`, and `v_mad_i16`: - `v_add_nc_u16` / `v_mad_u16`: clamp to `0xFFFF` via `IUGT` (`u16::MAX * u16::MAX + u16::MAX <= u32::MAX`, never wraps `u32`). - `v_sub_nc_u16` / `v_subrev_nc_u16`: clamp to `0` via `SLT` (result is in `[-65535, 65535]`). - `v_mad_i16`: clamp to `[-32768, 32767]` via `SLT`/`SGT` (`|r| <= 32768 * 32768 + 32768 < 2^31`, never wraps `i32`). - Non-saturating 16-bit integer ops keep rejecting `v.clamp`. - Add `emit::valu_tests::v_mad_16_and_int16_clamp_match_rdna2` in `crates/victory-shader/src/emit/valu_tests.rs` testing wrapping & saturating `v_mad_u16`, `v_mad_i16`, `v_add_nc_u16 clamp`, `v_sub_nc_u16 clamp`, and upper-half preservation. ## Verification (Real GPU + WARP + CI Gates) Tested on Windows 11, **NVIDIA GeForce RTX 3060 Ti** (driver `32.0.16.1656`), Rust `1.98.1`: - `cargo test -p victory-shader --lib v_mad_16_and_int16_clamp_match_rdna2`: **ok** (`dxil.dll` validator + RTX 3060 Ti hardware + Microsoft WARP) - `cargo test -p victory-shader --locked`: **121 passed, 0 failed, 1 ignored** - `cargo clippy --workspace --all-targets --locked -- -D warnings`: **pass (0 warnings)** - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: **pass (0 warnings)** - `cargo xtask policy`: **`asset policy: 154 files ok`** ## Scope & Non-Overlap - Independent complement to `#1142` (which covers packed VOP3P `v_pk_*`); this PR covers single-lane `valu16` (`v_mad_u16`, `v_mad_i16`, and 16-bit integer `clamp`). Checked open PRs and issues — no overlap. - **Not tested:** against retail title shader packages (synthetic fixtures only, no game data).
shortselow-byte commented 2026-11-24 18:05:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T17:23:40Z.


This PR has no CI run yet, so I ran the CI's checks at head 7dffb2a (on main ffe310e) on AMD, to add a second vendor to the RTX 3060 Ti run: Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2).

  • cargo test --workspace --locked -- --test-threads=1: 343 passed, 0 failed, including v_mad_16_and_int16_clamp_match_rdna2 on the AMD device and WARP.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • cargo xtask policy: ok.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7139127002 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7139127002). Originally posted by [shortselow-byte](https://github.com/shortselow-byte) on 2026-11-24T17:23:40Z. --- This PR has no CI run yet, so I ran the CI's checks at head `7dffb2a` (on `main` `ffe310e`) on AMD, to add a second vendor to the RTX 3060 Ti run: Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). - `cargo test --workspace --locked -- --test-threads=1`: 343 passed, 0 failed, including `v_mad_16_and_int16_clamp_match_rdna2` on the AMD device and WARP. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. - `cargo xtask policy`: ok.
Zipettte commented 2026-11-24 18:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:00:00Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 7dffb2a: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140010484 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7140010484). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:00:00Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 7dffb2a: `cargo test -p victory-shader` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Marvisak commented 2026-11-25 02:05:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:18:48Z.


Automated triage for the maintainers.

Merge candidate. Rebased onto current main. The change is the same as the head that was a merge candidate before. In lower.rs (the 16-bit integer path of the VALU lowering), v_mad_u16 and v_mad_i16 now wrap, with sign extension for the i16 form. v_add_nc_u16, v_sub_nc_u16 and v_subrev_nc_u16 saturate when CLAMP is set. On the eight ops where the cited RDNA2 measurement found the clamp bit has no effect, CLAMP is accepted and does nothing. CLAMP on v_mad_* is still refused, since nobody has measured it. I checked the opcode numbers in the test against gfx10/opcodes.rs and the saturation compares (unsigned for add, signed below zero for the zero-extended sub).

CI: passing. Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149419358 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7149419358). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:18:48Z. --- <!-- victory-triage v1 head=5780573f4755676da8d2271cba0ae91dda016882 verdict=merge-candidate at=2026-11-26T05:31:40Z --> Automated triage for the maintainers. **Merge candidate.** Rebased onto current `main`. The change is the same as the head that was a merge candidate before. In `lower.rs` (the 16-bit integer path of the VALU lowering), `v_mad_u16` and `v_mad_i16` now wrap, with sign extension for the i16 form. `v_add_nc_u16`, `v_sub_nc_u16` and `v_subrev_nc_u16` saturate when CLAMP is set. On the eight ops where the cited RDNA2 measurement found the clamp bit has no effect, CLAMP is accepted and does nothing. CLAMP on `v_mad_*` is still refused, since nobody has measured it. I checked the opcode numbers in the test against `gfx10/opcodes.rs` and the saturation compares (unsigned for add, signed below zero for the zero-extended sub). CI: passing. Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
upipibi commented 2026-11-25 04:07:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T03:39:17Z.


A hardware data point for the ops this PR still refuses with CLAMP=1, from reading, not a run here. boykopovar/AnyPS5 measured VOP3 16-bit integer ops with and without the clamp bit on gfx1036 (RDNA2), through their hardware oracle (the §9 entry and #22615):

  • v_add_nc_u16 with clamp saturates. That matches this PR's add / sub arms.
  • The clamp bit has no effect on v_mul_lo_u16, v_lshlrev_b16 / v_lshrrev_b16 / v_ashrrev_i16 and v_min / v_max_{u16,i16}. The result is the wrapped low 16 bits either way.

So those eight could take v.clamp as a no-op instead of returning Err("modifiers on a 16-bit integer operation"). It should not saturate there: xcl-dev/xcl#202 made v_mul_lo_u16 saturate and the same measurement contradicts it. v_mad_u16 / v_mad_i16 with clamp weren't part of that measurement.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152118988 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7152118988). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T03:39:17Z. --- A hardware data point for the ops this PR still refuses with CLAMP=1, from reading, not a run here. boykopovar/AnyPS5 measured VOP3 16-bit integer ops with and without the clamp bit on gfx1036 (RDNA2), through their hardware oracle (the §9 entry and #22615): - `v_add_nc_u16` with clamp saturates. That matches this PR's add / sub arms. - The clamp bit has **no effect** on `v_mul_lo_u16`, `v_lshlrev_b16` / `v_lshrrev_b16` / `v_ashrrev_i16` and `v_min` / `v_max_{u16,i16}`. The result is the wrapped low 16 bits either way. So those eight could take `v.clamp` as a no-op instead of returning `Err("modifiers on a 16-bit integer operation")`. It should not saturate there: xcl-dev/xcl#202 made `v_mul_lo_u16` saturate and the same measurement contradicts it. `v_mad_u16` / `v_mad_i16` with clamp weren't part of that measurement. AI-assisted (Claude Code).
ESAT586 commented 2026-11-25 12:03:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-25T11:23:18Z.


Rebased onto \main\ (\940d32f) at $sha. Thanks @upipibi for the RDNA2 (\gfx1036) hardware data point! Updated \lower.rs\ to accept \CLAMP=1\ as a no-op (wrapped low 16 bits, no saturation) on \ _mul_lo_u16, \ _lshlrev_b16, \ _lshrrev_b16, \ _ashrrev_i16, and \ {min,max}{u16,i16}, and added GPU regression tests for all 8 ops. Verified on RTX 3060 Ti + WARP: \ _mad_16_and_int16_clamp_match_rdna2\ passed, strict Clippy (--all-targets\ and --all-features) clean, \cargo xtask policy\ ok.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160979179 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7160979179). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-25T11:23:18Z. --- Rebased onto \main\ (\940d32f\) at \$sha\. Thanks @upipibi for the RDNA2 (\gfx1036\) hardware data point! Updated \lower.rs\ to accept \CLAMP=1\ as a no-op (wrapped low 16 bits, no saturation) on \ _mul_lo_u16\, \ _lshlrev_b16\, \ _lshrrev_b16\, \ _ashrrev_i16\, and \ _{min,max}_{u16,i16}\, and added GPU regression tests for all 8 ops. Verified on RTX 3060 Ti + WARP: \ _mad_16_and_int16_clamp_match_rdna2\ passed, strict Clippy (\--all-targets\ and \--all-features\) clean, \cargo xtask policy\ ok.
upipibi commented 2026-11-25 12:03:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T11:48:59Z.


@ESAT586 I read 21e43af against the gfx1036 measurement. The eight ops take CLAMP=1 as a no-op and keep the wrapped low 16 bits (clamp_noop in lower.rs, and the no-op cases in the new test), which is what was measured. v_add_nc_u16 and v_sub_nc_u16 saturate, which also matches. v_mad_i16 sign-extends all three sources, and u16::MAX * u16::MAX + u16::MAX fits in 32 bits, so the > 0xFFFF compare is exact.

One open point: v_mad_u16 / v_mad_i16 with clamp. The saturating results that v_mad_16_and_int16_clamp_match_rdna2 checks come from the lowering's model, because the measurement didn't include either op with clamp. v_mul_lo_u16 is a reason to be careful here: the same measurement showed its clamp bit does nothing, even though one could expect it to saturate. Until someone measures the two mad ops with clamp on RDNA2, I'd name or comment the test so it says which half was measured, or keep v_mad_* with clamp refused.

AI-assisted (Claude Code). Read only, nothing run for this.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161536182 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7161536182). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T11:48:59Z. --- @ESAT586 I read `21e43af` against the gfx1036 measurement. The eight ops take `CLAMP=1` as a no-op and keep the wrapped low 16 bits (`clamp_noop` in `lower.rs`, and the no-op cases in the new test), which is what was measured. `v_add_nc_u16` and `v_sub_nc_u16` saturate, which also matches. `v_mad_i16` sign-extends all three sources, and `u16::MAX * u16::MAX + u16::MAX` fits in 32 bits, so the `> 0xFFFF` compare is exact. One open point: `v_mad_u16` / `v_mad_i16` **with** clamp. The saturating results that `v_mad_16_and_int16_clamp_match_rdna2` checks come from the lowering's model, because the measurement didn't include either op with clamp. `v_mul_lo_u16` is a reason to be careful here: the same measurement showed its clamp bit does nothing, even though one could expect it to saturate. Until someone measures the two `mad` ops with clamp on RDNA2, I'd name or comment the test so it says which half was measured, or keep `v_mad_*` with clamp refused. AI-assisted (Claude Code). Read only, nothing run for this.
ESAT586 commented 2026-11-25 13:03:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-25T12:59:27Z.


Updated at $sha\ per triage and @upipibi's note: kept \CLAMP=1\ refused on \ _mad_u16\ / \ _mad_i16\ (added refusal regression check) until hardware-measured on RDNA2, while keeping wrapping \ mad{u16,i16}, saturating \ _{add,sub,subrev}_nc_u16, and the 8 hardware-measured \clamp_noop\ ops. Verified on RTX 3060 Ti + WARP: \ _mad_16_and_int16_clamp_match_rdna2\ passed, strict Clippy (--all-targets\ and --all-features) clean, \cargo xtask policy\ ok.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163135490 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7163135490). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-25T12:59:27Z. --- Updated at \$sha\ per triage and @upipibi's note: kept \CLAMP=1\ refused on \ _mad_u16\ / \ _mad_i16\ (added refusal regression check) until hardware-measured on RDNA2, while keeping wrapping \ _mad_{u16,i16}\, saturating \ _{add,sub,subrev}_nc_u16\, and the 8 hardware-measured \clamp_noop\ ops. Verified on RTX 3060 Ti + WARP: \ _mad_16_and_int16_clamp_match_rdna2\ passed, strict Clippy (\--all-targets\ and \--all-features\) clean, \cargo xtask policy\ ok.
upipibi commented 2026-11-25 14:07:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T13:53:04Z.


@ESAT586 Thanks for keeping the clamp refused there. ed4b40f (as-is, on main 940d32f), RTX 3070 (616.56) plus WARP, Windows 11, debug, cargo test -p victory-shader --locked:

  • v_mad_16_and_int16_clamp_match_rdna2 passes, including the new refusal check for v_mad_u16 / v_mad_i16 with CLAMP=1. It's slow on this machine, though: it ran for more than 60 s, most of the suite's 82 s.
  • The suite gives 245 passed, 3 failed, 3 ignored. The 3 are #1744's NVIDIA failures that main has too (a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, a_heap_buffer_read_by_element_takes_the_views_stride, gathers_at_a_level_match_the_hardware).

One run only.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164429977 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#issuecomment-7164429977). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T13:53:04Z. --- @ESAT586 Thanks for keeping the clamp refused there. `ed4b40f` (as-is, on `main` `940d32f`), RTX 3070 (616.56) plus WARP, Windows 11, debug, `cargo test -p victory-shader --locked`: - `v_mad_16_and_int16_clamp_match_rdna2` passes, including the new refusal check for `v_mad_u16` / `v_mad_i16` with `CLAMP=1`. It's slow on this machine, though: it ran for more than 60 s, most of the suite's 82 s. - The suite gives 245 passed, 3 failed, 3 ignored. The 3 are #1744's NVIDIA failures that `main` has too (`a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `a_heap_buffer_read_by_element_takes_the_views_stride`, `gathers_at_a_level_match_the_hardware`). One run only. AI-assisted (Claude Code). Synthetic tests only.
fuzeofficlal commented 2026-11-26 13:54:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T13:54:59Z.

Review: APPROVED


Reviewed and verified 5780573f4755 merged locally onto origin/main (63bcca43) on Windows 11 x64 (RTX 5090 and VICTORY_WARP=1, Rust 1.98.1 MSVC, Windows SDK 10.0.26100.0 dxil.dll).

  • The unclamped v_mad_u16 / v_mad_i16 paths (emit/lower.rs:6937-6955, 7144-7166) have exact 32-bit intermediate precision without overflow (65535^2 + 65535 <= u32::MAX, signed range within i32), v_add_nc_u16 / v_sub_nc_u16 saturate overflow/underflow cleanly, clamped MAD stays explicitly refused, and the 8 clamp_noop ops align with the gfx1036 hardware data point cited above.
  • emit/lower.rs after merging onto origin/main is 522,266 B (+1,703 B, 2,022 B under the 512 KiB cap).
  • Minor non-blocking cleanup notes: v_subrev_nc_u16 (lower.rs:6940, 7107, 7158) currently has no entry in gfx10/opcodes.rs:714-735; rustfmt --edition 2024 --check flags 3 new lines in valu_tests.rs:2332, 2357, 2368; and a mixed non-zero OPSEL MAD test writing the upper destination half while checking a low-half sentinel would cover the remaining half-selection path.

Local verification: git merge-tree onto 63bcca43 clean, cargo run --locked -p xtask -- policy (191 files ok), cargo clippy -p victory-shader --all-targets (default and --all-features, 0 warnings), emit::lower::tests (33 passed), and emit::valu_tests (36 passed, 0 failed) with dxil.dll validation all pass on both RTX 5090 and VICTORY_WARP=1. Looks good to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075325630 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#pullrequestreview-6075325630). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T13:54:59Z. **Review:** APPROVED --- Reviewed and verified `5780573f4755` merged locally onto `origin/main` (`63bcca43`) on Windows 11 x64 (RTX 5090 and `VICTORY_WARP=1`, Rust `1.98.1` MSVC, Windows SDK `10.0.26100.0` `dxil.dll`). - The unclamped `v_mad_u16` / `v_mad_i16` paths (`emit/lower.rs:6937-6955, 7144-7166`) have exact 32-bit intermediate precision without overflow (`65535^2 + 65535 <= u32::MAX`, signed range within `i32`), `v_add_nc_u16` / `v_sub_nc_u16` saturate overflow/underflow cleanly, clamped MAD stays explicitly refused, and the 8 `clamp_noop` ops align with the `gfx1036` hardware data point cited above. - `emit/lower.rs` after merging onto `origin/main` is **`522,266 B`** (+1,703 B, **2,022 B** under the 512 KiB cap). - Minor non-blocking cleanup notes: `v_subrev_nc_u16` (`lower.rs:6940, 7107, 7158`) currently has no entry in `gfx10/opcodes.rs:714-735`; `rustfmt --edition 2024 --check` flags 3 new lines in `valu_tests.rs:2332, 2357, 2368`; and a mixed non-zero `OPSEL` MAD test writing the upper destination half while checking a low-half sentinel would cover the remaining half-selection path. Local verification: `git merge-tree` onto `63bcca43` clean, `cargo run --locked -p xtask -- policy` (191 files ok), `cargo clippy -p victory-shader --all-targets` (`default` and `--all-features`, 0 warnings), `emit::lower::tests` (33 passed), and `emit::valu_tests` (36 passed, 0 failed) with `dxil.dll` validation all pass on both RTX 5090 and `VICTORY_WARP=1`. Looks good to merge.
Dukestar69 commented 2026-11-26 19:32:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T19:32:37Z.

Review: APPROVED


LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).

  • Lowering v_mad_u16 / v_mad_i16, handling unsigned 16-bit saturating clamp on v_add_nc_u16 / v_sub_nc_u16 / v_subrev_nc_u16, and treating no-op CLAMP on the remaining 8 16-bit integer ops (while safely rejecting unhandled v_mad_{u16,i16} clamp) is clean and matches RDNA2 semantics.
  • cargo test -p victory-shader --lib emit::valu_tests::v_mad_16_and_int16_clamp_match_rdna2 -- --test-threads=1: passed on RTX 5090 and VICTORY_WARP=1.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6079577077 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1211#pullrequestreview-6079577077). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T19:32:37Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 and `VICTORY_WARP=1` (Windows / D3D12) against `origin/main` (`63bcca4`). - Lowering `v_mad_u16` / `v_mad_i16`, handling unsigned 16-bit saturating clamp on `v_add_nc_u16` / `v_sub_nc_u16` / `v_subrev_nc_u16`, and treating no-op `CLAMP` on the remaining 8 16-bit integer ops (while safely rejecting unhandled `v_mad_{u16,i16}` clamp) is clean and matches RDNA2 semantics. - `cargo test -p victory-shader --lib emit::valu_tests::v_mad_16_and_int16_clamp_match_rdna2 -- --test-threads=1`: passed on RTX 5090 and `VICTORY_WARP=1`. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1211:upstream-pr/1211'
git switch 'upstream-pr/1211'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1211'
git switch 'upstream-pr/1211'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1211'
git switch 'upstream-pr/1211'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1211'
git switch 'main'
git merge --squash 'upstream-pr/1211'
git switch 'main'
git merge --ff-only 'upstream-pr/1211'
git switch 'main'
git merge 'upstream-pr/1211'
git push origin 'main'
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!1211
No description provided.