Shaders: lower v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8, and v_mqsad_u32_u8 in pure 32-bit DXIL #2095
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2097"
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?
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T04:50:43Z.
Summary
v_qsad_pk_u16_u8(0x172),v_mqsad_pk_u16_u8(0x173), andv_mqsad_u32_u8(0x175) incrates/victory-shader/src/emit/lower.rsusing pure 32-bit DXIL without enablingInt64/WIDE_OPS.clamp(unsigned 16-bit saturation forpk_u16_u8and unsigned 32-bit saturation foru32_u8), and rejects unsupportedabs/neg/omod/op_selmodifiers.crates/victory-shader/src/emit/valu_tests.rscovering all 4 sliding windows across thesrc0_lo/src0_hiboundary, zero-reference masking vs unmasked behavior, modulo wraparound and saturation, overlapping destination/accumulator VGPRs, and verifyingInt64is not set.Verification
cargo xtask policy: passedcargo clippy -p victory-shader --tests -- -D warnings: passedcargo test -p victory-shader --lib quad_sad_vop3 -- --test-threads=1andsums_of_absolute_differences_lowerwith Microsoftdxil.dll: all passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:56:55Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib quad_sad— passed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean pure-32-bit DXIL lowering of
v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8, andv_mqsad_u32_u8, verified end-to-end on hardware and WARP. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T05:05:27Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
562b92e.victory-shader: 246 passed, 3 failed, 3 ignored. The newquad_sad_vop3_tracks_register_dwords_and_rejects_modifiersandquad_sad_vop3_wraps_or_saturates_every_windowpass. The 3 failures are #1744's NVIDIA failures onmain. Same asmainon this hardware.Overlap, from reading: #1662 (open, conflicting with
main) lowers the RDNA 2 quad-byte SAD instructions too, and #1672 (closed) had this PR's three.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:16:26Z.
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_qsad_pk_u16_u8, v_mqsad_pk_u16_u8, v_mqsad... — quad/media saturating-add packing ops.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T08:52:24Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
562b92ebontomain940d32f(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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:36:51Z.
Automated triage for the maintainers.
Adds
quad_sadinemit/lower.rsforv_qsad_pk_u16_u8,v_mqsad_pk_u16_u8andv_mqsad_u32_u8: four sliding byte windows over the 64-bit src0 against src1, with masking of zero reference bytes for themqsadforms and 16-bit or 32-bit accumulators. It reads the accumulator dwords before the guarded writes, so overlapping destination and accumulator registers are safe. It refuses abs/neg/omod/op_sel. I checked the window layout against the register widths already ingfx10/fields.rsand recomputed the test SADs ([416, 684, 42, 526] unmasked, 321 for masked window 0). They match AMD's public RDNA ISA description, which would be worth citing. CI passes, and an independent NVIDIA run reports the new tests passing.Minor:
pairtreats a float inline constant as a zero high dword. Overlaps the conflicting #1662, and thetry_build_valu_cschange conflicts trivially with #2092.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:42:45Z.
Code review and RTX 5090 + WARP + DXIL verification at head
562b92ebc11amerged ontomain(63bcca43c6a0):xtask):crates/victory-shader/src/emit/lower.rsreaches524,743bytes (+455B over the524,288-byte limit), causingcargo xtask policyto fail (exit 1).pairclosure insidequad_sad(lower.rs:6724-6733) duplicates existingself.src64_dwords(inst, k)(lower.rs:6855) — reusingsrc64_dwordsor movingquad_sad/unsigned_abs_diffto a submodule underemit/lower/will clear the 512 KiB gate cleanly with headroom.lower.rs:6712-6805):abs/neg/omod/opsel, handles 7-byte sliding windows across 64-bit sources, skips zero reference bytes onv_mqsad_*, saturates 16-bit packed (sum > 0xFFFF) and 32-bit (sum < acc) accumulators underv.clamp, and writes all destinations underguard(EXEC).cargo clippy(default +--features diagnostics): 0 warnings;quad_sad(2/2, pure 32-bit withoutInt64),emit::lower::tests(33/33), andemit::semantics_tests(34/34 on both RTX 5090 and WARP, 1 ignored) all passed.Lowering and GPU execution are solid — just needs moving out of
lower.rs(and reusingsrc64_dwords) to satisfy the 512 KiB policy check.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.