Shaders: lower VOP3 integer clamp saturation for add/sub ops #1478
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!1478
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1478/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?
@geiyiliyabumo on GitHub · 2026-11-24 18:18 UTC · original
geiyiliyabumo:fix/shader-vop3-int-clamp→main· +206 −17 · 2 files · 1 commits · closed without mergingSummary
Implements VOP3 integer \clamp\ saturation for RDNA2 / GFX10.3 integer add/sub instructions in \ictory-shader\ (tracking issue #1242, \VIC-BT-010).
Previously, \Lower::write_i\ rejected any integer VALU instruction with \.clamp, refusing valid clamped integer add/sub instructions emitted by console shaders.
Changes
@AnoHunted on GitHub · 2026-11-24 18:38 UTC · original
Independent NVIDIA hardware run. No game files were used.
Machine: Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, DXC
dxil.dll1.9.2609 (SDK 10.0.26100) validating.Applied on main (
ffe310e),cargo test -p victory-shader --features host -- --test-threads=1:vop3_unsigned_clamp_preserves_carry_and_borrow_out,vop3_unsigned_no_carry_add_sub_respect_clamp,vop3_signed_no_carry_add_sub_respect_clamp,v_add3_u32_wraps_on_double_carry) execute throughrun_cases/run_cases_with_outputon the RTX 5080 (and WARP) and all pass.Not tested: the in-game effect; AMD.
@marquezinii on GitHub · 2026-11-24 18:48 UTC · original
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
1905213.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 124 passed, 0 failed, 1 ignored.#1398 covers the same VIC-BT-010 item, so I ran each PR's tests against the other PR's code (tests copied in, everything else unchanged):
vop3_unsigned_clamp_preserves_carry_and_borrow_out,vop3_unsigned_no_carry_add_sub_respect_clamp,v_add3_u32_wraps_on_double_carryvop3_signed_no_carry_add_sub_respect_clampv_add_nc_i32isn't lowered therevop3_unsigned_add_sub_clampinteger output modifiers) only forv_add3_u32with clamp; the other 9 ops passSo the two agree on every value both produce on this hardware. Each one covers something the other doesn't: this PR adds signed
v_add/sub_nc_i32with clamp, and #1398 adds clampedv_add3_u32(saturating when either add carries). I also checked the signed saturation here: overflow when the sign ofbdisagrees with whether the result moved belowa, and the limit follows the sign ofa. That looks right.@wwwwwwww3333333 on GitHub · 2026-11-24 19:15 UTC · original
Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head
1905213on mainffe310e(clean merge).cargo test -p victory-shader --lib -- --test-threads=1: 124 passed, 0 failed, 1 ignored (main alone: 120 passed).v_add3_u32_wraps_on_double_carry,vop3_signed_no_carry_add_sub_respect_clamp,vop3_unsigned_clamp_preserves_carry_and_borrow_out,vop3_unsigned_no_carry_add_sub_respect_clampran on the hardware adapter and then on WARP, and passed on both. This adds an AMD result to the NVIDIA runs already posted.Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
@sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
1905213ontomainffe310e(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 124, 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).
@geiyiliyabumo on GitHub · 2026-11-24 21:07 UTC · original
Thanks @catminou4 for the macOS verification and review! Just a quick note on point #2: commit
1905213already includesvop3_signed_no_carry_add_sub_respect_clamptestingv_add_nc_i32andv_sub_nc_i32withclampon/off across positive/negative overflow and boundary cases — verified passing above by @AnoHunted (RTX 5080), @marquezinii (RTX 5070), @wwwwwwww3333333 (RX 6750 XT), @sinan-cmyk (RTX 4070 SUPER), and on our RX 9060 XT + WARP. Happy to rebase onto #1398 if #1398 lands first.AI-assisted; synthetic tests only, no game files.
@Marvisak on GitHub · 2026-11-25 00:40 UTC · original
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1398. clamp on VOP3 integer add/sub. The unsigned carry and no-carry code is the same as in #1398 (identical lines), which also guards descriptor tracing; the extra signed v_add_nc_i32/v_sub_nc_i32 are also in #92. Neither is used by the title.
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.
Pull request closed