Shaders: lower v_sad_u8/u16/u32, v_sad_hi_u8 and v_msad_u8 (port of VIctory#162) #57
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr!57
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-57"
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?
@lcg007xd-c on GitHub · 2026-11-25 20:57 UTC · original
lcg007xd-c:port/sad-lowering→main· +109 −0 · 1 files · 3 commits · openStacked on #56. This branch contains that PR's commit, because it uses its
lowers_valutest helper. Once #56 is merged, this diff is the single SAD commit.What
v_sad_u8,v_sad_hi_u8,v_sad_u16,v_sad_u32andv_msad_u8(VOP3 0x15A-0x15D, 0x171) had no lowering, so a shader that used them failed to translate. Each one is nowsrc2plus the sum of|a - b|over the operands' bytes, halves or whole dwords, wrapping at 32 bits:v_sad_hi_u8adds the byte sum shifted into the high half.v_msad_u8skips a byte whose reference byte (src1) is 0.Port
Cherry-pick (
-x) ofgithub.com/Marvisak/VIctory@5d6889efrom upstream. Rareuncommon is still the commit author. The only conflict was a test added next to VItoriaBr'sbuffer_cache_invalidations_lower_as_no_ops. Both tests are kept.Test
sums_of_absolute_differences_lowerlowers all five. With only this commit's match arm reverted, it fails, and with it, it passes.How this was checked (Linux, no Windows PC or game files)
cargo clippy -p victory-core -p victory-pe -p victory-pipeline -p victory-shader -p victory-formats -p victory-game -p xtask --all-targets --locked -- -D warnings, thencargo teston the same crates (rebased on currentmain).cargo clippywith the same crates and--target x86_64-pc-windows-msvc(check only, no link) is clean.lower.rshas the same number ofrustfmtdifferences before and after this change, so the added code is rustfmt-clean.Not tested: Windows runtime, GPU, and the game itself. In particular, the numeric results were not run on a GPU here. The new test only proves the instructions now lower, and Windows CI validates the module where
dxil.dllis available.🤖 Generated with Claude Code
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.