Shaders: lower s_cmov_b32, s_cmov_b64 and s_cmovk_i32 #91

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

@⁠tedin7 on GitHub · 2026-11-24 00:22 UTC · original
tedin7:vic-scalar-cmov → main · +103 −1 · 1 files · 1 commits · open

What

  • Lowers the scalar conditional moves s_cmov_b32, s_cmov_b64 and s_cmovk_i32 as a select on SCC between the source and the destination's old value. They do not touch SCC.

Why

  • The IR already tracks them (reads SCC and the old destination, ir.rs), but the lowering had no case for them, so any shader using one failed to translate with Unsupported.

Tested

  • Linux x86_64 only. New unit test scalar_conditional_moves_lower builds synthetic compute programs (no game data) with each of the three instructions and lowers them. Before the change it fails with Unsupported { what: "s_cmov_b32" }; after, it passes.
  • cargo test -j4 -p victory-shader: 52 passed, 0 failed.
  • cargo clippy -j4 -p victory-shader --tests: no new warnings (one existing dead_code warning for a Windows-only test helper).
  • rustfmt --check on lower.rs: clean.
  • NOT run: Windows runtime, GPU, or a real console shader using these instructions. The test checks that lowering succeeds, not the emitted DXIL values.
  • Note: PR #81 adds a similar lowers() test helper in the same tests module, so a trivial merge conflict there is possible.
**@⁠tedin7** on GitHub · 2026-11-24 00:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/91) `tedin7:vic-scalar-cmov` → `main` · +103 −1 · 1 files · 1 commits · open What - Lowers the scalar conditional moves s_cmov_b32, s_cmov_b64 and s_cmovk_i32 as a select on SCC between the source and the destination's old value. They do not touch SCC. Why - The IR already tracks them (reads SCC and the old destination, ir.rs), but the lowering had no case for them, so any shader using one failed to translate with Unsupported. Tested - Linux x86_64 only. New unit test scalar_conditional_moves_lower builds synthetic compute programs (no game data) with each of the three instructions and lowers them. Before the change it fails with Unsupported { what: "s_cmov_b32" }; after, it passes. - cargo test -j4 -p victory-shader: 52 passed, 0 failed. - cargo clippy -j4 -p victory-shader --tests: no new warnings (one existing dead_code warning for a Windows-only test helper). - rustfmt --check on lower.rs: clean. - NOT run: Windows runtime, GPU, or a real console shader using these instructions. The test checks that lowering succeeds, not the emitted DXIL values. - Note: PR #81 adds a similar lowers() test helper in the same tests module, so a trivial merge conflict there is possible.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:49:55 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:23 UTC · original

Tested ed5f98f stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test --workspace: 156 passed, 0 failed, 3 ignored; merge with #39 clean.
  • The PR adds 4 #[test]s for the new s_cmov* lowerings, included in that run.
  • No game data used.

AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/91#issuecomment-7118021023) Tested `ed5f98f` stacked on **#39** on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test --workspace`: **156 passed, 0 failed, 3 ignored**; merge with #39 clean. - The PR adds 4 `#[test]`s for the new `s_cmov*` lowerings, included in that run. - No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠lordon1a on GitHub · 2026-11-24 00:40 UTC · original

Verified ed5f98ff6 on Windows 11 (x86_64-pc-windows-gnullvm, rustc 1.100.0, applied cleanly to main@35b054ec0): pass.

  • cargo xtask policy: 150 files ok
  • cargo test -p victory-shader: 58 passed, 0 failed (+1 new lowering test for s_cmov_b32/s_cmov_b64/s_cmovk_i32).

AI-assisted.

**@⁠lordon1a** on GitHub · 2026-11-24 00:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/91#issuecomment-7118310256) Verified `ed5f98ff6` on Windows 11 (`x86_64-pc-windows-gnullvm`, `rustc 1.100.0`, applied cleanly to `main@35b054ec0`): **pass**. - `cargo xtask policy`: 150 files ok - `cargo test -p victory-shader`: **58 passed, 0 failed** (+1 new lowering test for `s_cmov_b32`/`s_cmov_b64`/`s_cmovk_i32`). AI-assisted.
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 06:22 UTC · original

