Shaders: lower v_{min3,max3,med3}_{i16,u16} and v_mad_{u32_u16,i32_i16} #1300

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

@⁠ESAT586 on GitHub · 2026-11-24 17:16 UTC · original
ESAT586:shader/valu16-min3-max3-med3-mad32 → main · +300 −0 · 3 files · 1 commits · open

AI Transparency Notice: This PR was authored, implemented, and hardware-tested by Gemini 4 Neon (High Mode) (an AI coding agent, not a human engineer), using zero game files or proprietary console SDK data.

Summary

Lowers 8 missing 16-bit integer VALU instructions in victory-shader:

  • 16-bit 3-source min/max/median (valu16/valu16_op):
    • v_min3_i16 (0x352), v_min3_u16 (0x353)
    • v_max3_i16 (0x355), v_max3_u16 (0x356)
    • v_med3_i16 (0x358), v_med3_u16 (0x359)
    • Honors op_sel[0..2] on all three 16-bit sources and op_sel[3] on the destination, preserving the untouched half of vdst.
  • Widening 16×16 + 32 → 32-bit multiply-add (valu_op):
    • v_mad_u32_u16 (0x373)
    • v_mad_i32_i16 (0x375)
    • Honors op_sel[0..1] for the 16-bit multiplicands, reads full 32-bit src2, and supports both wrapping and exact 32-bit signed/unsigned saturating clamp using pure 32-bit DXIL (no INT64 required).

Verification

Tested locally on Windows 11 with NVIDIA GeForce RTX 3060 Ti (Driver 32.0.16.1656) + Microsoft WARP + dxil.dll validator, Rust 1.98.1 MSVC:

  • cargo clippy --workspace --all-targets --locked -- -D warnings — 0 warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — 0 warnings
  • cargo test -p victory-shader --locked — 121 passed, 0 failed, 1 ignored (including valu16_min3_max3_med3_and_mad32_16_match_rdna2 verifying all 8 opcodes, high-half op_sel, untouched-half preservation, wrapping, and saturating clamp on RTX 3060 Ti and WARP)
  • cargo xtask policy — 154 files ok
**@⁠ESAT586** on GitHub · 2026-11-24 17:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300) `ESAT586:shader/valu16-min3-max3-med3-mad32` → `main` · +300 −0 · 3 files · 1 commits · open > **AI Transparency Notice:** This PR was authored, implemented, and hardware-tested by **Gemini 4 Neon (High Mode)** (an AI coding agent, not a human engineer), using **zero game files or proprietary console SDK data**. ## Summary Lowers 8 missing 16-bit integer VALU instructions in `victory-shader`: - **16-bit 3-source min/max/median (`valu16`/`valu16_op`):** - `v_min3_i16` (`0x352`), `v_min3_u16` (`0x353`) - `v_max3_i16` (`0x355`), `v_max3_u16` (`0x356`) - `v_med3_i16` (`0x358`), `v_med3_u16` (`0x359`) - Honors `op_sel[0..2]` on all three 16-bit sources and `op_sel[3]` on the destination, preserving the untouched half of `vdst`. - **Widening 16×16 + 32 → 32-bit multiply-add (`valu_op`):** - `v_mad_u32_u16` (`0x373`) - `v_mad_i32_i16` (`0x375`) - Honors `op_sel[0..1]` for the 16-bit multiplicands, reads full 32-bit `src2`, and supports both wrapping and exact 32-bit signed/unsigned saturating `clamp` using pure 32-bit DXIL (no `INT64` required). ## Verification Tested locally on Windows 11 with **NVIDIA GeForce RTX 3060 Ti** (`Driver 32.0.16.1656`) + **Microsoft WARP** + `dxil.dll` validator, Rust `1.98.1` MSVC: - `cargo clippy --workspace --all-targets --locked -- -D warnings` — **0 warnings** - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` — **0 warnings** - `cargo test -p victory-shader --locked` — **121 passed, 0 failed, 1 ignored** (including `valu16_min3_max3_med3_and_mad32_16_match_rdna2` verifying all 8 opcodes, high-half `op_sel`, untouched-half preservation, wrapping, and saturating `clamp` on RTX 3060 Ti and WARP) - `cargo xtask policy` — **154 files ok**
AI-authored and verified by Gemini 4 Neon (High Mode) — zero game data used.

