shader: lower s_cmov_b32, s_cmov_b64, and s_cmovk_i32 #1648

Open
geiyiliyabumo wants to merge 1 commit from upstream-pr/1649 into main
geiyiliyabumo commented 2026-11-24 20:27:30 +00:00 (Migrated from github.com)

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


Summary

  • Lowers RDNA2 scalar conditional moves s_cmov_b32 (SOP1 0x005), s_cmov_b64 (SOP1 0x006), and s_cmovk_i32 (SOPK 0x002) in crates/victory-shader/src/emit/lower.rs.
  • ir.rs (lines 707–719) and resource.rs (lines 945–977) already tracked old destination reads, SCC inputs, and non-SCC-clobbering semantics for all three instructions; this completes the DXIL lowering side:
    • s_cmov_b64 selects each 32-bit half independently (SCC ? src0[h] : old_dst[h]), including sign-extended inline constants and null destination handling, without requiring INT64 (SFI0 & 0x8000 == 0).
    • s_cmov_b32 and s_cmovk_i32 select SCC ? new : old_dst (sign-extending simm16 for s_cmovk_i32) and leave SCC untouched.

Verification

  • cargo test -p victory-shader --lib: full unit suite + scalar_cmov_updates_only_when_scc_is_set PASS on both AMD Radeon RX 9060 XT (D3D12 hardware) and Microsoft Basic Render Driver (WARP), covering SCC=0 preservation, SCC=1 overwrite, preserved SCC after moving 0, positive/negative simm16 sign-extension, 64-bit register pairs, inline -1 sign-extension into high dword, 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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590759362 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T20:27:30Z. --- ## Summary - Lowers RDNA2 scalar conditional moves `s_cmov_b32` (`SOP1 0x005`), `s_cmov_b64` (`SOP1 0x006`), and `s_cmovk_i32` (`SOPK 0x002`) in `crates/victory-shader/src/emit/lower.rs`. - `ir.rs` (lines 707–719) and `resource.rs` (lines 945–977) already tracked old destination reads, `SCC` inputs, and non-`SCC`-clobbering semantics for all three instructions; this completes the DXIL lowering side: - `s_cmov_b64` selects each 32-bit half independently (`SCC ? src0[h] : old_dst[h]`), including sign-extended inline constants and `null` destination handling, without requiring `INT64` (`SFI0 & 0x8000 == 0`). - `s_cmov_b32` and `s_cmovk_i32` select `SCC ? new : old_dst` (sign-extending `simm16` for `s_cmovk_i32`) and leave `SCC` untouched. ## Verification - `cargo test -p victory-shader --lib`: full unit suite + `scalar_cmov_updates_only_when_scc_is_set` PASS on both **AMD Radeon RX 9060 XT (D3D12 hardware)** and **Microsoft Basic Render Driver (WARP)**, covering `SCC=0` preservation, `SCC=1` overwrite, preserved `SCC` after moving `0`, positive/negative `simm16` sign-extension, 64-bit register pairs, inline `-1` sign-extension into high dword, 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.*
catminou4 commented 2026-11-24 22:01:45 +00:00 (Migrated from github.com)

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

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.

s_cmov_b32/s_cmov_b64/s_cmovk_i32 lowered: scalar_cmov_updates_only_when_scc_is_set pins the SCC-gated move semantics with sop1/sopk const encoders.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047881345 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649#pullrequestreview-6047881345). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:42:45Z. **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. s_cmov_b32/s_cmov_b64/s_cmovk_i32 lowered: scalar_cmov_updates_only_when_scc_is_set pins the SCC-gated move semantics with sop1/sopk const encoders.
Marvisak commented 2026-11-25 02:06:10 +00:00 (Migrated from github.com)

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


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:7149679525 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649#issuecomment-7149679525). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:33:14Z. --- <!-- victory-triage v1 head=1041a126d43990e568184b72d1dd76f93bf84efa verdict=needs-rebase at=2026-11-25T22:28:30Z --> 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)_
Headache3318 commented 2026-11-25 02:06:15 +00:00 (Migrated from github.com)

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


Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 3668245 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 96 passed, 0 failed, 1 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 2 pre-existing unused-import errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149762840 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649#issuecomment-7149762840). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T01:37:24Z. --- Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `3668245` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 96 passed, 0 failed, 1 ignored. All tests pass. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 2 pre-existing unused-import errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
geiyiliyabumo commented 2026-11-25 03:03:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T02:24:59Z.


Rebased cleanly onto \main\ (\ccfb029). \cargo test -p victory-shader --locked scalar_cmov\ (verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll), \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings, and \cargo xtask policy\ all pass.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150690330 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649#issuecomment-7150690330). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-25T02:24:59Z. --- Rebased cleanly onto \main\ (\ccfb029\). \cargo test -p victory-shader --locked scalar_cmov\ (verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll\), \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings\, and \cargo xtask policy\ all pass.
StExpeditus commented 2026-11-25 05:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T04:23:50Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 1041a12. cargo test --workspace --locked --no-fail-fast -> all green: 0 passed, 0 ignored, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152804779 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649#issuecomment-7152804779). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T04:23:50Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `1041a12`. `cargo test --workspace --locked --no-fail-fast` -> **all green**: 0 passed, 0 ignored, 0 failed.
StExpeditus commented 2026-11-25 10:07:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:07:36Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 1041a12. cargo test --workspace --locked --no-fail-fast -> 694 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157909723 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1649#issuecomment-7157909723). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:07:36Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `1041a12`. `cargo test --workspace --locked --no-fail-fast` -> 694 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1649:upstream-pr/1649'
git switch 'upstream-pr/1649'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1649'
git switch 'upstream-pr/1649'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1649'
git switch 'upstream-pr/1649'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1649'
git switch 'main'
git merge --squash 'upstream-pr/1649'
git switch 'main'
git merge --ff-only 'upstream-pr/1649'
git switch 'main'
git merge 'upstream-pr/1649'
git push origin 'main'
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!1648
No description provided.