shader: lower v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8, and v_mqsad_u32_u8 without INT64 #1672

Closed
github-bot wants to merge 1 commit from gh-pr/1672/head into gh-pr/1672/base
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 20:39 UTC · original
geiyiliyabumo:fix/shader-qsad-mqsad → main · +234 −3 · 2 files · 1 commits · closed without merging

Summary

  • Lowers RDNA2 VOP3 quad/masked sum-of-absolute-differences instructions v_qsad_pk_u16_u8 (0x172), v_mqsad_pk_u16_u8 (0x173), and v_mqsad_u32_u8 (0x175) in crates/victory-shader/src/emit/lower.rs (Lower::quad_sad).
  • Uses pure 32-bit DXIL integer arithmetic so none of the three instructions set the INT64 DXIL capability flag (SFI0 & 0x8000 == 0).
  • Matches AMD RDNA2 ISA §§6.5, 12.12:
    • Computes all 4 sliding-window 4-byte unsigned SAD sums across the 64-bit src0[0:1] reference bytes against the 4 src1 target bytes.
    • Masks zero target bytes (src1_byte[j] == 0) to 0 for v_mqsad_pk_u16_u8 and v_mqsad_u32_u8.
    • Supports unsigned CLAMP saturation (u16::MAX per packed half for *_pk_u16_u8, u32::MAX per dword for v_mqsad_u32_u8) as well as wraparound when unclamped.
    • Writes all destination dwords (vdst[0:1] or vdst[0:3]) under the active EXEC guard.

Verification

  • cargo test -p victory-shader --lib: 123 passed, 0 failed, 1 ignored on both AMD Radeon RX 9060 XT (D3D12 hardware) and Microsoft Basic Render Driver (WARP), including 3 new regression tests (v_qsad_pk_u16_u8_accumulates_all_windows, v_mqsad_pk_u16_u8_masks_zero_target_bytes, v_mqsad_u32_u8_masks_zero_target_bytes — 30 synthetic dispatches per backend covering all 4 windows, zero masking, nonzero accumulators, wrap vs CLAMP, in-place EXEC-guarded writes, and 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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 20:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1672) `geiyiliyabumo:fix/shader-qsad-mqsad` → `main` · +234 −3 · 2 files · 1 commits · closed without merging ## Summary - Lowers RDNA2 VOP3 quad/masked sum-of-absolute-differences instructions `v_qsad_pk_u16_u8` (`0x172`), `v_mqsad_pk_u16_u8` (`0x173`), and `v_mqsad_u32_u8` (`0x175`) in `crates/victory-shader/src/emit/lower.rs` (`Lower::quad_sad`). - Uses pure 32-bit DXIL integer arithmetic so none of the three instructions set the `INT64` DXIL capability flag (`SFI0 & 0x8000 == 0`). - Matches AMD RDNA2 ISA §§6.5, 12.12: - Computes all 4 sliding-window 4-byte unsigned SAD sums across the 64-bit `src0[0:1]` reference bytes against the 4 `src1` target bytes. - Masks zero target bytes (`src1_byte[j] == 0`) to `0` for `v_mqsad_pk_u16_u8` and `v_mqsad_u32_u8`. - Supports unsigned `CLAMP` saturation (`u16::MAX` per packed half for `*_pk_u16_u8`, `u32::MAX` per dword for `v_mqsad_u32_u8`) as well as wraparound when unclamped. - Writes all destination dwords (`vdst[0:1]` or `vdst[0:3]`) under the active `EXEC` guard. ## Verification - `cargo test -p victory-shader --lib`: **123 passed, 0 failed, 1 ignored** on both **AMD Radeon RX 9060 XT (D3D12 hardware)** and **Microsoft Basic Render Driver (WARP)**, including 3 new regression tests (`v_qsad_pk_u16_u8_accumulates_all_windows`, `v_mqsad_pk_u16_u8_masks_zero_target_bytes`, `v_mqsad_u32_u8_masks_zero_target_bytes` — 30 synthetic dispatches per backend covering all 4 windows, zero masking, nonzero accumulators, wrap vs `CLAMP`, in-place `EXEC`-guarded writes, and `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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:00 +00:00
github-bot closed this pull request 2026-11-26 04:41:00 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 20:52 UTC · original

Closing in favor of #1662, which was opened a few minutes earlier with the same pure-32-bit DXIL lowering for v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8, and v_mqsad_u32_u8 (plus Wave32/Wave64 coverage).

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 20:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1672#issuecomment-7144169381) Closing in favor of #1662, which was opened a few minutes earlier with the same pure-32-bit DXIL lowering for `v_qsad_pk_u16_u8`, `v_mqsad_pk_u16_u8`, and `v_mqsad_u32_u8` (plus Wave32/Wave64 coverage). *AI-assisted; synthetic tests only, no game files.*

Pull request closed

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