Shaders: v_cmp_f/v_cmp_tru on floats emit fcmp false/true, which removes the WARP device (fix on a fork) #832
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#832
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 11:49 UTC · original
What's wrong
The float compares that are always false or always true are lowered to LLVM's constant predicates. The four instructions are
v_cmp_f_f32,v_cmp_tru_f32,v_cmp_f_f16andv_cmp_tru_f16. Incrates/victory-shader/src/emit/lower.rs, the compare lowering maps:"f"topred::FALSE, emittingfcmp false;"tru"topred::TRUE, emittingfcmp true.DXC folds those predicates away, so drivers never see them from it. WARP removes its device at the first dispatch of a pipeline that contains one. The dispatch fails with "The GPU device instance has been suspended".
A removed device stays removed for the whole process, so every later pipeline and dispatch on WARP fails as well. The DXIL validator accepts the shader, and the hardware adapter runs it (RTX 5080, driver 616.92).
The integer forms
v_cmp_f_*andv_cmp_t_*are already lowered as constants (self.lane(inst, Some(op == "t"))), and they run on both.This may be one way WARP loses its device on real shaders. It could matter for #653, where WARP removes its device during world load, but I haven't checked whether the title's shaders contain these instructions.
Repro
v_cmp_f_f32_e64 s20, v1, v2, thenv_cndmask_b32_e64 v0, 0, 1, s20, with any operands:v_cmp_tru_f32,v_cmp_f_f16andv_cmp_tru_f16behave the same, with 1 thread or many.v_cmp_f_i32,v_cmp_t_i32and every other float compare run fine.Fix
e04929d, onmain(ffe310e), 0 commits behind it. Three files:lower.rs,bitcode.rsandvalu_tests.rs.What changed:
fandtruare now constants, false and true, the same way the integer compares do it, before any operand is read. The RDNA2 ISA defines them as false and true whatever the operands, NaNs included.pred::FALSEandpred::TRUEstay in the table, marked unused, with a note on why they aren't emitted.Test
float_compares_that_are_always_false_or_true, invalu_tests.rs:main, WARP's dispatch fails:warp: dispatch failed: The GPU device instance has been suspended. With the fix it passes on both.How it was found
I swept every 32-bit VALU instruction the translator lowers on the hardware adapter against WARP. Each ran on about 400 edge-case inputs, one per thread, and the results were compared bit for bit. 200 instructions ran. These four were the only ones that removed a device.
With the fix, all 62 compares run and agree on both. The other differences were small:
v_sin_f32andv_sin_f16on the tiniest inputs. For example,v_sin_f32(0x00800000)gives 0 on the RTX 5080 and0x01c90fdbon WARP. Both are within D3D's tolerance for sin.v_med3_f16(+0, −0, 1)gives +0 on the RTX 5080 and −0 on WARP.v_med3_f32agreed on every case.Results
On Windows 11 with Rust 1.98.1 and an RTX 5080 (driver 616.92), using the CI's own commands:
cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.rustfmt --edition 2024 --checkon the changed files: clean on our changes (lower.rskeeps the three diffs it already has onmain, in its test module).cargo xtask policy: 154 files ok.PR creation is limited to collaborators right now, so this is an issue with the branch. I can open a PR when it reopens.
No game files used.
@26dwh7yy8g-rgb on GitHub · 2026-11-24 12:10 UTC · original
Reproduced and fixed on an RTX 4060 desktop (driver 616.92), Windows 11 Pro 26200, Rust 1.98.1, WARP 10.0.26100.9818.
main(ffe310e) with only yourvalu_tests.rs: the new test fails 3/3 on WARP (dispatch failed, device suspended). The hardware part passes.e04929d: passes 3/3 on both.cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored (4 of the passes arediff_tests, which skip themselves here). Both clippy variants andcargo xtask policyare clean.maintogether with #830 without conflict:victory-shaderlib tests 122 passed, 0 failed, 1 ignored, both clippy variants clean.No game data used. AI-assisted (Claude Code).
@MamaLeVrai on GitHub · 2026-11-24 19:42 UTC · original
@Peppacodes your fix for this issue is now in a pull request, #1603, together with the three others of yours (#762, #764, #765, #832): the branches are merged as they are, with your commits and your name unchanged, onto
mainffe310e. Clippy (both runs) andcargo test --workspacepass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1603. AI-assisted (Claude Code); no game data.@Marvisak on GitHub · 2026-11-25 03:49 UTC · original
Automated triage for the maintainers. This is fixed on
main. Commit77053a0("Shaders: accuracy fixes for discards, f16 rounding, denormals, med3 and signed zeros", now onmain) changedLower::compareincrates/victory-shader/src/emit/lower.rs: floatfandtrucompares now emit constant false/true (self.s.m.bool(op == "tru")) instead offcmp false/fcmp true. The branch's regression test (float_compares_that_are_always_false_or_true) could still be sent as a PR if wanted.This issue will be closed in 48 hours unless the reporter replies or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code