Shaders: lower v_dot4_u32_u8 and v_dot8_u32_u4 in pure 32-bit DXIL #2090

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

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T04:37:22Z.


Summary

  • Lowers GFX10 VOP3P instructions v_dot4_u32_u8 and v_dot8_u32_u4 in crates/victory-shader/src/emit/lower.rs using pure 32-bit DXIL (shifts, masks, multiply-adds, and unsigned overflow detection for clamp), reusing the existing VOP3P half-selector and modifier validation from v_dot4_i32_i8 without enabling Int64 / WIDE_OPS.
  • Adds synthetic DXIL-validation and GPU execution tests in crates/victory-shader/src/emit/valu_tests.rs covering unsigned byte products (including 0xFF * 0xFF), all 8 nibble positions and max nibble sum (1800), modulo-2^32 wraparound (clamp = 0), unsigned saturation to 0xFFFF_FFFF (clamp = 1), and VOP3P operand half selection, asserting Int64 is not set.

Verification

  • cargo xtask policy: passed
  • cargo clippy -p victory-shader --tests -- -D warnings: passed
  • cargo test -p victory-shader --lib dot_products -- --test-threads=1 with Microsoft dxil.dll: 5/5 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:6597316288 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-25T04:37:22Z. --- ## Summary - Lowers GFX10 VOP3P instructions `v_dot4_u32_u8` and `v_dot8_u32_u4` in `crates/victory-shader/src/emit/lower.rs` using pure 32-bit DXIL (shifts, masks, multiply-adds, and unsigned overflow detection for `clamp`), reusing the existing VOP3P half-selector and modifier validation from `v_dot4_i32_i8` without enabling `Int64` / `WIDE_OPS`. - Adds synthetic DXIL-validation and GPU execution tests in `crates/victory-shader/src/emit/valu_tests.rs` covering unsigned byte products (including `0xFF * 0xFF`), all 8 nibble positions and max nibble sum (`1800`), modulo-`2^32` wraparound (`clamp = 0`), unsigned saturation to `0xFFFF_FFFF` (`clamp = 1`), and VOP3P operand half selection, asserting `Int64` is not set. ## Verification - `cargo xtask policy`: passed - `cargo clippy -p victory-shader --tests -- -D warnings`: passed - `cargo test -p victory-shader --lib dot_products -- --test-threads=1` with Microsoft `dxil.dll`: 5/5 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 05:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:41:35Z.

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 unsigned_ — 4 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (covering v_dot4_u32_u8, v_dot8_u32_u4, wrapping/saturating, and operand half selectors)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean pure-32-bit DXIL lowering of v_dot4_u32_u8 and v_dot8_u32_u4, verified end-to-end on hardware and WARP. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051958138 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#pullrequestreview-6051958138). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:41:35Z. **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 unsigned_` — **4 passed, 0 failed** on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (covering `v_dot4_u32_u8`, `v_dot8_u32_u4`, wrapping/saturating, and operand half selectors) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean pure-32-bit DXIL lowering of `v_dot4_u32_u8` and `v_dot8_u32_u4`, verified end-to-end on hardware and WARP. Looks good. AI-assisted (Gemini 4 Neon).
jeremygold02 commented 2026-11-25 05:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:43:10Z.


Triage verdict — Keep the unsigned dot lowering with operand selectors (e4eae6b)

Evidence

  • @geiyiliyabumo’s two unsigned opcodes overlap #1292 and #157. The unsigned product sums fit in a dword, so the candidate can saturate by checking the one accumulator addition. It also honors both packed operand half selectors. #1292’s corresponding arms unpack ordinary src operands without those selectors, while #157 explicitly refuses selector and clamp cases. Current lowering · #1292 patch · #157 patch

Checks and limits

  • Compared the exact-head code and fixtures. The existing review reports four focused tests passing with DXIL validation on hardware and WARP. I did not independently dispatch these tests. Existing verification

