Shaders: compute exact SCC for s_lshl{1..4}_add_u32 and s_min/s_max_{u32,i32} #350
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/350"
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 fxceless/victory-fork. Originally posted by AscilCH on 2026-11-24T23:49:46Z.
Problem
In
crates/victory-shader/src/emit/lower.rs,Lower::scalarreturnedcarry = Nonefor:s_lshl1_add_u32,s_lshl2_add_u32,s_lshl3_add_u32,s_lshl4_add_u32s_min_u32,s_max_u32,s_min_i32,s_max_i32Because
carrywasNone, all eight instructions fell through to the defaultSCC = (r != 0)path:s_lshl{1..4}_add_u32, any subsequents_addc_u32(used in 64-bit scalar address arithmetic) receivedSCC = 1whenever the low 32-bit result was non-zero (adding a spurious+4 GiBto the high word) andSCC = 0when an overflow wrapped the low word to0.s_min/s_max_{u32,i32},SCCreflectedr != 0instead of whethersrc0won the comparison (src0 < src1orsrc0 > src1), breakings_cselect_b32/s_cbranch_scc*consumers.Fix
s_lshl{1..4}_add_u32, compute the exact 32-bit unsigned carry-out((a >> (32 - shift)) != 0) || (r < (a << shift))and returnSome(carry).s_min_{u32,i32}ands_max_{u32,i32}, returnSome(t)wheretis thesrc0 < src1/src0 > src1comparison result already used forselect.emit::valu_tests::scalar_lshl_add_and_minmax_set_scccovering all fours_lshl{1..4}_add_u32+s_addc_u32combinations and all fours_min/s_max_{u32,i32}+s_cselect_b32combinations across signed/unsigned/zero/overflow/equal edge cases.Verification
cargo test -p victory-shader --locked scalar_lshl_add_and_minmax_set_scc: passed (hardware D3D12 + WARP +dxil.dll)cargo xtask policy: 169 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic tests only, no game data.)
Imported from fxceless/victory-fork. Originally posted by BTekV4 on 2026-11-25T00:48:45Z.
Tested this PR on top of
31714de(i.e. after yesterday's3bff182and31714demerges), with #376 for the per-pipeline diagnostics. Hardware: RTX 5070 Ti, Windows 11, direct D3D12. Same automated run for every build: the prologue, withApressed by a script so the world actually loads (~5000 draws/frame, 150 s).Result: no measurable change on this title.
missing-shader10,pipeline-refused7,mesh-pipeline-refused1 — identical to the same build without this PR.main+ #376):a8826150ef94847amain+ #376 + PR):378fb4f54b93f1f5The class this PR targets no longer shows up in the run. After the two commits merged yesterday, the
a whole-wave section step the simulation does not follow(15 occurrences) anda lane mask exchanged where not every lane runs(15) failures are gone. What remains is:a descriptor read only as data(pixel)a descriptor's address or format read as dataa lane mask exchanged where not every lane runsa lane mask holding lanes elsewhere read as datapipeline-refused, allE_INVALIDARG (0x80070057)on compute pipelinesSo this may be superseded — worth checking before merging, unless it covers forms this scene does not exercise (the test cases suggest it covers more than the prologue does).
Two practical notes:
31714dethis PR conflicts only incrates/victory-shader/src/emit/valu_tests.rs(a test file); the functional code applies cleanly, so a rebase is trivial.shader-diag.jsonl(34k records, 11.8 MB) are in #394.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.