shader: lower remaining packed dot products and clamped integer forms #2202
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2202
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2202"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@UnkwnDev on GitHub · 2026-11-25 07:44 UTC · original
UnkwnDev:arc-packed-dot-products→main· +655 −56 · 3 files · 2 commits · openSplit out from #740 per triage feedback against current
main(940d32f).mainalready lowersv_dot4_i32_i8(withopsel/opsel_hi) and unclampedv_dot4c_i32_i8to DXILdot4AddPacked.i32. This PR adds the remaining dot-product lowering and saturation forms:v_dot4_u32_u8: lowers through the sameopsel/opsel_hihalf-selection helper todot4AddPacked.i32(DXIL opcode 164,Dot4AddU8Packed), with overflow-safeselect(sum < acc, u32::MAX, sum)whenv.clampis set.v.clampsaturation onv_dot4_i32_i8andv_dot4c_i32_i8: emitsdot4AddPacked.i32(0, a, b)(bounded within[-65024, +65536]) and saturatesdot + accin 64-bit arithmetic before truncating toi32.v_dot2_f32_f16andv_dot2c_f32_f16: converts operands vialegacyF16ToF32(handling both VOP3Popsel/opsel_hi+neg_hiand VOP2[15:0]/[31:16]slicing) and chainsfmad(tertiary.f32) matching RDNA2 rounding, usingwrite_fforv.clamp/v.omod.v_dot2_i32_i16andv_dot2_u32_u16: extracts halves viapacked_srcwith 64-bit clamping whenv.clampis set.v_dot8_u32_u4: unpacks and accumulates 8 nibble products with wrapping saturation whenv.clampis set.emit::valu_tests::packed_dot_products_and_clamps_execute_cleanlyincrates/victory-shader/src/emit/valu_tests.rs.Testing
cargo test -p victory-shader --locked packed_dot_products_and_clamps_execute_cleanly -- --test-threads=1: 1 passed, 0 failed.cargo test -p victory-shader --locked -- --test-threads=1: 244 passed, 4 failed, 3 ignored. All 4 failures are pre-existing baseline failures on this adapter (stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,synthetic_tests::gathers_at_a_level_match_the_hardware,valu_tests::fspx_programs_run_with_the_hardwares_dot_productswhich also fails identically onmain940d32f, andvalu_tests::image_atomics_of_64_bits).cargo clippy -p victory-shader --all-targets --lockedand--all-features: clean on all modified code (1 pre-existingneedless_range_loopwarning atlower.rs:1009).cargo test -p xtask --locked: 6 passed, 0 failed (repository_passes_policy).AI use
mainand verifying hardware/WARP execution tests.Closes part of #740.
@MamaLeVrai on GitHub · 2026-11-25 07:57 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head
cecd8e77intomain940d32fin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with--all-features: clean.cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (mainalone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
@sinan-cmyk on GitHub · 2026-11-25 10:57 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
cecd8e77ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 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 on GitHub · 2026-11-25 13:28 UTC · original · edited 2026-11-25 22:20 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/bitcode.rsandemit/valu_tests.rs). It will be reviewed again once it is rebased.From the earlier needs-work note, still open: a source or a distinguishing test for fused rounding in
v_dot2_f32_f16, splitting the Intel Arc workaround into its own PR with a repro, and a green CI.Generated by Claude Code
@UnkwnDev on GitHub · 2026-11-25 15:35 UTC · original · edited 2026-11-25 15:47 UTC
Updated in
cf43fda230c8to address the review points and add edge-case assertions:RDNA2 ISA semantics and comments:
V_DOT2_F32_F16/V_DOT2C_F32_F16: per the AMD RDNA2 Instruction Set Architecture manual (VOP3P / VOP2 dot-product definitions), each packed f16 input pair (including denormals) is converted to f32 without precision loss, then accumulated with two chained f32 fused multiply-adds (fma(a0, b0, c)followed byfma(a1, b1, inner)). In DXIL,legacyF16ToF32decodes f16 including subnormals (whereas SM 6.4f16arithmetic may flush),fmadsupplies the fused rounding, andwrite_fappliesv.clamp(saturate to[0.0, 1.0]) andv.omod.neg/neg_hihandling: VOP2 encoding (0x02) has noneg/absmodifiers; VOP3v_dot2c_f32_f16carries operand-widev.negapplied to both halves ofsrc0orsrc1(if !is_vop3p); VOP3Pv_dot2_f32_f16splits low/high halves acrossv.neg/v.neg_hi. Also fixed a double-negation bug onv_dot2_f32_f16wherefsrcalready appliedv.neg[2]before an unconditional extra negation indot_productcancelled it out; explicitv.neg >> 2negation is now restricted tov_dot2c_f32_f16.clamp=1saturates signed results to[i32::MIN, i32::MAX]via 64-bit bounds clamping (sat_64/sat_i32_add) and unsigned results tou32::MAX(sat_u32_add, since max unsigned 4x8 / 8x4 dot products stay below 260,101 and overflow iffsum < acc).Constant dot4 expansion for Intel Arc IGC:
Module::eval_u32andLower::dot4_packed/Lower::dot4_constsov_dot4_i32_i8,v_dot4_u32_u8, andv_dot4c_i32_i8expand constant multiplicands in scalar arithmetic instead of emittingdx.op.dot4AddPackedwith a constant operand, avoiding Intel Arc IGC's 16-bit constant broadcast miscompilation.Expanded
packed_dot_products_and_clamps_execute_cleanlyassertions:i32::MIN/i32::MAXsaturation onv_dot2_i32_i16,u32::MAXsaturation onv_dot2_u32_u16andv_dot8_u32_u4, negated accumulator and low-half operands onv_dot2_f32_f16(2.0and-4.0), f16 denormals (0x0001,0x03FF), and constant dot4 multiplicands acrossv_dot4_i32_i8,v_dot4_u32_u8, andv_dot4c_i32_i8.Verified after the final edit:
cargo test -p victory-shader --locked packed_dot_products_and_clamps_execute_cleanly -- --nocapture --test-threads=1: passed (Arc A770 hardware + WARP).cargo test -p victory-shader --locked fspx_programs_run_with_the_hardwares_dot_products -- --nocapture --test-threads=1: passed (Arc A770 hardware + WARP).cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (exit 0).cargo test -p xtask --locked: 6 passed, 0 failed.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.