Next step

  • Preserve this unsigned selector and saturation behavior when rebasing the broader proposals. Keep #1292’s wider signed/16-bit accumulation work and #157’s unrelated ALU cases available for separate review. There should be one implementation of the two unsigned opcodes.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153101226 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7153101226). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:43:10Z. --- **Triage verdict — Keep the unsigned dot lowering with operand selectors** (`e4eae6b`) **Evidence** - @geiyiliyabumo’s two unsigned opcodes overlap #1292 and #157. The unsigned product sums fit in a dword, so the candidate can saturate by checking the one accumulator addition. It also honors both packed operand half selectors. #1292’s corresponding arms unpack ordinary `src` operands without those selectors, while #157 explicitly refuses selector and clamp cases. [Current lowering](https://github.com/Marvisak/VIctory/blob/e4eae6b3466a852563807b9f6beedd1c18e84d80/crates/victory-shader/src/emit/lower.rs#L5599-L5654) · [#1292 patch](https://github.com/Marvisak/VIctory/pull/1292/files) · [#157 patch](https://github.com/Marvisak/VIctory/pull/157/files) **Checks and limits** - Compared the exact-head code and fixtures. The existing review reports four focused tests passing with DXIL validation on hardware and WARP. I did not independently dispatch these tests. [Existing verification](https://github.com/Marvisak/VIctory/pull/2092#pullrequestreview-6051958138) **Next step** - Preserve this unsigned selector and saturation behavior when rebasing the broader proposals. Keep #1292’s wider signed/16-bit accumulation work and #157’s unrelated ALU cases available for separate review. There should be one implementation of the two unsigned opcodes. This verification was AI-assisted.
upipibi commented 2026-11-25 05:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T04:48:36Z.


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

Overlap, from reading: #1292 (open, conflicting with main) lowers v_dot4_u32_u8 and v_dot8_u32_u4 too, along with v_dot2_{i32_i16,u32_u16}, v_dot4_i32_i8 and v_dot4c_i32_i8.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153183837 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7153183837). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T04:48:36Z. --- Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `e4eae6b`. `victory-shader`: 247 passed, 3 failed, 3 ignored. The new `unsigned_byte_dot_products_wrap_or_saturate`, `unsigned_nibble_dot_products_wrap_or_saturate` and `unsigned_packed_dot_products_use_operand_half_selectors` pass. The 3 failures are #1744's NVIDIA failures on `main`. Same as `main` on this hardware. Overlap, from reading: #1292 (open, conflicting with `main`) lowers `v_dot4_u32_u8` and `v_dot8_u32_u4` too, along with `v_dot2_{i32_i16,u32_u16}`, `v_dot4_i32_i8` and `v_dot4c_i32_i8`. AI-assisted (Claude Code).
catminou4 commented 2026-11-25 06:02:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:16:24Z.

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. v_dot4_u32_u8 and v_dot8_u32_u4 lowered in pure 32-bit DXIL — dot-product ops without i64; relates to #1879's dot4 runtime operands.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052205140 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#pullrequestreview-6052205140). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T05:16:24Z. **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. v_dot4_u32_u8 and v_dot8_u32_u4 lowered in pure 32-bit DXIL — dot-product ops without i64; relates to #1879's dot4 runtime operands.
sinan-cmyk commented 2026-11-25 09:06:24 +00:00 (Migrated from github.com)

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


Offline measurement on a retail dump

Result: no count change against main.

I merged head e4eae6b3 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:7157623174 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7157623174). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T08:54:33Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head e4eae6b3 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:26 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Extends the existing v_dot4_i32_i8 arm in emit/lower.rs to v_dot4_u32_u8 (VOP3P 0x17) and v_dot8_u32_u4 (0x19), reusing its op_sel/op_sel_hi operand handling. I checked the opcodes against gfx10/opcodes.rs, that the byte/nibble product sums fit in 32 bits (so the only overflow is the accumulator add, which the clamp path saturates with an unsigned compare), and the expected values in the three new valu_tests.rs tests, including the half-selector case. This matches the unsigned dot products as AMD's public RDNA ISA guide describes them; citing that in the PR would help. CI passes, and an independent NVIDIA run reports the new tests passing.

