Shaders: always-false and always-true float compares lower as constants #160
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!160
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-160"
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?
@Peppacodes on GitHub · 2026-11-24 22:03 UTC · original
Peppacodes:vf/fcmp-false-true→main· +50 −2 · 3 files · 1 commits · openv_cmp_f_{f32,f16}andv_cmp_tru_{f32,f16}lowered tofcmp falseandfcmp true(predicates 0 and 15).Why this matters
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_talready do.FALSEandTRUEstay 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 as4e17478) plus this commit, on Windows 11 with an RTX 5080:float_compares_that_are_always_false_or_true: f32 and f16, ordinary and NaN operands, on the hardware adapter and on WARP. Onmain, 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).
v_cmp_f_{f32,f16} and v_cmp_tru_{f32,f16} lowered to fcmp false and fcmp true (predicates 0 and 15). DXC folds those away, so drivers never see them from it, and WARP removes its device at the first dispatch of a pipeline that has one ("The GPU device instance has been suspended"). The hardware adapter (RTX 5080) runs them. A removed WARP device stays removed for the process, so everything after it fails too. They 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. Found with a sweep of every 32-bit VALU instruction on the hardware adapter against WARP: all 62 compares now run and agree on both. Test: float_compares_that_are_always_false_or_true, f32 and f16 with ordinary and NaN operands, on the hardware adapter and WARP. On main WARP's dispatch fails with the device suspended. (cherry picked from commit e04929d9d0c4815fc054f8793986894794b350dc)@DovisLe on GitHub · 2026-11-24 23:43 UTC · original
Tested on a Radeon 860M (RDNA 3.5) and WARP, at
21ad2df(base2119b0e).float_compares_that_are_always_false_or_truemain'slower.rsandbitcode.rswarp: 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.self.lane(inst, Some(op == "tru")), the same path the integerv_cmp_f/v_cmp_talready take, sov_cmpx_*still writes EXEC and the VOP3 forms still write their SGPR pair.No game files used.
AI-assisted (Claude).
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.