Shaders: hardware test for the scalar add/sub carry chain and the SOPK forms #1875

Closed
github-bot wants to merge 1 commit from gh-pr/1875/head into gh-pr/1875/base
Owner

@⁠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 merging

s_add_u32, s_sub_u32, s_add_i32, s_sub_i32, s_addc_u32, s_subb_u32, s_addk_i32 and s_mulk_i32 are lowered in lower.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, then s_addk_i32/s_mulk_i32 with four immediates (sign-extended). Expected values come from wrapping_* and a u64 sum in Rust. Adds a small sopk encoder next to sop2.

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 for x86_64-pc-windows-msvc, but could not run it locally: the shader test module is Windows-only.

🤖 Generated with Claude Code

**@⁠LouisRiverstone** on GitHub · 2026-11-24 23:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1875) `LouisRiverstone:shaders/s-add-sub-carry-test` → `main` · +90 −0 · 1 files · 1 commits · closed without merging `s_add_u32`, `s_sub_u32`, `s_add_i32`, `s_sub_i32`, `s_addc_u32`, `s_subb_u32`, `s_addk_i32` and `s_mulk_i32` are lowered in `lower.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, then `s_addk_i32`/`s_mulk_i32` with four immediates (sign-extended). Expected values come from `wrapping_*` and a `u64` sum in Rust. Adds a small `sopk` encoder next to `sop2`. 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 for `x86_64-pc-windows-msvc`, but could not run it locally: the shader test module is Windows-only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:22 +00:00
github-bot closed this pull request 2026-11-26 04:47:22 +00:00
Author
Owner

@⁠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_rdna2 in crates/victory-shader/src/emit/valu_tests.rs covers s_add/sub_u32/i32, the 64-bit carry and borrow chains through SCC (s_addc_u32, s_subb_u32, checked on the high dword), and s_addk_i32/s_mulk_i32 with sign-extended immediates. I checked the GFX10 opcodes (SOP2 0x00 to 0x05; SOPK 0x0f, 0x10) and the sopk encoding (0xB000_0000 | op<<23 | sdst<<16 | simm16). The SOPK forms overwrite s0 only after build_valu_cs has already copied it to v1, so the inputs are intact. The expected carry is (a + b) >> 32 and the borrow is a < 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

**@⁠Marvisak** on GitHub · 2026-11-25 07:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1875#issuecomment-7155861354) <!-- victory-triage v1 head=124e45b2ffd792647bbd80b4f3bf031a42310ed3 verdict=merge-candidate at=2026-11-25T07:26:24Z --> Automated triage for the maintainers. This is a test-only change: `s_add_sub_carry_chain_and_k_forms_match_rdna2` in `crates/victory-shader/src/emit/valu_tests.rs` covers `s_add/sub_u32/i32`, the 64-bit carry and borrow chains through SCC (`s_addc_u32`, `s_subb_u32`, checked on the high dword), and `s_addk_i32`/`s_mulk_i32` with sign-extended immediates. I checked the GFX10 opcodes (SOP2 0x00 to 0x05; SOPK 0x0f, 0x10) and the `sopk` encoding (`0xB000_0000 | op<<23 | sdst<<16 | simm16`). The SOPK forms overwrite `s0` only after `build_valu_cs` has already copied it to `v1`, so the inputs are intact. The expected carry is `(a + b) >> 32` and the borrow is `a < 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](https://claude.ai/code)_
Author
Owner

@⁠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 124e45b2 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 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).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 11:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1875#issuecomment-7161765302) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 124e45b2 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 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).
Author
Owner

@⁠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_u32 and s_sub_i32 over edge pairs, and s_addk_i32 and s_mulk_i32 with five immediates. s_add_u32 and s_add_i32 are already on main. 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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1875#issuecomment-7175877161) 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_u32` and `s_sub_i32` over edge pairs, and `s_addk_i32` and `s_mulk_i32` with five immediates. `s_add_u32` and `s_add_i32` are already on `main`. 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1875
No description provided.