Shaders: lower v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8, and v_mqsad_u32_u8 in pure 32-bit DXIL #2097
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!2097
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@geiyiliyabumo on GitHub · 2026-11-25 04:50 UTC · original
geiyiliyabumo:feat/shader-v-qsad-mqsad→main· +218 −11 · 2 files · 1 commits · openSummary
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)@upipibi on GitHub · 2026-11-25 05:05 UTC · original
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).
@sinan-cmyk on GitHub · 2026-11-25 08:52 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 10:36 UTC · original
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
@fuzeofficlal on GitHub · 2026-11-26 01:42 UTC · original
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.