Shaders: always-false and always-true float compares lower as constants #160

Open
Peppacodes wants to merge 1 commit from upstream-pr/160 into main
Peppacodes commented 2026-11-24 22:03:21 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Peppacodes on 2026-11-24T22:03:21Z.


v_cmp_f_{f32,f16} and v_cmp_tru_{f32,f16} lowered to fcmp false and fcmp true (predicates 0 and 15).

Why this matters

  • DXC folds those predicates away, so drivers never see them coming from it.
  • WARP removes its device at the first dispatch of a pipeline that has one ("The GPU device instance has been suspended"). A removed WARP device stays removed for the process, so everything after it fails too.
  • The hardware adapter (RTX 5080) runs them.

The fix. These compares are false and true whatever the operands, NaNs included (RDNA2 ISA). So they now lower as constants, as the integer v_cmp_f / v_cmp_t already do. FALSE and TRUE stay in the predicate table, unused.

How it was found. A sweep of every 32-bit VALU instruction on the hardware adapter against WARP. With this change, all 62 compares run and agree on both.

Tested on this branch's base (2119b0e, the same tree as 4e17478) plus this commit, on Windows 11 with an RTX 5080:

  • New test float_compares_that_are_always_false_or_true: f32 and f16, ordinary and NaN operands, on the hardware adapter and on WARP. On main, WARP's dispatch fails with the device suspended.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • cargo test -p victory-shader -p victory-hle -p victory-loader --locked: 337 passed, 0 failed, 2 ignored. This was with the two other PRs from this account applied as well.

AI-assisted (Claude Code).

<!-- greyfinch-sync:fxceless/victory-fork:issue:6592305641 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/160). Originally posted by [Peppacodes](https://github.com/Peppacodes) on 2026-11-24T22:03:21Z. --- `v_cmp_f_{f32,f16}` and `v_cmp_tru_{f32,f16}` lowered to `fcmp false` and `fcmp true` (predicates 0 and 15). **Why this matters** - DXC folds those predicates away, so drivers never see them coming from it. - WARP removes its device at the first dispatch of a pipeline that has one ("The GPU device instance has been suspended"). A removed WARP device stays removed for the process, so everything after it fails too. - The hardware adapter (RTX 5080) runs them. **The fix.** These compares are false and true whatever the operands, NaNs included (RDNA2 ISA). So they now lower as constants, as the integer `v_cmp_f` / `v_cmp_t` already do. `FALSE` and `TRUE` stay in the predicate table, unused. **How it was found.** A sweep of every 32-bit VALU instruction on the hardware adapter against WARP. With this change, all 62 compares run and agree on both. **Tested** on this branch's base (`2119b0e`, the same tree as `4e17478`) plus this commit, on Windows 11 with an RTX 5080: - New test `float_compares_that_are_always_false_or_true`: f32 and f16, ordinary and NaN operands, on the hardware adapter and on WARP. On `main`, WARP's dispatch fails with the device suspended. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `cargo test -p victory-shader -p victory-hle -p victory-loader --locked`: 337 passed, 0 failed, 2 ignored. This was with the two other PRs from this account applied as well. AI-assisted (Claude Code).
DovisLe commented 2026-11-25 00:10:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by DovisLe on 2026-11-24T23:43:40Z.


Tested on a Radeon 860M (RDNA 3.5) and WARP, at 21ad2df (base 2119b0e).

build float_compares_that_are_always_false_or_true
this PR passes on the 860M and WARP
this PR's test with main's lower.rs and bitcode.rs the 860M gives the right answers; WARP fails with warp: dispatch failed: The GPU device instance has been suspended.

So AMD hardware, like the RTX 5080, runs fcmp false/fcmp true, and only WARP loses its device on them.

  • cargo test -p victory-shader --locked --lib: 211 passed, 0 failed, 2 ignored (main: 210 passed).
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.
  • The early return calls self.lane(inst, Some(op == "tru")), the same path the integer v_cmp_f/v_cmp_t already take, so v_cmpx_* still writes EXEC and the VOP3 forms still write their SGPR pair.

No game files used.

AI-assisted (Claude).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147727022 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/160#issuecomment-7147727022). Originally posted by [DovisLe](https://github.com/DovisLe) on 2026-11-24T23:43:40Z. --- Tested on a **Radeon 860M (RDNA 3.5)** and WARP, at `21ad2df` (base `2119b0e`). | build | `float_compares_that_are_always_false_or_true` | |---|---| | this PR | passes on the 860M and WARP | | this PR's test with `main`'s `lower.rs` and `bitcode.rs` | the 860M gives the right answers; WARP fails with `warp: dispatch failed: The GPU device instance has been suspended.` | So AMD hardware, like the RTX 5080, runs `fcmp false`/`fcmp true`, and only WARP loses its device on them. - `cargo test -p victory-shader --locked --lib`: 211 passed, 0 failed, 2 ignored (`main`: 210 passed). - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. - The early return calls `self.lane(inst, Some(op == "tru"))`, the same path the integer `v_cmp_f`/`v_cmp_t` already take, so `v_cmpx_*` still writes EXEC and the VOP3 forms still write their SGPR pair. No game files used. AI-assisted (Claude).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/160:upstream-pr/160'
git switch 'upstream-pr/160'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/160'
git switch 'upstream-pr/160'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/160'
git switch 'upstream-pr/160'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/160'
git switch 'main'
git merge --squash 'upstream-pr/160'
git switch 'main'
git merge --ff-only 'upstream-pr/160'
git switch 'main'
git merge 'upstream-pr/160'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!160
No description provided.