Skip to content

shader: lower v_mul_hi_i32_i24 and v_mul_hi_u32_u24 without INT64 - #1647

Closed
geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:fix/shader-mul-hi-24
Closed

geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:fix/shader-mul-hi-24

Conversation

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026

@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 → 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.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
@Marvisak

Copy link
Copy Markdown
Owner

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.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants