Shaders: lower v_sad_u8, v_msad_u8, v_sad_u16, and v_sad_u32 #1197
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!1197
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1197/head"
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?
@DenRakEiw on GitHub · 2026-11-24 16:24 UTC · original
shader/v-sad-family→main· +152 −0 · 2 files · 1 commits · closed without merging## Summary
Lowers RDNA2's unsigned sum-of-absolute-differences (SAD) instruction family in
crates/victory-shader/src/emit/lower.rs:v_sad_u8(VOP30x15A): sum of 4 unsigned byte absolute differences +src2accumulator.v_msad_u8(VOP30x171): masked 4-byte SAD — lanes wheresrc0's byte is0contribute0regardless ofsrc1(whilesrc1 == 0is not skipped).v_sad_u16(VOP30x15C): sum of 2 unsigned 16-bit absolute differences +src2accumulator.v_sad_u32(VOP30x15D):|src0 - src1|+src2accumulator.clamp(unsigned saturation tou32::MAXon accumulator overflow) across all four instructions, while rejecting invalidomod/abs/negmodifiers.Tests
Added end-to-end synthetic GFX10 compute shader test
v_sad_family_matches_rdna2incrates/victory-shader/src/emit/valu_tests.rs(validated viadxil.dlland executed on both host GPU and WARP), covering:v_sad_u8(normal accumulation,u32wraparound, andclampsaturation tou32::MAX)v_msad_u8(zero-masking onsrc0bytes vs. non-masking onsrc1 == 0)v_sad_u16(normal accumulation andclampsaturation)v_sad_u32(normal accumulation,u32wraparound, andclampsaturation)Verification
cargo test -p victory-shader v_sad_family: passed on Windows 11 x64 / NVIDIA GeForce RTX 5090 (Blackwell) + WARPcargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy:asset policy: 155 files okAI-assisted (Gemini 4 Neon).
@ghost on GitHub · 2026-11-24 16:34 UTC · original
Ran on RDNA2 hardware through vkd3d-proton on a Steam Deck (not native Windows): AMD Van Gogh, RADV 26.1.99, SteamOS 3.8.28, Proton 11.0-3 (wine-11.0) with its vkd3d-proton 212991fc. Windows MSVC test binary (rustc 1.100.0) built from head
8967035on mainffe310e. Your report lists NVIDIA and WARP, so this adds AMD hardware.v_sad_family_matches_rdna2passes: v_sad_u8, v_msad_u8, v_sad_u16 and v_sad_u32, wrapping and clamp cases.stub_pipeline_is_created, fails on main too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR).Not tested: native Windows AMD drivers; WARP (this setup has none, so the WARP leg ran on RADV too); whether the new test fails without the fix on this host.
AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@Zipettte on GitHub · 2026-11-24 18:00 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
8967035:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:34 UTC · original
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #162. Lowers v_sad_u8, v_msad_u8, v_sad_u16 and v_sad_u32, which the title does not use. The clean #162 covers the same instructions plus v_sad_hi_u8.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 00:19 UTC · original
The close note asks for anything #162 missed. It landed the wrapping forms, and the integer output path still refuses
clamp. I copiedv_sad_family_matches_rdna2unchanged from your89670357onto current main63bcca43. The fixture fails to lower at its first clampedv_sad_u8withinteger output modifiers. On the exact89670357head the same test passes, including the clampedSAD/MSADcases. Both runs used app-local WARP SM 6.6 and the DXIL validator.The remaining difference is unsigned saturation of the final accumulation. For four differences of 255 and an accumulator of
u32::MAX - 10, wrapping gives1009; the original clamped case returnsu32::MAX. Theclampforms are listed in the GFX1030 assembly reference.Pull request closed