shader: lower v_mul_hi_i32_i24 and v_mul_hi_u32_u24 without INT64 #1646

Closed
geiyiliyabumo wants to merge 1 commit from upstream-pr/1647 into main
geiyiliyabumo commented 2026-11-24 20:23:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T20:23:28Z.


Summary

  • Lowers RDNA2 v_mul_hi_i32_i24 (VOP2 0x00a / VOP3 0x10a) and v_mul_hi_u32_u24 (VOP2 0x00c / VOP3 0x10c) in crates/victory-shader/src/emit/lower.rs (mul_hi_24).
  • Matches AMD RDNA 2 ISA §12.7 (p. 132): ignores input bits [31:24], computes the exact 48-bit signed or unsigned product of bits [23:0], and returns (product >> 32) (bits [47:32], sign- or zero-extended to 32 bits).
  • Uses 16-bit + 8-bit partial products in pure i32 DXIL arithmetic so shaders using these instructions do not require the INT64 DXIL capability flag (SFI0 & 0x8000 == 0).

Verification

  • cargo test -p victory-shader --lib valu_tests: 14/14 PASS on both AMD Radeon RX 9060 XT (D3D12 hardware) and Microsoft Basic Render Driver (WARP) (mul_hi_24_signed_and_unsigned_match_rdna2 covers 36 synthetic cases across both VOP2 and VOP3 encodings and asserts SFI0 & 0x8000 == 0).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: pass (154 files).

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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590689710 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1647). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T20:23:28Z. --- ## Summary - Lowers RDNA2 `v_mul_hi_i32_i24` (VOP2 `0x00a` / VOP3 `0x10a`) and `v_mul_hi_u32_u24` (VOP2 `0x00c` / VOP3 `0x10c`) in `crates/victory-shader/src/emit/lower.rs` (`mul_hi_24`). - Matches AMD RDNA 2 ISA §12.7 (p. 132): ignores input bits `[31:24]`, computes the exact 48-bit signed or unsigned product of bits `[23:0]`, and returns `(product >> 32)` (bits `[47:32]`, sign- or zero-extended to 32 bits). - Uses 16-bit + 8-bit partial products in pure `i32` DXIL arithmetic so shaders using these instructions do not require the `INT64` DXIL capability flag (`SFI0 & 0x8000 == 0`). ## Verification - `cargo test -p victory-shader --lib valu_tests`: **14/14 PASS** on both **AMD Radeon RX 9060 XT (D3D12 hardware)** and **Microsoft Basic Render Driver (WARP)** (`mul_hi_24_signed_and_unsigned_match_rdna2` covers 36 synthetic cases across both VOP2 and VOP3 encodings and asserts `SFI0 & 0x8000 == 0`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: pass (154 files). *AI-assisted; synthetic tests only, no game files.*
DenRakEiw commented 2026-11-24 21:02:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:26:12Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib mul_hi_24_signed_and_unsigned_match_rdna2 — passed on RTX 5090 hardware and under VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean 32-bit-only lowering of v_mul_hi_i32_i24 and v_mul_hi_u32_u24 without requiring INT64, validated end-to-end on hardware and WARP. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046815484 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1647#pullrequestreview-6046815484). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T20:26:12Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib mul_hi_24_signed_and_unsigned_match_rdna2` — passed on RTX 5090 hardware and under `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean 32-bit-only lowering of `v_mul_hi_i32_i24` and `v_mul_hi_u32_u24` without requiring `INT64`, validated end-to-end on hardware and WARP. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 22:01:44 +00:00 (Migrated from github.com)

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

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 → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows.

v_mul_hi_i32_i24/v_mul_hi_u32_u24 lowered without INT64: mul_hi_24(sign) helper, mul_hi_24_signed_and_unsigned_match_rdna2 checks both signs against RDNA2.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047881541 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1647#pullrequestreview-6047881541). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:42:46Z. **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 → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows. v_mul_hi_i32_i24/v_mul_hi_u32_u24 lowered without INT64: mul_hi_24(sign) helper, mul_hi_24_signed_and_unsigned_match_rdna2 checks both signs against RDNA2.
upstream-sync closed this pull request 2026-11-25 02:04:45 +00:00
Marvisak commented 2026-11-25 02:05:57 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #156. Lowers v_mul_hi_i32_i24/v_mul_hi_u32_u24 like #156 (already picked for testing), but with 30 lines of 16/8-bit limb arithmetic only to avoid the INT64 flag main's mul_hi already sets. Its GPU value test (both encodings, 9 cases) is better than #156's and worth carrying over.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149487900 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1647#issuecomment-7149487900). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:22:59Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #156. Lowers v_mul_hi_i32_i24/v_mul_hi_u32_u24 like #156 (already picked for testing), but with 30 lines of 16/8-bit limb arithmetic only to avoid the INT64 flag main's mul_hi already sets. Its GPU value test (both encodings, 9 cases) is better than #156's and worth carrying over. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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