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

Closed
bvtterbroot wants to merge 1 commit from upstream-pr/1289 into main
bvtterbroot commented 2026-11-24 17:09:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bvtterbroot on 2026-11-24T17:09:17Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5476816228 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1289). Originally posted by [bvtterbroot](https://github.com/bvtterbroot) on 2026-11-24T17:09:17Z. --- `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)
geiyiliyabumo commented 2026-11-24 18:05:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T17:34:53Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139406392 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1289#issuecomment-7139406392). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T17:34:53Z. --- 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.*
Marvisak commented 2026-11-25 02:05:54 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149461905 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1289#issuecomment-7149461905). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:21:22Z. --- <!-- 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)_

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