Shaders: set SCC from the carry of s_addc_u32 and s_subb_u32 #81
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/81"
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?
Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:17:28Z.
What
s_addc_u32ands_subb_u32now set SCC to the carry (borrow) out, computed the wayv_add_co_ci_u32andv_sub_co_ci_u32already compute theirs. The carry logic moves into one helper,add_sub_carry, which the scalar and vector paths share (the vector path's operations are unchanged).Why
Both scalar instructions returned no carry, so SCC became
Missing("the carry of a scalar operation"). Any 64-bit scalar add or subtract whose result feeds a branch or a select on SCC (s_add_u32->s_addc_u32->s_cselect_b32/s_cbranch_scc1) could not be translated: the shader failed withUnsupportedinstead of becoming DXIL. The carry out of the high dword isa + b + cin >= 2^32for add, andb + cin > afor subtract.Tested
Linux x86_64, from the repository root:
cargo test -j4 -p victory-shader: 52 passed, 0 failed.emit::lower::tests::a_scalar_carry_chain_reaches_the_select: lowers synthetic compute programs (s_add_u32->s_addc_u32->s_cselect_b32-> branch, ands_sub_u32->s_subb_u32->s_cselect_b32-> branch). Without the fix it fails withUnsupported { offset: 24, what: "the carry of a scalar operation" }; with it, it passes. Synthetic buffers only.cargo clippy -j4 -p victory-shader --tests: nothing inlower.rs; the one warning (constant_colorunused inemit/mod.rs) is already on main.rustfmt --check --edition 2024 crates/victory-shader/src/emit/lower.rs: clean.Not run: the Windows runtime and any GPU. The test checks that the program now translates; it does not execute the emitted DXIL, so the carry value itself rests on the formula check above and on the vector path using the same logic.
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:23:19Z.
Tested
a2f5f43stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.cargo test --workspace: 156 passed, 0 failed, 3 ignored; merge with #39 clean.#[test]in the diff) and they are part of that run.AI-assisted (DeepSeek V4.1 Flash coding agent).