Shaders: s_min/s_max set SCC when S0 is chosen, not when the result is non-zero #634
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/634"
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 Belobug/VIctory-Belobug-AMD. Originally posted by 11run11 on 2026-11-27T15:22:28Z.
s_min_{i,u}32ands_max_{i,u}32set SCC from their comparison: SCC = 1 when S0 is the value chosen. The lowering returned no SCC for them, so SCC fell back to "result ≠ 0".min(0, 5)therefore gave SCC 0 instead of 1, andmax(0, 5)gave SCC 1 instead of 0. Anys_cselect,s_cbranch_scc*or carry-in that reads SCC after one of these took the wrong side.The change
emit/lower.rs: the min/max arm returns its comparison as SCC (Some(t)), as the add/sub arms do with their carry.TRANSLATOR_VERSION2 → 3, because programs that read that SCC translate differently.scalar_min_max_set_scc_when_the_first_source_is_chosen(emit/valu_tests.rs) checks all four ops on six input pairs, including results of 0 with S0 chosen and signed/unsigned edges. It fails before the change (hardware: s_min_i32 0x0, 0x5, left: 0, right: 1) and passes after.Tested
Windows 11, RX 9070 XT, Rust 1.98.1.
cargo test -p victory-shader: 303 passed, 0 failed on hardware and WARP.size_tests::the_record_count_of_a_structured_buffer_read_by_index, crashes the test process (STATUS_ACCESS_VIOLATION) on this machine both with and without this change, so I skipped it. It looks like a driver issue, not related to this change.The bug was first reported as AvatarManz #404. This implementation is written independently from the ISA definition.
Not included
v_readlane_b32/v_writelane_b32should use only S1[4:0] or S1[5:0] as the lane. That touches the cross-wave exchange paths and needs separate work.CI
Belobug's own
ci.yml, unmodified, passes on this branch in my fork (Clippy with-D warnings, default and diagnostics tests): https://github.com/11run11/VIctory-Belobug-11run/actions/runs/46028870175 (commit13388d9).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.