Shaders: hardware test for the scalar add/sub carry chain and the SOPK forms #1875
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!1875
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1875/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?
@LouisRiverstone on GitHub · 2026-11-24 23:58 UTC · original
LouisRiverstone:shaders/s-add-sub-carry-test→main· +90 −0 · 1 files · 1 commits · closed without mergings_add_u32,s_sub_u32,s_add_i32,s_sub_i32,s_addc_u32,s_subb_u32,s_addk_i32ands_mulk_i32are lowered inlower.rs, with the carry going through SCC, but no hardware test ran them.New test
s_add_sub_carry_chain_and_k_forms_match_rdna2: the four plain forms over 25 pairs, then a 64-bit add (s_add_u32+s_addc_u32) and subtract (s_sub_u32+s_subb_u32) over 225 cases each, reading the high dword so the carry or borrow shows, thens_addk_i32/s_mulk_i32with four immediates (sign-extended). Expected values come fromwrapping_*and au64sum in Rust. Adds a smallsopkencoder next tosop2.Test only, no production change.
Verify:
cargo test -p victory-shader s_add_sub_carry(Windows, hardware GPU or WARP). I type-checked it with clippy forx86_64-pc-windows-msvc, but could not run it locally: the shader test module is Windows-only.🤖 Generated with Claude Code
@Marvisak on GitHub · 2026-11-25 07:26 UTC · original
Automated triage for the maintainers.
This is a test-only change:
s_add_sub_carry_chain_and_k_forms_match_rdna2incrates/victory-shader/src/emit/valu_tests.rscoverss_add/sub_u32/i32, the 64-bit carry and borrow chains through SCC (s_addc_u32,s_subb_u32, checked on the high dword), ands_addk_i32/s_mulk_i32with sign-extended immediates. I checked the GFX10 opcodes (SOP2 0x00 to 0x05; SOPK 0x0f, 0x10) and thesopkencoding (0xB000_0000 | op<<23 | sdst<<16 | simm16). The SOPK forms overwrites0only afterbuild_valu_cshas already copied it tov1, so the inputs are intact. The expected carry is(a + b) >> 32and the borrow isa < b, which is the ISA's definition.This inserts at the same place in the file as #1874 and #1876, so whichever merges later needs a trivial rebase.
CI: passing.
Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 11:59 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
124e45b2ontomain940d32f(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 22:03 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing as covered by #2015, which runs the same add/addc and sub/subb chains over 625 wide inputs (low dword, high dword and final carry),
s_sub_u32ands_sub_i32over edge pairs, ands_addk_i32ands_mulk_i32with five immediates.s_add_u32ands_add_i32are already onmain. The model here is right.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed