Skip to content

Shaders: lower v_mad_u32_u16, v_mad_i32_i16, and v_lerp_u8 - #1688

Open
Calvix2k wants to merge 2 commits into
Marvisak:mainfrom
Calvix2k:codex/shader-mad16-lerp-1068
Open

Calvix2k wants to merge 2 commits into
Marvisak:mainfrom
Calvix2k:codex/shader-mad16-lerp-1068

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

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.

@Calvix2k
Calvix2k force-pushed the codex/shader-mad16-lerp-1068 branch from 65ae507 to c7242f1 Compare November 24, 2026 22:15
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

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 Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@StExpeditus

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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

@Calvix2k
Calvix2k force-pushed the codex/shader-mad16-lerp-1068 branch from 37be962 to 8c6ff38 Compare November 26, 2026 13:52
@Calvix2k

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants