Shaders: lower v_mad_u32_u16, v_mad_i32_i16, and v_lerp_u8 #1687

Open
Calvix2k wants to merge 2 commits from upstream-pr/1688 into main
Calvix2k commented 2026-11-24 20:46:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T20:46:10Z.


Implements #1068.

Ports the verified branch from @kilvynsilveira-tech's fork (commit 5319a34 by Kilvy Nog), applied unchanged onto ffe310e; the commit keeps its original author.

Summary

Lower::integer refused three RDNA2 integer VALU instructions:

  • v_mad_u32_u16 and v_mad_i32_i16 (16x16 → 32 multiply-add), including opsel low/high 16-bit selection for src0 and src1.
  • v_lerp_u8: the packed 4x8-bit rounded average, (a[i] + b[i] + (c[i] & 1)) >> 1, with src2 supplying the rounding bits.

Synthetic unit test mad_32_16_and_lerp_u8_lower_and_validate covers all three, including the opsel high halves, and validates the emitted DXIL with dxil.dll.

Validation

  • cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests — passed (103 tests, 1 ignored).
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings — passed.
  • cargo xtask policy — passed (154 files).
  • The new test itself was run by the author with dxil.dll validation: passed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6591072361 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T20:46:10Z. --- Implements #1068. Ports the verified branch from [@kilvynsilveira-tech's fork](https://github.com/kilvynsilveira-tech/VIctory/tree/shader/lerp-and-mad16-u32) (commit 5319a34 by Kilvy Nog), applied unchanged onto `ffe310e`; the commit keeps its original author. ## Summary `Lower::integer` refused three RDNA2 integer VALU instructions: - `v_mad_u32_u16` and `v_mad_i32_i16` (16x16 → 32 multiply-add), including `opsel` low/high 16-bit selection for `src0` and `src1`. - `v_lerp_u8`: the packed 4x8-bit rounded average, `(a[i] + b[i] + (c[i] & 1)) >> 1`, with `src2` supplying the rounding bits. Synthetic unit test `mad_32_16_and_lerp_u8_lower_and_validate` covers all three, including the `opsel` high halves, and validates the emitted DXIL with `dxil.dll`. ## Validation - `cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests` — passed (103 tests, 1 ignored). - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` — passed. - `cargo xtask policy` — passed (154 files). - The new test itself was run by the author with `dxil.dll` validation: passed.
catminou4 commented 2026-11-24 22:01:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:07Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

v_mad_u32_u16/v_mad_i32_i16/v_lerp_u8 lowered; mad_32_16_and_lerp_u8_lower_and_validate checks the DXIL container hash against the reference.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047848695 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#pullrequestreview-6047848695). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:40:07Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests. v_mad_u32_u16/v_mad_i32_i16/v_lerp_u8 lowered; mad_32_16_and_lerp_u8_lower_and_validate checks the DXIL container hash against the reference.
Calvix2k commented 2026-11-24 23:05:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T22:15:47Z.


Rebased onto 70564ae; only the test module conflicted (upstream added the packed-half parameter test). Both tests are kept. mad_32_16_and_lerp_u8_lower_and_validate passes and cargo check -p victory-shader --tests is clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146010689 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7146010689). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T22:15:47Z. --- Rebased onto 70564ae; only the test module conflicted (upstream added the packed-half parameter test). Both tests are kept. mad_32_16_and_lerp_u8_lower_and_validate passes and cargo check -p victory-shader --tests is clean.
upipibi commented 2026-11-24 23:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:52:01Z.


NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, c7242f1 (on main 70564ae). mad_32_16_and_lerp_u8_lower_and_validate passes on the hardware adapter.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146736104 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7146736104). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:52:01Z. --- NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `c7242f1` (on `main` `70564ae`). `mad_32_16_and_lerp_u8_lower_and_validate` passes on the hardware adapter. AI-assisted (Claude Code). Synthetic tests only.
Marvisak commented 2026-11-25 04:06:57 +00:00 (Migrated from github.com)

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


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/lower.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:7152032439 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7152032439). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:33:56Z. --- <!-- victory-triage v1 head=37be9623705c7c4dfec9d2330ef703888384a005 verdict=needs-rebase at=2026-11-25T22:28: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/lower.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)_
StExpeditus commented 2026-11-25 05:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T04:23:46Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 37be962. cargo test --workspace --locked --no-fail-fast -> all green: 0 passed, 0 ignored, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152803682 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7152803682). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T04:23:46Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `37be962`. `cargo test --workspace --locked --no-fail-fast` -> **all green**: 0 passed, 0 ignored, 0 failed.
StExpeditus commented 2026-11-25 09:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:04:43Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 37be962. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157844646 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7157844646). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:04:43Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `37be962`. `cargo test --workspace --locked --no-fail-fast` -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
Calvix2k commented 2026-11-25 17:05:09 +00:00 (Migrated from github.com)

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


Thanks — the same five NVIDIA heap-cap failures as on main, and nothing from this PR. Noted on the record.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168325247 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7168325247). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T16:39:17Z. --- Thanks — the same five NVIDIA heap-cap failures as on `main`, and nothing from this PR. Noted on the record.
Calvix2k commented 2026-11-26 14:01:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-26T13:53:18Z.


Rebased. Dropped our duplicate validate helper (upstream added the same one in the same place) and kept upstream's ds_bpermute test plus ours.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193975355 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1688#issuecomment-7193975355). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-26T13:53:18Z. --- Rebased. Dropped our duplicate `validate` helper (upstream added the same one in the same place) and kept upstream's `ds_bpermute` test plus ours.
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/1688:upstream-pr/1688'
git switch 'upstream-pr/1688'

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