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

Open
geiyiliyabumo wants to merge 1 commit from upstream-pr/2104 into main
geiyiliyabumo commented 2026-11-25 05:04:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T05:04:56Z.


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).
<!-- greyfinch-sync:Marvisak/VIctory:issue:6597617159 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-25T05:04:56Z. --- ## 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).
DenRakEiw commented 2026-11-25 06:02:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T05:26:31Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib wqm — 2 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (scalar_wqm_ir_tracks_register_widths_and_scc and scalar_wqm_expands_nibbles_and_sets_scc)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean pure-32-bit DXIL lowering of s_wqm_b32 and s_wqm_b64 expanding quad nibbles and setting SCC, verified on hardware and WARP. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052281488 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104#pullrequestreview-6052281488). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T05:26:31Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib wqm` — **2 passed, 0 failed** on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (`scalar_wqm_ir_tracks_register_widths_and_scc` and `scalar_wqm_expands_nibbles_and_sets_scc`) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean pure-32-bit DXIL lowering of `s_wqm_b32` and `s_wqm_b64` expanding quad nibbles and setting SCC, verified on hardware and WARP. Looks good. AI-assisted (Gemini 4 Neon).
upipibi commented 2026-11-25 06:02:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T05:09:02Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153495798 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104#issuecomment-7153495798). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T05:09:02Z. --- 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).
catminou4 commented 2026-11-25 07:02:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T06:33:44Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. s_wqm_b32 and s_wqm_b64 lowered in pure 32-bit DXIL — write-mask ops without i64.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052898932 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104#pullrequestreview-6052898932). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T06:33:44Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. s_wqm_b32 and s_wqm_b64 lowered in pure 32-bit DXIL — write-mask ops without i64.
sinan-cmyk commented 2026-11-25 09:06:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T08:44:03Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157402485 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104#issuecomment-7157402485). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T08:44:03Z. --- ### 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).
Marvisak commented 2026-11-25 11:05:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:39:52Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160004689 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104#issuecomment-7160004689). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:39:52Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-26 03:03:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:26:54Z.

Review: COMMENTED


Reviewed and verified against main (63bcca43) on Windows 11 (RTX 5090 + WARP + dxil.dll, VICTORY_D3D12_DEBUG=1) — clean 32-bit lowering and ready to merge:

  • expand_quads (lower.rs:3918-3935) uses two 32-bit butterfly shift-mask steps (0xaaaa_aaaa/0x5555_5555, 0xcccc_cccc/0x3333_3333) with zero i64 / flags::INT64 usage, symmetric with s_quadmask_b{32,64} and accurate SCC ((low | high) != 0).
  • Note on 512 KiB cap: emit/lower.rs reaches 522,007 B (2,281 B headroom on 63bcca43).

Local verification:

  • victory-shader (emit::valu_tests, emit::lower::tests, emit::semantics_tests): 104/104 passed on both RTX 5090 and WARP (dxil.dll + DEBUG=1), including scalar_wqm_ir_tracks_register_widths_and_scc and scalar_wqm_expands_nibbles_and_sets_scc
  • cargo clippy --locked -p victory-shader --tests -- -D warnings (default & --all-features) + cargo xtask policy (191 files ok): 0 warnings
<!-- greyfinch-sync:Marvisak/VIctory:review:6067747915 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2104#pullrequestreview-6067747915). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:26:54Z. **Review:** COMMENTED --- Reviewed and verified against `main` (`63bcca43`) on Windows 11 (RTX 5090 + WARP + `dxil.dll`, `VICTORY_D3D12_DEBUG=1`) — clean 32-bit lowering and ready to merge: - `expand_quads` (`lower.rs:3918-3935`) uses two 32-bit butterfly shift-mask steps (`0xaaaa_aaaa/0x5555_5555`, `0xcccc_cccc/0x3333_3333`) with zero `i64` / `flags::INT64` usage, symmetric with `s_quadmask_b{32,64}` and accurate `SCC` (`(low | high) != 0`). - **Note on 512 KiB cap**: `emit/lower.rs` reaches **522,007 B** (**2,281 B** headroom on `63bcca43`). **Local verification**: - `victory-shader` (`emit::valu_tests`, `emit::lower::tests`, `emit::semantics_tests`): **104/104 passed** on both **RTX 5090** and **WARP** (`dxil.dll` + `DEBUG=1`), including `scalar_wqm_ir_tracks_register_widths_and_scc` and `scalar_wqm_expands_nibbles_and_sets_scc` - `cargo clippy --locked -p victory-shader --tests -- -D warnings` (default & `--all-features`) + `cargo xtask policy` (`191 files ok`): 0 warnings
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/2104:upstream-pr/2104'
git switch 'upstream-pr/2104'

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