shader: lower s_absdiff_i32 and s_pack_{ll,lh,hh}_b32_b16 #1674

Closed
geiyiliyabumo wants to merge 1 commit from upstream-pr/1675 into main
geiyiliyabumo commented 2026-11-24 20:41:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T20:41:06Z.


Summary

  • Lowers four RDNA2 SOP2 scalar ALU instructions in crates/victory-shader/src/emit/lower.rs:
    • s_absdiff_i32 (0x02c): computes 32-bit signed |src0 - src1| (preserving two's-complement wraparound on i32::MIN) and sets SCC = (result != 0) (already declared in ir.rs writes_scc).
    • s_pack_ll_b32_b16 (0x032), s_pack_lh_b32_b16 (0x033), and s_pack_hh_b32_b16 (0x034): pack selected 16-bit halves of src0 (low 16) and src1 (high 16); do not modify SCC.
  • Scoped cleanly to avoid overlapping with #142 (s_sext_i32_{i8,i16}).

Verification

  • cargo test -p victory-shader --lib valu_tests: PASS on both AMD Radeon RX 9060 XT (D3D12 hardware) and Microsoft Basic Render Driver (WARP), including scalar_absdiff_and_pack_match_rdna2.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: pass (154 files).

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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590991634 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1675). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T20:41:06Z. --- ## Summary - Lowers four RDNA2 SOP2 scalar ALU instructions in `crates/victory-shader/src/emit/lower.rs`: - `s_absdiff_i32` (`0x02c`): computes 32-bit signed `|src0 - src1|` (preserving two's-complement wraparound on `i32::MIN`) and sets `SCC = (result != 0)` (already declared in `ir.rs` `writes_scc`). - `s_pack_ll_b32_b16` (`0x032`), `s_pack_lh_b32_b16` (`0x033`), and `s_pack_hh_b32_b16` (`0x034`): pack selected 16-bit halves of `src0` (low 16) and `src1` (high 16); do not modify `SCC`. - Scoped cleanly to avoid overlapping with #142 (`s_sext_i32_{i8,i16}`). ## Verification - `cargo test -p victory-shader --lib valu_tests`: PASS on both **AMD Radeon RX 9060 XT (D3D12 hardware)** and **Microsoft Basic Render Driver (WARP)**, including `scalar_absdiff_and_pack_match_rdna2`. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: pass (154 files). *AI-assisted; synthetic tests only, no game files.*
catminou4 commented 2026-11-24 22:01:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:12Z.

Review: APPROVED


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; macOS covers lowering/structure unit tests.

s_absdiff_i32 and s_pack_{ll,lh,hh}_b32_b16 lowered; scalar_absdiff_and_pack_match_rdna2 checks encodings and values.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047849802 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1675#pullrequestreview-6047849802). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:40:12Z. **Review:** APPROVED --- 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; macOS covers lowering/structure unit tests. s_absdiff_i32 and s_pack_{ll,lh,hh}_b32_b16 lowered; scalar_absdiff_and_pack_match_rdna2 checks encodings and values.
upstream-sync closed this pull request 2026-11-25 02:04:53 +00:00
Marvisak commented 2026-11-25 02:05:59 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #120. Lowers s_absdiff_i32 and s_pack_{ll,lh,hh}_b32_b16, which the title does not use. The clean #120 covers the same four plus s_sext.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149511261 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1675#issuecomment-7149511261). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:24:21Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #120. Lowers s_absdiff_i32 and s_pack_{ll,lh,hh}_b32_b16, which the title does not use. The clean #120 covers the same four plus s_sext. 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 commented 2026-11-25 02:06:11 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149699980 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1675#issuecomment-7149699980). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:34:16Z. --- <!-- victory-triage v1 head=5a3f25a48bcde1715e1de7bfa4a8cc1a9d82afb7 verdict=needs-rebase at=2026-11-25T01:34:16Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _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!1674
No description provided.