- Lowers the 6 16-bit 3-source integer comparison ops (`v_min3_i16`,
  `v_min3_u16`, `v_max3_i16`, `v_max3_u16`, `v_med3_i16`, `v_med3_u16`) in
  `valu16`/`valu16_op`, honoring `op_sel[0..2]` for inputs and `op_sel[3]`
  for destination half preservation.
- Lowers the widening 16x16 + 32 -> 32-bit multiply-add ops (`v_mad_u32_u16`
  and `v_mad_i32_i16`), honoring `op_sel[0..1]` for the 16-bit multiplicands
  and exact 32-bit signed/unsigned saturating `clamp` without requiring `INT64`.
- Adds `valu16_min3_max3_med3_and_mad32_16_match_rdna2` testing all 8 opcodes
  (including high-half `op_sel`, untouched-half preservation, wrapping, and
  saturating `clamp`) on hardware D3D12 and WARP.
Authored and verified by Gemini 4 Neon (High Mode, AI coding agent) with
zero game data.

Addresses review feedback on #1300:
1. `v_mad_{u32_u16,i32_i16}` and `v_{min3,max3,med3}_{i16,u16}` have
   16-bit integer operands (`OPERAND_REG_INLINE_C_INT16`), where GFX10
   decodes inline float constants (`240..=248`) as 32-bit `f32` bit
   patterns before selecting the low/high half via `op_sel` (not `f16`).
   Switch those source reads from `half_src` to
   `packed_src(inst, k, false, false)`.
2. Return `"integer operand modifiers"` for `v.abs != 0 || v.neg != 0`
   on `v_mad_{u32_u16,i32_i16}` (keeping `"integer output modifiers"`
   for `v.omod != 0`).
3. Extend `valu16_min3_max3_med3_and_mad32_16_match_rdna2` with GPU/WARP
   tests for inline float constant `242` (`1.0f = 0x3F80_0000`) across
   `op_sel=0` and `op_sel=1` on both `v_mad_u32_u16` and `v_max3_u16`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:52 +00:00
github-bot force-pushed github-bot/gh-1300 from 4726c19952 to 1879aace7b 2026-11-26 06:30:34 +00:00 Compare
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 17:22 UTC · original

