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

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

@⁠geiyiliyabumo on GitHub · 2026-11-25 04:37 UTC · original
geiyiliyabumo:feat/shader-v-dot4-dot8 → main · +136 −17 · 2 files · 1 commits · open

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).
**@⁠geiyiliyabumo** on GitHub · 2026-11-25 04:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2092) `geiyiliyabumo:feat/shader-v-dot4-dot8` → `main` · +136 −17 · 2 files · 1 commits · open ## 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:36 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:43 UTC · original

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.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7153101226) **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://git.gtahub.st/github/Marvisak--VIctory/pulls/1292/files) · [#157 patch](https://git.gtahub.st/github/Marvisak--VIctory/pulls/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://git.gtahub.st/github/Marvisak--VIctory/pulls/2092) **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.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 04:48 UTC · original

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

**@⁠upipibi** on GitHub · 2026-11-25 04:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7153183837) 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).
Author
Owner

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

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 08:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7157623174) ### 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).
Author
Owner

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

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7159883401) <!-- 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)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:42 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2092#issuecomment-7180048167) 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 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/2092/head:github-bot/gh-2092'
git switch 'github-bot/gh-2092'

Merge

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