Repository navigation
Shaders: set SCC from the carry of s_addc_u32 and s_subb_u32 - #81
Merged
Merged
Conversation
Both returned no carry, so SCC was missing and a branch or select on a 64-bit scalar add or subtract failed to translate. They now share the carry logic of v_add_co_ci_u32 and v_sub_co_ci_u32.
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
alessiodeia
added a commit
to alessiodeia/VIctory
that referenced
this pull request
Nov 24, 2026
Adds host_waves: None to the Parts initializers added in main by Marvisak#37 and Marvisak#81, and disambiguates the duplicate mod tests introduced in host.rs on main. Co-authored-by: BlueKaiman <360454391+BlueKaiman@users.noreply.github.com>
suirentakamura
referenced
this pull request
in suirentakamura/victory-suiren
Nov 24, 2026
Shaders: set SCC from the carry of s_addc_u32 and s_subb_u32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.