Skip to content

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

Open
geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:feat/shader-v-dot4-dot8
Open

geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:feat/shader-v-dot4-dot8

Conversation

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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

Evidence

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

This verification was AI-assisted.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, 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

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head e4eae6b 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).

Copy link
Copy Markdown
Owner

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

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants