Shaders: s_min and s_max set SCC to their comparison #1891

Manually merged
github merged 1 commit from github-bot/gh-1891 into main 2026-11-29 02:17:26 +00:00 AGit
Owner

@⁠Melow-code on GitHub · 2026-11-29 01:46 UTC · original
Melow-code:scalar-min-max-scc → main · +29 −2 · 2 files · 1 commits · merged 2026-11-29 02:13 UTC

Fixes the flag left by the scalar minimum and maximum.

What it changes

s_min_i32, s_min_u32, s_max_i32 and s_max_u32 set SCC to the comparison of their operands (RDNA 2 ISA: SCC = (S0 < S1), SCC = (S0 > S1)). The lowering set it to "the result is not zero", so an s_cselect or a branch behind one could take the wrong side: s_min_u32 s0, 5, 3 gave 1.

Two lines in lower.rs, and a test of the four opcodes: zero results, equal operands, signed and unsigned orders.

Credit: the fix and the test table are from TaynanGT/Vice-Tay 3c83a339 (reported in Belobug/VIctory-Belobug-AMD#634 and avatarmanz/VIctory-7900XTX#404). The same defect was in #71, reviewed and then closed by its author.

How it was tested

  • GPU and profile: RTX 2080 Ti (driver 621.40, 32-lane waves), Windows 11 build 26300. Shader test on the card, not a run of the game; the game was open on the same card meanwhile.
  • Before: scalar_min_max_pass_the_comparison_to_conditional_select fails on the card (hardware, opcode 0x6, case 0: 0 instead of 1).
  • After: it passes.
  • Wave sizes: 32 lanes only.
  • cargo test -p victory-shader --lib on Linux, on main 0338ec6c: 268 passed, 0 failed. The card test was run on f9dfb76f with the same change (the test above is Windows only). The test programs were cross-built with Rust 1.99.1 GNU, not the pinned 1.98.1 MSVC. The whole Windows suite was not completed on this branch.
  • No visible change in the game has been measured.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #71 (closed)

🤖 Generated with Claude Code

**@⁠Melow-code** on GitHub · 2026-11-29 01:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1891) `Melow-code:scalar-min-max-scc` → `main` · +29 −2 · 2 files · 1 commits · merged 2026-11-29 02:13 UTC Fixes the flag left by the scalar minimum and maximum. ## What it changes `s_min_i32`, `s_min_u32`, `s_max_i32` and `s_max_u32` set SCC to the comparison of their operands (RDNA 2 ISA: `SCC = (S0 < S1)`, `SCC = (S0 > S1)`). The lowering set it to "the result is not zero", so an `s_cselect` or a branch behind one could take the wrong side: `s_min_u32 s0, 5, 3` gave 1. Two lines in `lower.rs`, and a test of the four opcodes: zero results, equal operands, signed and unsigned orders. Credit: the fix and the test table are from TaynanGT/Vice-Tay 3c83a339 (reported in Belobug/VIctory-Belobug-AMD#634 and avatarmanz/VIctory-7900XTX#404). The same defect was in #71, reviewed and then closed by its author. ## How it was tested - GPU and profile: RTX 2080 Ti (driver 621.40, 32-lane waves), Windows 11 build 26300. Shader test on the card, not a run of the game; the game was open on the same card meanwhile. - Before: `scalar_min_max_pass_the_comparison_to_conditional_select` fails on the card (`hardware, opcode 0x6, case 0`: 0 instead of 1). - After: it passes. - Wave sizes: 32 lanes only. - `cargo test -p victory-shader --lib` on Linux, on main 0338ec6c: 268 passed, 0 failed. The card test was run on f9dfb76f with the same change (the test above is Windows only). The test programs were cross-built with Rust 1.99.1 GNU, not the pinned 1.98.1 MSVC. The whole Windows suite was not completed on this branch. - No visible change in the game has been measured. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #71 (closed) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
It was whether the result is zero, so a select or branch behind them could
take the wrong side. After TaynanGT/Vice-Tay 3c83a339; the same defect was
reported in trustno1-coder/VIctory-NVIDIA#71.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 01:54:17 +00:00
github-bot changed title from [pr-fix] Shaders: s_min and s_max set SCC to their comparison to Shaders: s_min and s_max set SCC to their comparison 2026-11-29 02:01:23 +00:00
github manually merged commit 76a531134c into main 2026-11-29 02:17:26 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1891
No description provided.