Shaders: lower v_mul_hi_u32_u24 and v_mul_hi_i32_i24 (port of VIctory#156) #56

Open
github-bot wants to merge 2 commits from github-bot/gh-56 into main AGit
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 20:57 UTC · original
lcg007xd-c:port/mul-hi-24 → main · +61 −0 · 1 files · 2 commits · open

What

v_mul_hi_u32_u24 and v_mul_hi_i32_i24 (VOP2 0x0C / 0x0A) had no lowering, so any shader that used them failed to translate. Their low-dword partners v_mul_u32_u24 / v_mul_i32_i24 were already lowered.

They now give the high dword of the same 48-bit product. Each operand's low 24 bits are zero- or sign-extended, then go through the existing mul_hi.

Port

Cherry-pick (-x) of github.com/Marvisak/VIctory@344704e from upstream. Rareuncommon is still the commit author. It applied cleanly. It also adds a small lowers_valu test helper: a one-thread compute program that stores v0, so a VALU instruction can be checked for lowering without a GPU.

Test

the_24_bit_multiplies_lower_both_halves lowers all four 24-bit multiplies. With the new match arm reverted it fails (v_mul_hi_* is unsupported). With it, it passes.

How this was checked (Linux, no Windows PC or game files)

  • The portable CI commands pass locally on this branch: cargo clippy -p victory-core -p victory-pe -p victory-pipeline -p victory-shader -p victory-formats -p victory-game -p xtask --all-targets --locked -- -D warnings, then cargo test on the same crates (rebased on current main).
  • cargo clippy with the same crates and --target x86_64-pc-windows-msvc (check only, no link) is clean.
  • lower.rs has the same number of rustfmt differences before and after this change, so the added code is rustfmt-clean.

Not tested: Windows runtime, GPU, and the game itself. In particular, the numeric results were not run on a GPU here. The new test only proves the instructions now lower, and Windows CI validates the module where dxil.dll is available.

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 20:57 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/56) `lcg007xd-c:port/mul-hi-24` → `main` · +61 −0 · 1 files · 2 commits · open ## What `v_mul_hi_u32_u24` and `v_mul_hi_i32_i24` (VOP2 0x0C / 0x0A) had no lowering, so any shader that used them failed to translate. Their low-dword partners `v_mul_u32_u24` / `v_mul_i32_i24` were already lowered. They now give the high dword of the same 48-bit product. Each operand's low 24 bits are zero- or sign-extended, then go through the existing `mul_hi`. ## Port Cherry-pick (`-x`) of https://github.com/Marvisak/VIctory/commit/344704e from upstream. Rareuncommon is still the commit author. It applied cleanly. It also adds a small `lowers_valu` test helper: a one-thread compute program that stores `v0`, so a VALU instruction can be checked for lowering without a GPU. ## Test `the_24_bit_multiplies_lower_both_halves` lowers all four 24-bit multiplies. With the new match arm reverted it fails (`v_mul_hi_*` is unsupported). With it, it passes. ## How this was checked (Linux, no Windows PC or game files) - The portable CI commands pass locally on this branch: `cargo clippy -p victory-core -p victory-pe -p victory-pipeline -p victory-shader -p victory-formats -p victory-game -p xtask --all-targets --locked -- -D warnings`, then `cargo test` on the same crates (rebased on current `main`). - `cargo clippy` with the same crates and `--target x86_64-pc-windows-msvc` (check only, no link) is clean. - `lower.rs` has the same number of `rustfmt` differences before and after this change, so the added code is rustfmt-clean. Not tested: Windows runtime, GPU, and the game itself. In particular, the numeric results were not run on a GPU here. The new test only proves the instructions now lower, and Windows CI validates the module where `dxil.dll` is available. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The high dword of the 48-bit product whose low dword v_mul_u32_u24 and v_mul_i32_i24 already give: the low
24 bits of each operand, zero- or sign-extended, through the existing mul_hi.

The test module gets lowers_valu, a one-thread compute program with root constants in v1..v4 and a buffer
store of v0 (built with lower_with), so a vector instruction can be checked for lowering without a GPU.

AI-assisted (Claude Code).

(cherry picked from commit 344704e02850eb227fe61d4fd54e6657c17ea68d)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:42:43 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/56/head:github-bot/gh-56'
git switch 'github-bot/gh-56'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-56'
git switch 'github-bot/gh-56'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-56'
git switch 'github-bot/gh-56'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-56'
git switch 'main'
git merge --squash 'github-bot/gh-56'
git switch 'main'
git merge --ff-only 'github-bot/gh-56'
git switch 'main'
git merge 'github-bot/gh-56'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.