Reviewed at head 79a7a60 (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked:

1. The lowering is semantically correct — model-checked exhaustively, then hardware-tested. Opcodes check out against the GFX10 table (gfx10/opcodes.rs: 0x352 v_min3_i16 … 0x359 v_med3_u16, 0x373 v_mad_u32_u16, 0x375 v_mad_i32_i16). The 16-bit min3/max3/med3 arm sign-extends all three sources for _i16 (so SGT/SLT on the extended values is exactly 16-bit signed compare; zero-extended IUGT/IULT is exactly unsigned), and the med3 chain max(min(a,b), min(max(a,b), c)) is the ISA median — I checked the chain against a direct median over all sign/boundary combos (0x0000/0x0001/0x5/0x7FFF/0x8000/0xFFFE/0xFFFF triples, both signednesses): 0 mismatches. No -0-style subtlety exists for integers, so the f32/f16 med3 fix from #1259 does not interact here.

2. v_mad_u32_u16 / v_mad_i32_i16 clamp logic verified. I modeled the emitted ops against the wrapping-arithmetic-plus-saturation reference over 306,480 combinations (all boundary 16-bit values × boundary accumulators, near-exhaustive small grid, 300k random with random clamp): 0 mismatches. Unsigned overflow detection sum <u acc is exact because the product of two u16 is non-negative and fits in u32; the signed path's (prod^acc >= 0) & (prod^sum < 0) with saturation to the sign of prod is the standard correct test — including prod == 0 (no false overflow). omod/abs/neg are refused, clamp handled, opsel half-selection goes through the existing half_src/dst-half machinery.

3. Hardware evidence on this machine. cargo test -p victory-shader --lib valu16 runs valu16_min3_max3_med3_and_mad32_16_match_rdna2 on the GPU: 1 passed / 0 failed. The test pins both signednesses of min3/max3/med3, a hi-dst opsel case with a 0xCAFE_BEEF-seeded destination (half preservation), and mad u32/i32 in wrapping + clamped + opsel forms, including all three overflow directions (u32 wrap → u32::MAX, i32 positive overflow → i32::MAX, negative overflow → i32::MIN). Full cargo test -p victory-shader --lib: 121 passed / 0 failed / 1 ignored.

4. Checks: cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings clean; cargo build --release -p victory builds.

5. One nit, not blocking (CI has no fmt job): the PR adds 4 new rustfmt diffs of its own — lower.rs:3951 (the (imin, imax) tuple fits on one line per rustfmt) and three in the new test code in valu_tests.rs (main's copy of that file is fmt-clean). The other 3 lower.rs hunks are pre-existing on main (7099/7118/7137, shifted by the additions). Worth a rustfmt pass on the touched lines before merge.

Nothing else found; the new opcodes previously fell through to a refusal, so this strictly widens what translates.

**@⁠adamdotpy** on GitHub · 2026-11-24 17:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7139091720) Reviewed at head `79a7a60` (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked: **1. The lowering is semantically correct — model-checked exhaustively, then hardware-tested.** Opcodes check out against the GFX10 table (`gfx10/opcodes.rs`: `0x352` v_min3_i16 … `0x359` v_med3_u16, `0x373` v_mad_u32_u16, `0x375` v_mad_i32_i16). The 16-bit min3/max3/med3 arm sign-extends all three sources for `_i16` (so `SGT`/`SLT` on the extended values is exactly 16-bit signed compare; zero-extended `IUGT`/`IULT` is exactly unsigned), and the med3 chain `max(min(a,b), min(max(a,b), c))` is the ISA median — I checked the chain against a direct median over all sign/boundary combos (0x0000/0x0001/0x5/0x7FFF/0x8000/0xFFFE/0xFFFF triples, both signednesses): 0 mismatches. No -0-style subtlety exists for integers, so the f32/f16 med3 fix from #1259 does not interact here. **2. `v_mad_u32_u16` / `v_mad_i32_i16` clamp logic verified.** I modeled the emitted ops against the wrapping-arithmetic-plus-saturation reference over 306,480 combinations (all boundary 16-bit values × boundary accumulators, near-exhaustive small grid, 300k random with random clamp): 0 mismatches. Unsigned overflow detection `sum <u acc` is exact because the product of two u16 is non-negative and fits in u32; the signed path's `(prod^acc >= 0) & (prod^sum < 0)` with saturation to the sign of `prod` is the standard correct test — including `prod == 0` (no false overflow). `omod`/`abs`/`neg` are refused, `clamp` handled, opsel half-selection goes through the existing `half_src`/dst-half machinery. **3. Hardware evidence on this machine.** `cargo test -p victory-shader --lib valu16` runs `valu16_min3_max3_med3_and_mad32_16_match_rdna2` on the GPU: 1 passed / 0 failed. The test pins both signednesses of min3/max3/med3, a hi-dst opsel case with a `0xCAFE_BEEF`-seeded destination (half preservation), and mad u32/i32 in wrapping + clamped + opsel forms, including all three overflow directions (u32 wrap → `u32::MAX`, i32 positive overflow → `i32::MAX`, negative overflow → `i32::MIN`). Full `cargo test -p victory-shader --lib`: 121 passed / 0 failed / 1 ignored. **4. Checks:** `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` clean; `cargo build --release -p victory` builds. **5. One nit, not blocking (CI has no fmt job):** the PR adds 4 new rustfmt diffs of its own — `lower.rs:3951` (the `(imin, imax)` tuple fits on one line per rustfmt) and three in the new test code in `valu_tests.rs` (main's copy of that file is fmt-clean). The other 3 `lower.rs` hunks are pre-existing on `main` (`7099/7118/7137`, shifted by the additions). Worth a `rustfmt` pass on the touched lines before merge. Nothing else found; the new opcodes previously fell through to a refusal, so this strictly widens what translates.
Author
Owner

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

Independent verification of \79a7a60\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-shader --lib valu_tests\ (real RX 9060 XT GPU execution): 14 passed, 0 failed (including \ alu16_min3_max3_med3_and_mad32_16_match_rdna2)
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

Code audit looks solid: \ _mad_u32_u16\ / \ _mad_i32_i16\ products never overflow 32 bits (\65535^2 <= u32::MAX\ and -32768)^2 = 2^30 <= i32::MAX, so checking overflow on \prod + acc\ alone is exact for both unsigned and signed clamp paths; \ {min3,max3,med3}{i16,u16}\ properly uses \half_src(inst, 2)\ with sign extension for _i16. (Minor merge note: #1295 changes \half_src\ arity if both land.)

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7139148603) Independent verification of \79a7a60\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200\) / Rust 1.98.1 MSVC**: - Merge check vs \main\ (\ fe310e\): clean - \cargo test -p victory-shader --lib valu_tests\ (real RX 9060 XT GPU execution): **14 passed, 0 failed** (including \ alu16_min3_max3_med3_and_mad32_16_match_rdna2\) - \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 154 files ok Code audit looks solid: \ _mad_u32_u16\ / \ _mad_i32_i16\ products never overflow 32 bits (\65535^2 <= u32::MAX\ and \(-32768)^2 = 2^30 <= i32::MAX\), so checking overflow on \prod + acc\ alone is exact for both unsigned and signed clamp paths; \ _{min3,max3,med3}_{i16,u16}\ properly uses \half_src(inst, 2)\ with sign extension for \_i16\. (Minor merge note: #1295 changes \half_src\ arity if both land.) *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 17:54 UTC · original

Reviewed 3c01f0e and verified v_mad_u32_u16 / v_mad_i32_i16 on NVIDIA GeForce RTX 5090, AMD Radeon(TM) Graphics, D3D12 WARP, and dxil.dll. Two bugs worth fixing:

  1. Inline float constants (240..=248) on 16-bit integer ops use 32-bit f32 bit patterns on GFX10, not f16 (emit/lower.rs:3932, 4708):
    • Both v_mad_{u32_u16,i32_i16} and v_{min3,max3,med3}_{i16,u16} have OPERAND_REG_INLINE_C_INT16 operands in AMDGPU's decoder (AMDGPUDisassembler.cpp: only FP16/BF16 operands decode 242 as 0x3C00; INT16 operands decode 242 (1.0) as 0x3F80_0000, selecting 0x0000 for op_sel=0 and 0x3F80 for op_sel=1).
    • Calling self.half_src(inst, k) routes through f16_operand, turning 1.0 with op_sel=0 into 0x3C00 (15360) instead of 0x0000 (and op_sel=1 into 0x0000 instead of 0x3F80). Using self.packed_src(inst, k, false, false)? (which reads self.operand before selecting the halfword) matches hardware.
  2. Modifier error reason (emit/lower.rs:3926):
    • v.abs != 0 || v.neg != 0 should return "integer operand modifiers" rather than "integer output modifiers" to match the rest of lower.rs.

Verified reference tests (including inline float constants 242/243 across op_sel and signed/unsigned clamp saturation): fuzeofficlal/VIctory@dec3499.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7139875198) Reviewed `3c01f0e` and verified `v_mad_u32_u16` / `v_mad_i32_i16` on **NVIDIA GeForce RTX 5090**, **AMD Radeon(TM) Graphics**, **D3D12 WARP**, and **`dxil.dll`**. Two bugs worth fixing: 1. **Inline float constants (`240..=248`) on 16-bit integer ops use 32-bit `f32` bit patterns on GFX10, not `f16` (`emit/lower.rs:3932, 4708`)**: - Both `v_mad_{u32_u16,i32_i16}` and `v_{min3,max3,med3}_{i16,u16}` have `OPERAND_REG_INLINE_C_INT16` operands in AMDGPU's decoder (`AMDGPUDisassembler.cpp`: only `FP16`/`BF16` operands decode `242` as `0x3C00`; `INT16` operands decode `242` (`1.0`) as `0x3F80_0000`, selecting `0x0000` for `op_sel=0` and `0x3F80` for `op_sel=1`). - Calling `self.half_src(inst, k)` routes through `f16_operand`, turning `1.0` with `op_sel=0` into `0x3C00` (`15360`) instead of `0x0000` (and `op_sel=1` into `0x0000` instead of `0x3F80`). Using `self.packed_src(inst, k, false, false)?` (which reads `self.operand` before selecting the halfword) matches hardware. 2. **Modifier error reason (`emit/lower.rs:3926`)**: - `v.abs != 0 || v.neg != 0` should return `"integer operand modifiers"` rather than `"integer output modifiers"` to match the rest of `lower.rs`. Verified reference tests (including inline float constants `242`/`243` across `op_sel` and signed/unsigned `clamp` saturation): [`fuzeofficlal/VIctory@dec3499`](https://github.com/fuzeofficlal/VIctory/commit/dec3499b75018b72a8b3553bca5183442630d37f).
Author
Owner

@⁠ESAT586 on GitHub · 2026-11-24 18:44 UTC · original

Great catch, @⁠fuzeofficlal — thank you for checking the OPERAND_REG_INLINE_C_INT16 decoding against hardware!

Fixed both items on this branch:

  1. Switched v_mad_{u32_u16,i32_i16} and v_{min3,max3,med3}_{i16,u16} to read their 16-bit integer operands through self.packed_src(inst, k, false, false)? so inline float constants (240..=248) decode as 32-bit f32 bit patterns before op_sel half selection.
  2. Split v_mad_{u32_u16,i32_i16} modifier checks so v.abs != 0 || v.neg != 0 returns "integer operand modifiers" and v.omod != 0 returns "integer output modifiers".
  3. Added GPU/WARP tests in valu16_min3_max3_med3_and_mad32_16_match_rdna2 for inline float constant 242 (1.0f = 0x3F80_0000) with op_sel=0 (0x0000) and op_sel=1 (0x3F80) on both v_mad_u32_u16 and v_max3_u16.

Re-verified on NVIDIA GeForce RTX 3060 Ti, WARP, and dxil.dll (clippy -D warnings, --all-features, xtask policy all green).

(Authored and verified by Gemini 4 Neon — High Mode; synthetic tests only, zero game data.)

**@⁠ESAT586** on GitHub · 2026-11-24 18:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7141075714) Great catch, @⁠fuzeofficlal — thank you for checking the `OPERAND_REG_INLINE_C_INT16` decoding against hardware! Fixed both items on this branch: 1. Switched `v_mad_{u32_u16,i32_i16}` and `v_{min3,max3,med3}_{i16,u16}` to read their 16-bit integer operands through `self.packed_src(inst, k, false, false)?` so inline float constants (`240..=248`) decode as 32-bit `f32` bit patterns before `op_sel` half selection. 2. Split `v_mad_{u32_u16,i32_i16}` modifier checks so `v.abs != 0 || v.neg != 0` returns `"integer operand modifiers"` and `v.omod != 0` returns `"integer output modifiers"`. 3. Added GPU/WARP tests in `valu16_min3_max3_med3_and_mad32_16_match_rdna2` for inline float constant `242` (`1.0f = 0x3F80_0000`) with `op_sel=0` (`0x0000`) and `op_sel=1` (`0x3F80`) on both `v_mad_u32_u16` and `v_max3_u16`. Re-verified on **NVIDIA GeForce RTX 3060 Ti**, **WARP**, and **`dxil.dll`** (`clippy -D warnings`, `--all-features`, `xtask policy` all green). *(Authored and verified by Gemini 4 Neon — High Mode; synthetic tests only, zero game data.)*
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 19:04 UTC · original

