Shaders: lower RDNA 2 quad-byte SAD instructions to DXIL #1662
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!1662
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1662"
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?
@THE-PRO-GAME on GitHub · 2026-11-24 20:34 UTC · original
THE-PRO-GAME:review/rdna2-qsad→main· +393 −16 · 3 files · 1 commits · openBase branch
Marvisak/VIctory:mainatffe310eb2098e52169f4c44db5ffdabf43a72622.Head
review/rdna2-qsadate8bbc120b6d87efeffd68701cafa6dd7413cc6fa.Changes
Lower
v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8andv_mqsad_u32_u8. These instructions compute four overlapping unsigned byte sums of absolute differences and add each to its corresponding accumulator. The masked forms exclude positions where the reference byte is zero. The lowering preserves isolated 16-bit or 32-bit accumulation, theCLMPsaturation rule and EXEC predication for every destination dword. AMD RDNA 2 ISA §12.12 · AMD RDNA 2 ISA §6.5This commit uses DXIL
i32arithmetic and the existing VALU operand and write paths. The original compute fixtures check window order, register pairs, expanded constants, boundary values and inactive lanes in guest Wave32 and Wave64.Individual validation
cargo test --workspace --lockedpassed 347 tests. The--all-featuresrun passed 351. Both had zero failures and six ignored tests.--all-targets --locked -- -D warningspassed with default and all features. All five targeted QSAD tests passed.dxvv1.9.2609) accepted all 16 emitted containers. D3D12 WARP and an NVIDIA GeForce RTX 3060 each matched the CPU reference for 64 dispatches across guest Wave32 and Wave64.cargo test -p victory-shader --locked qsad -- --nocapture. SetVICTORY_DXILto the full path to Microsoft'sdxil.dllto select the validator explicitly. Microsoft DXC releaseJoint validation
A separate local integration check combined both commits and exercised all six instructions in one synthetic compute shader. The test chains GLOBAL ADDTID reads through the three SAD instructions into LDS ADDTID, then reads the resulting dwords back after a group barrier. Inactive lanes keep their original destination values. The mixed shader matched the CPU reference for two cases per guest wave width on each backend.
The local merge kept both decoder tests as separate functions after resolving an overlap at their insertion point. The mixed-shader fixture is local to the integration check.
The combined targeted run passed all 11 tests. Microsoft
dxvv1.9.2609 accepted 28 containers. WARP and the RTX 3060 each matched the CPU reference for 82 dispatches, including four mixed-shader dispatches. The integrated workspace reported 353 passing tests with default features and 357 with all features, with zero failures and six ignored tests in each run. Strict Clippy passed for both configurations. The existing Xbox SDK differential tests returned early on this host.Related work
PRs #162 and #1197 cover ordinary SAD and MSAD. PR #1614 adds a general adapter differential fuzzer. The recent upstream review found no proposal that lowers these three quad forms. PR #162 · PR #1197 · PR #1614
Test scope and remaining validation
Execution verification used original synthetic compute shaders and a CPU reference derived from the public ISA. WARP and the RTX 3060 ran the translated DXIL. Native RDNA 2 execution in Wave32 and Wave64 remains pending, including a comparison of the masked and clamped cases against the same reference. Graphics stages and retail shader coverage were outside the test scope. VIctory asset policy
@Marvisak on GitHub · 2026-11-25 01:33 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 02:36 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
e8bbc12ontomainffe310e(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: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 125, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (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.