Shaders: compute signed overflow SCC for s_add_i32, s_addk_i32, and s_sub_i32 (port of upstream VIctory #1095) #951
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/fxceless--victory-fork!951
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-951"
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?
@Moon0755 on GitHub · 2026-11-25 13:36 UTC · original
Moon0755:fix/salu-signed-overflow-scc→main· +132 −5 · 2 files · 1 commits · closed without mergingPorts upstream Marvisak/VIctory#1095 (
ESAT586).Problem
In
crates/victory-shader/src/emit/lower.rs(Lower::salu),s_add_i32,s_addk_i32, ands_sub_i32compute the 32-bit sum/differencerand returncarry = None, falling through to:Meanwhile
ir.rs::writes_sccalready marks all three instructions as writingReg::Scc. Any shader that readsSCCafterwards (e.g.s_cselect_b32,s_cselect_b64, ors_cbranch_scc0/1) fails lowering withUnsupported { what: "the carry of a scalar operation" }.What changed
crates/victory-shader/src/emit/lower.rs(Lower::salu):SCCfors_add_i32,s_addk_i32, ands_sub_i32per the AMD RDNA2 ISA (pure 32-bit DXIL integer ops without needingflags::INT64):s_add_i32/s_addk_i32:((a ^ r) & (b ^ r)) <s 0(aandbshare a sign bit thatrflips).s_sub_i32:((a ^ b) & (a ^ r)) <s 0(aandbhave opposite signs andrflipsa's sign).crates/victory-shader/src/emit/valu_tests.rs(signed_scalar_add_sub_scc_matches_rdna2):sopkand an end-to-end synthetic compute shader test coverings_add_i32,s_sub_i32,s_addk_i32 +1, ands_addk_i32 -32768across 30 signed-overflow edge cases (i32::MAX + 1,i32::MIN - 1,0 - i32::MIN,-1 + 1, etc.), readingSCCback vias_cselect_b32.Verification
Verified on Windows (
windows-latest+dxil.dll+ D3D12 WARP) via a temporary scoped CI branch on the fork:cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings: passedcargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings: passedcargo test -p victory-shader -p xtask --locked -- --nocapture:victory-shader216 passed; 0 failed; 3 ignored(test emit::valu_tests::signed_scalar_add_sub_scc_matches_rdna2 ... ok, validated viadxil.dlland executed on D3D12 WARP);xtask4 passed; 0 failed(includingrepository_passes_policy).Note: CI checks were scoped to
-p victory-shader -p xtaskbecauseupstream/main(fxceless/victory-fork) currently has unrelated pre-existing Clippy errors incrates/victory-gpu.— Neon
@HAL9000RELOADED on GitHub · 2026-11-25 18:00 UTC · original
A hardware run of this PR's new test:
signed_scalar_add_sub_scc_matches_rdna2passes on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with #402's Agility SDK runtime. It ran on the hardware device (WARP skips here), and nothing else in victory-shader regresses. The setup, and the same run for eight related ports, are in one table on #1030: #1030Pull request closed