Verified the new head 7383f54 here (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). The two follow-ups both land: (1) the new 16-bit int ops now read inline float constants as f32 bit patterns via packed_src(..., false, false) + opsel half-select — consistent with the rule in #1295/#1285 (note: those PRs route the same decode through half_int_src; the behaviors agree, but the second PR to merge will conflict on these arms); (2) the rustfmt pass cleared the hunks I flagged. The abs/neg refusal is now split into a separate "integer operand modifiers" message, fine. Ran here: valu16 GPU test passes, full cargo test -p victory-shader --lib 121 passed / 0 failed / 1 ignored, clippy clean, release build ok. One cosmetic leftover: rustfmt --check still wants to split the one-line (imin, imax) tuple at lower.rs:3959 (it exceeds the width) — one hunk, CI has no fmt job.

**@⁠adamdotpy** on GitHub · 2026-11-24 19:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7141566177) Verified the new head `7383f54` here (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). The two follow-ups both land: (1) the new 16-bit int ops now read inline float constants as f32 bit patterns via `packed_src(..., false, false)` + opsel half-select — consistent with the rule in #1295/#1285 (note: those PRs route the same decode through `half_int_src`; the behaviors agree, but the second PR to merge will conflict on these arms); (2) the rustfmt pass cleared the hunks I flagged. The `abs`/`neg` refusal is now split into a separate "integer operand modifiers" message, fine. Ran here: `valu16` GPU test passes, full `cargo test -p victory-shader --lib` 121 passed / 0 failed / 1 ignored, clippy clean, release build ok. One cosmetic leftover: `rustfmt --check` still wants to split the one-line `(imin, imax)` tuple at `lower.rs:3959` (it exceeds the width) — one hunk, CI has no fmt job.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:21 UTC · original · edited 2026-11-26 05:42 UTC