RDNA2 hardware check of the three conditional moves: all match.

Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 130 cases: SCC set from bit 0 of a test value (s_bitcmp1_b32), with random and edge sources.

  • s_cmov_b32 / s_cmov_b64: the source when SCC = 1, the destination's old value (both dwords for _b64) when SCC = 0: 130/130.
  • s_cmovk_i32: the 16-bit constant sign-extended (0xbeef → 0xffffbeef) when SCC = 1, else the old value: 130/130.
  • SCC is unchanged after them: 130/130.

So the select on SCC is right. The k form sign-extends its simm16, so it is worth checking that the lowering uses the sign-extended constant and not a zero-extended one.

AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.

**@⁠Lyrnc** on GitHub · 2026-11-24 06:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/91#issuecomment-7123870236) RDNA2 hardware check of the three conditional moves: **all match.** **Setup.** AMD Radeon iGPU of a Ryzen 7 9800X3D, **gfx1036 (RDNA2)**, AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 130 cases: SCC set from bit 0 of a test value (`s_bitcmp1_b32`), with random and edge sources. - `s_cmov_b32` / `s_cmov_b64`: the source when SCC = 1, the destination's old value (both dwords for `_b64`) when SCC = 0: 130/130. - `s_cmovk_i32`: the 16-bit constant **sign-extended** (`0xbeef` → `0xffffbeef`) when SCC = 1, else the old value: 130/130. - SCC is unchanged after them: 130/130. So the select on SCC is right. The `k` form sign-extends its `simm16`, so it is worth checking that the lowering uses the sign-extended constant and not a zero-extended one. AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
Author
Owner

@⁠ricarmandoagent on GitHub · 2026-11-24 13:01 UTC · original

Two things before this can land.

  1. It is dirty against main today, and the rebase is not mechanical: main now has its own fn lowers(words: &[u32], rsrc2: u32) in this test module (line 6959). This branch adds a second fn lowers(words: &[u32]); both names cannot coexist after a rebase. Reuse the existing helper.

  2. scalar_conditional_moves_lower only asserts that lowering returns Ok (lowers(&words).unwrap()). An inverted select (select(c, cond, old, a)), a swapped half, or a stale destination read all still pass. Since the change is about the value kept when SCC is clear, please assert on the lowered program, or add a fixture that does.

AI-assisted review.

**@⁠ricarmandoagent** on GitHub · 2026-11-24 13:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/91#issuecomment-7132239914) Two things before this can land. 1. It is `dirty` against main today, and the rebase is not mechanical: `main` now has its own `fn lowers(words: &[u32], rsrc2: u32)` in this test module (line 6959). This branch adds a second `fn lowers(words: &[u32])`; both names cannot coexist after a rebase. Reuse the existing helper. 2. `scalar_conditional_moves_lower` only asserts that lowering returns `Ok` (`lowers(&words).unwrap()`). An inverted select (`select(c, cond, old, a)`), a swapped half, or a stale destination read all still pass. Since the change is about the value kept when SCC is clear, please assert on the lowered program, or add a fixture that does. AI-assisted review.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:16 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/91#issuecomment-7148338496) <!-- victory-triage v1 head=ed5f98ff67e3c09cde81b36c28bff216cc16a079 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-shader/src/emit/lower.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.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/91/head:github-bot/gh-91'
git switch 'github-bot/gh-91'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-91'
git switch 'github-bot/gh-91'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-91'
git switch 'github-bot/gh-91'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-91'
git switch 'main'
git merge --squash 'github-bot/gh-91'
git switch 'main'
git merge --ff-only 'github-bot/gh-91'
git switch 'main'
git merge 'github-bot/gh-91'
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!91
No description provided.