Shaders: lower s_wqm_b32 and s_wqm_b64 in pure 32-bit DXIL #2104

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

@⁠geiyiliyabumo on GitHub · 2026-11-25 05:04 UTC · original
geiyiliyabumo:feat/shader-s-wqm → main · +113 −0 · 2 files · 1 commits · open

Summary

  • Lowers GFX10 SOP1 instructions s_wqm_b32 (0x009) and s_wqm_b64 (0x00a) in crates/victory-shader/src/emit/lower.rs using pure 32-bit DXIL bitwise nibble expansion without enabling Int64 / WIDE_OPS.
  • Sets SCC = (dst != 0) for s_wqm_b32 and SCC = (dst_lo | dst_hi) != 0 for s_wqm_b64, preserving existing register-width metadata and structure.rs EXEC/lane-mask handling.
  • Adds synthetic IR, DXIL-validation, and GPU execution tests in crates/victory-shader/src/emit/valu_tests.rs covering all 16 nibble values, single-bit-per-nibble and mixed patterns, low-only and high-only SCC cases for b64, and verifying Int64 is not set.

Verification

  • cargo xtask policy: passed
  • cargo clippy -p victory-shader --tests -- -D warnings: passed
  • cargo test -p victory-shader --lib wqm -- --test-threads=1, scalar_quad_masks, and structure::tests (11 passed, 1 bench ignored) with Microsoft dxil.dll: all passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)
  • Zero game files or game-derived data used (synthetic tests only).
**@⁠geiyiliyabumo** on GitHub · 2026-11-25 05:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2104) `geiyiliyabumo:feat/shader-s-wqm` → `main` · +113 −0 · 2 files · 1 commits · open ## Summary - Lowers GFX10 SOP1 instructions `s_wqm_b32` (`0x009`) and `s_wqm_b64` (`0x00a`) in `crates/victory-shader/src/emit/lower.rs` using pure 32-bit DXIL bitwise nibble expansion without enabling `Int64` / `WIDE_OPS`. - Sets `SCC = (dst != 0)` for `s_wqm_b32` and `SCC = (dst_lo | dst_hi) != 0` for `s_wqm_b64`, preserving existing register-width metadata and `structure.rs` `EXEC`/lane-mask handling. - Adds synthetic IR, DXIL-validation, and GPU execution tests in `crates/victory-shader/src/emit/valu_tests.rs` covering all 16 nibble values, single-bit-per-nibble and mixed patterns, low-only and high-only `SCC` cases for `b64`, and verifying `Int64` is not set. ## Verification - `cargo xtask policy`: passed - `cargo clippy -p victory-shader --tests -- -D warnings`: passed - `cargo test -p victory-shader --lib wqm -- --test-threads=1`, `scalar_quad_masks`, and `structure::tests` (11 passed, 1 bench ignored) with Microsoft `dxil.dll`: all passed on **AMD Radeon RX 9060 XT (RDNA4)** and **Microsoft Basic Render Driver (WARP)** - Zero game files or game-derived data used (synthetic tests only).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:56 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 05:09 UTC · original

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at a41083a. victory-shader: 246 passed, 3 failed, 3 ignored. The new scalar_wqm_ir_tracks_register_widths_and_scc and scalar_wqm_expands_nibbles_and_sets_scc pass. The 3 failures are #1744's NVIDIA failures on main. Same as main on this hardware.

I also read expand_quads. The two pair-then-quad spreads keep every bit inside its nibble, so each quad with a set bit ends up all ones, and SCC is the result ≠ 0. That matches s_wqm.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 05:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2104#issuecomment-7153495798) Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `a41083a`. `victory-shader`: 246 passed, 3 failed, 3 ignored. The new `scalar_wqm_ir_tracks_register_widths_and_scc` and `scalar_wqm_expands_nibbles_and_sets_scc` pass. The 3 failures are #1744's NVIDIA failures on `main`. Same as `main` on this hardware. I also read `expand_quads`. The two pair-then-quad spreads keep every bit inside its nibble, so each quad with a set bit ends up all ones, and SCC is the result ≠ 0. That matches `s_wqm`. AI-assisted (Claude Code).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 08:44 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head a41083a0 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 08:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2104#issuecomment-7157402485) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head a41083a0 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:39 UTC · original

Automated triage for the maintainers.

Adds s_wqm_b32 and s_wqm_b64 to the scalar lowering in emit/lower.rs, beside s_quadmask. The new Lower::expand_quads spreads each set bit to its pair and then to its quad, so every quad with a set bit becomes all ones. SCC is the result != 0, which is the documented RDNA S_WQM behaviour. EXEC handling in structure.rs (its wqm case) is untouched. Tests cover all 16 nibbles and both halves for b64. A census shows no title program changes, so it is a small capability rather than a fix. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2104#issuecomment-7160004689) <!-- victory-triage v1 head=a41083a06f22224d1cdc0bd864d8b6a477a893a4 verdict=merge-candidate at=2026-11-25T10:39:45Z --> Automated triage for the maintainers. Adds `s_wqm_b32` and `s_wqm_b64` to the scalar lowering in `emit/lower.rs`, beside `s_quadmask`. The new `Lower::expand_quads` spreads each set bit to its pair and then to its quad, so every quad with a set bit becomes all ones. SCC is the result != 0, which is the documented RDNA `S_WQM` behaviour. EXEC handling in `structure.rs` (its `wqm` case) is untouched. Tests cover all 16 nibbles and both halves for b64. A census shows no title program changes, so it is a small capability rather than a fix. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2104/head:github-bot/gh-2104'
git switch 'github-bot/gh-2104'

Merge

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