Automated triage for the maintainers.

Verdict: merge candidate. This is now rebased and merges cleanly. It lowers v_{min3,max3,med3}_{i16,u16} and v_mad_{u32_u16,i32_i16} in a new emit/lower/valu16.rs. Before this, those opcodes (gfx10/opcodes.rs 0x352-0x359, 0x373, 0x375) had no lowering on main, so shaders using them were refused. I checked the following:

  • _i16 sign-extends before signed compares.
  • The med3 chain is a correct median.
  • The clamped mad detects overflow correctly in both the unsigned (sum <u acc) and signed (sign-flip) paths. A 16x16 product always fits in 32 bits, so the check only has to cover the add.
  • Sources go through packed_src(.., false, false), so inline float constants decode as 32-bit patterns before the op_sel half is selected. That follows the review above.

The GPU test valu16_min3_max3_med3_and_mad32_16_match_rdna2 covers both signednesses, opsel, the three overflow directions and inline constants.

To note: #1295/#1285 route the same operand decode through half_int_src, so whichever lands second will need a small conflict fix on these arms.

CI: passing (check). Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7149469927) · edited 2026-11-26 05:42 UTC <!-- victory-triage v1 head=1879aace7bc4a3208cc3e1a3d5e674cfab4c1a22 verdict=merge-candidate at=2026-11-26T05:42:28Z --> Automated triage for the maintainers. **Verdict: merge candidate.** This is now rebased and merges cleanly. It lowers `v_{min3,max3,med3}_{i16,u16}` and `v_mad_{u32_u16,i32_i16}` in a new `emit/lower/valu16.rs`. Before this, those opcodes (`gfx10/opcodes.rs` 0x352-0x359, 0x373, 0x375) had no lowering on `main`, so shaders using them were refused. I checked the following: - `_i16` sign-extends before signed compares. - The med3 chain is a correct median. - The clamped mad detects overflow correctly in both the unsigned (`sum <u acc`) and signed (sign-flip) paths. A 16x16 product always fits in 32 bits, so the check only has to cover the add. - Sources go through `packed_src(.., false, false)`, so inline float constants decode as 32-bit patterns before the op_sel half is selected. That follows the review above. The GPU test `valu16_min3_max3_med3_and_mad32_16_match_rdna2` covers both signednesses, opsel, the three overflow directions and inline constants. To note: #1295/#1285 route the same operand decode through `half_int_src`, so whichever lands second will need a small conflict fix on these arms. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠ESAT586 on GitHub · 2026-11-25 11:18 UTC · original

Rebased onto \main\ (\940d32f) at $sha. Verified on RTX 3060 Ti + WARP: \ alu16_min3_max3_med3_and_mad32_16_match_rdna2\ passed, strict Clippy (--all-targets\ and --all-features) clean, \cargo xtask policy\ ok.

**@⁠ESAT586** on GitHub · 2026-11-25 11:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1300#issuecomment-7160876121) Rebased onto \main\ (\940d32f\) at \$sha\. Verified on RTX 3060 Ti + WARP: \ alu16_min3_max3_med3_and_mad32_16_match_rdna2\ passed, strict Clippy (\--all-targets\ and \--all-features\) clean, \cargo xtask policy\ ok.
This pull request can be merged automatically.
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/1300/head:github-bot/gh-1300'
git switch 'github-bot/gh-1300'

Merge

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