Shader tests: v_pk_mul_lo_u16 keeps each half to 16 bits #1289

Open
github-bot wants to merge 1 commit from github-bot/gh-1289 into main AGit
Owner

@⁠bvtterbroot on GitHub · 2026-11-24 17:09 UTC · original
bvtterbroot:shader-pk-mul-lo-mask → main · +49 −0 · 1 files · 1 commits · open

v_pk_mul_lo_u16 has no test, and its lowering, (x * y) & 0xffff per half, is the case where an AMD driver has been seen to drop the 16-bit mask when the other half of the result is a constant 0. That was in another translator, on the Vulkan path (RDNA2 iGPU, driver 26.10.1, 0x1234 * 0xaaaa read back as 0x0c229e88 instead of 0x00009e88). This adds a test that would catch it here.

What

v_pk_mul_lo_u16_keeps_each_half_to_16_bits in crates/victory-shader/src/emit/valu_tests.rs, plus a small vop3p encoder beside the existing vop1/vop3 ones. All four forms take run-time operands from the root constants, so no compiler can fold them:

Form Expected
v_pk_mul_lo_u16 v0, v1, 0xaaaa0000 op_sel:[0,1] op_sel_hi:[0,0] (v1 = 0x00011234) 0x00009e88
v_pk_mul_lo_u16 v0, s1, v3 op_sel_hi:[1,0] (s1 = 0x0003ffff, v3 = 0x1234abcd) 0x03675433
v_pk_mul_lo_u16 v0, v4, 0x00050000 (v4 = 0x0007beef) 0x00230000
v_pk_mul_lo_u16 v0, v1, 7 op_sel_hi:[1,0] 0x00077f6c

The expected words are the RDNA2 ISA rule (each half is the low 16 bits of the product of the selected source halves). The same four cases were measured on native RDNA2 hardware (gfx1036) in that other project. No translator change: the current lowering gets all four right.

Tested

Windows 11, Rust 1.98.1, at ffe310e:

  • AMD Radeon RX 7900 XTX (RDNA3), driver 32.0.32029.2010: passes.
  • The Ryzen 7 7800X3D's RDNA2 iGPU ("AMD Radeon(TM) Graphics"), driver 32.0.21045.29003: passes, along with the rest of cargo test -p victory-shader (121 passed). The test host picks the default adapter, so for this run I pointed it at the iGPU with a local, uncommitted change to Host::new.
  • WARP: passes.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean. rustfmt --check on the file: clean.

So the AMD D3D12 drivers here do not show the dropped mask. The test is a guard for when the lowering or a driver changes.

🤖 Generated with Claude Code

**@⁠bvtterbroot** on GitHub · 2026-11-24 17:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1289) `bvtterbroot:shader-pk-mul-lo-mask` → `main` · +49 −0 · 1 files · 1 commits · open `v_pk_mul_lo_u16` has no test, and its lowering, `(x * y) & 0xffff` per half, is the case where an AMD driver has been seen to drop the 16-bit mask when the other half of the result is a constant 0. That was in another translator, on the Vulkan path (RDNA2 iGPU, driver 26.10.1, `0x1234 * 0xaaaa` read back as `0x0c229e88` instead of `0x00009e88`). This adds a test that would catch it here. ## What `v_pk_mul_lo_u16_keeps_each_half_to_16_bits` in `crates/victory-shader/src/emit/valu_tests.rs`, plus a small `vop3p` encoder beside the existing `vop1`/`vop3` ones. All four forms take run-time operands from the root constants, so no compiler can fold them: | Form | Expected | |------|----------| | `v_pk_mul_lo_u16 v0, v1, 0xaaaa0000 op_sel:[0,1] op_sel_hi:[0,0]` (v1 = `0x00011234`) | `0x00009e88` | | `v_pk_mul_lo_u16 v0, s1, v3 op_sel_hi:[1,0]` (s1 = `0x0003ffff`, v3 = `0x1234abcd`) | `0x03675433` | | `v_pk_mul_lo_u16 v0, v4, 0x00050000` (v4 = `0x0007beef`) | `0x00230000` | | `v_pk_mul_lo_u16 v0, v1, 7 op_sel_hi:[1,0]` | `0x00077f6c` | The expected words are the RDNA2 ISA rule (each half is the low 16 bits of the product of the selected source halves). The same four cases were measured on native RDNA2 hardware (gfx1036) in that other project. No translator change: the current lowering gets all four right. ## Tested Windows 11, Rust 1.98.1, at `ffe310e`: - AMD Radeon RX 7900 XTX (RDNA3), driver 32.0.32029.2010: passes. - The Ryzen 7 7800X3D's RDNA2 iGPU ("AMD Radeon(TM) Graphics"), driver 32.0.21045.29003: passes, along with the rest of `cargo test -p victory-shader` (121 passed). The test host picks the default adapter, so for this run I pointed it at the iGPU with a local, uncommitted change to `Host::new`. - WARP: passes. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. `rustfmt --check` on the file: clean. So the AMD D3D12 drivers here do not show the dropped mask. The test is a guard for when the lowering or a driver changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
v_pk_mul_lo_u16 had no test. Its low 16 bits are the case where an
AMD driver has been seen to drop the 16-bit mask of a translated
(x * y) & 0xffff when the other half of the result is a constant 0
(Vulkan, RDNA2 iGPU, driver 26.10.1). Four forms with run-time
operands and constant halves: a literal read through op_sel, an SGPR
with op_sel_hi, a literal with a zero low half, and an inline
constant.

Passes on an RX 7900 XTX (driver 32.0.32029.2010), on the Ryzen 7800X3D's
RDNA2 iGPU (driver 32.0.21045.29003) and on WARP.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:30 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:34 UTC · original

Independent verification of \␀03944a\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-shader --lib valu_tests\ (real RX 9060 XT GPU execution): 14 passed, 0 failed (including \ _pk_mul_lo_u16_keeps_each_half_to_16_bits)
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1289#issuecomment-7139406392) Independent verification of \␀03944a\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200\) / Rust 1.98.1 MSVC**: - Merge check vs \main\ (\ fe310e\): clean - \cargo test -p victory-shader --lib valu_tests\ (real RX 9060 XT GPU execution): **14 passed, 0 failed** (including \ _pk_mul_lo_u16_keeps_each_half_to_16_bits\) - \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 154 files ok *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:21 UTC · original · edited 2026-11-25 22:28 UTC

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/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1289#issuecomment-7149461905) · edited 2026-11-25 22:28 UTC <!-- victory-triage v1 head=52c5cdc2a3594f9ba0be93f5e969f6c3b9374bf8 verdict=needs-rebase at=2026-11-25T22:31: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/valu_tests.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)_
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/valu_tests.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/1289/head:github-bot/gh-1289'
git switch 'github-bot/gh-1289'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1289'
git switch 'github-bot/gh-1289'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1289'
git switch 'github-bot/gh-1289'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1289'
git switch 'main'
git merge --squash 'github-bot/gh-1289'
git switch 'main'
git merge --ff-only 'github-bot/gh-1289'
git switch 'main'
git merge 'github-bot/gh-1289'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1289
No description provided.