Notes: #1292 and #157 also touch these two opcodes; there should be one implementation. The try_build_valu_cs change (panic when VICTORY_DXIL is set but fails to load) also appears in #2097 with a different message, so whichever lands second needs a trivial rebase.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159883401 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7159883401). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:34:33Z. --- <!-- victory-triage v1 head=e4eae6b3466a852563807b9f6beedd1c18e84d80 verdict=merge-candidate at=2026-11-25T10:34:25Z --> Automated triage for the maintainers. Extends the existing `v_dot4_i32_i8` arm in `emit/lower.rs` to `v_dot4_u32_u8` (VOP3P 0x17) and `v_dot8_u32_u4` (0x19), reusing its op_sel/op_sel_hi operand handling. I checked the opcodes against `gfx10/opcodes.rs`, that the byte/nibble product sums fit in 32 bits (so the only overflow is the accumulator add, which the `clamp` path saturates with an unsigned compare), and the expected values in the three new `valu_tests.rs` tests, including the half-selector case. This matches the unsigned dot products as AMD's public RDNA ISA guide describes them; citing that in the PR would help. CI passes, and an independent NVIDIA run reports the new tests passing. Notes: #1292 and #157 also touch these two opcodes; there should be one implementation. The `try_build_valu_cs` change (panic when `VICTORY_DXIL` is set but fails to load) also appears in #2097 with a different message, so whichever lands second needs a trivial rebase. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 02:07:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:42:44Z.


Code review and RTX 5090 + WARP + DXIL verification at head e4eae6b3466a merged cleanly onto main (63bcca43c6a0; emit/lower.rs = 522,189 B, 2,099 B under the 512 KiB cap):

  • Code review (crates/victory-shader/src/emit/lower.rs:6194-6249):
    • Shares v.opsel/v.opsel_hi half selection with v_dot4_i32_i8; computes pure 32-bit unsigned 4x8 (<= 260,100) and 8x4 (<= 1,800) dot products without u32 overflow, detects acc + dot wrap via pred::IULT(sum, acc) for v.clamp saturation to u32::MAX, and writes under guard. (Consistent with v_dot4_i32_i8, line 6199 checks v.neg_hi != 0.)
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, dxil.dll 10.0.26100.0, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy (default + --features diagnostics): 0 warnings
    • dot_product (5/5), emit::lower::tests (33/33), and emit::semantics_tests (34/34 on both RTX 5090 and WARP, 1 ignored) all passed.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180048167 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7180048167). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:42:44Z. --- Code review and RTX 5090 + WARP + DXIL verification at head `e4eae6b3466a` merged cleanly onto `main` (`63bcca43c6a0`; `emit/lower.rs` = `522,189` B, `2,099` B under the 512 KiB cap): - **Code review (`crates/victory-shader/src/emit/lower.rs:6194-6249`)**: - Shares `v.opsel`/`v.opsel_hi` half selection with `v_dot4_i32_i8`; computes pure 32-bit unsigned 4x8 (`<= 260,100`) and 8x4 (`<= 1,800`) dot products without `u32` overflow, detects `acc + dot` wrap via `pred::IULT(sum, acc)` for `v.clamp` saturation to `u32::MAX`, and writes under `guard`. (Consistent with `v_dot4_i32_i8`, line 6199 checks `v.neg_hi != 0`.) - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `dxil.dll` 10.0.26100.0, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy` (default + `--features diagnostics`): 0 warnings - `dot_product` (5/5), `emit::lower::tests` (33/33), and `emit::semantics_tests` (34/34 on both RTX 5090 and WARP, 1 ignored) all passed. LGTM.
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/2092:upstream-pr/2092'
git switch 'upstream-pr/2092'

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