Shaders: v_cmp_f and v_cmp_tru are constants (fcmp false/true removed WARP's device) #173

Open
github-bot wants to merge 1 commit from github-bot/gh-173 into main AGit
Owner

@⁠alexdeliu on GitHub · 2026-11-25 18:49 UTC · original
alexdeliu:fix/v-cmp-f-tru-constant → main · +32 −0 · 2 files · 1 commits · open

What

The always-false and always-true f32/f16 compares (v_cmp_f_f32, v_cmp_tru_f32, v_cmp_f_f16, v_cmp_tru_f16) now lower to the constants they mean, instead of fcmp false / fcmp true. This is the same change as upstream Marvisak/VIctory 77053a0. f64 has its own path (compare_f64) and is unchanged.

Why

A dispatch with fcmp false or fcmp true makes WARP remove its device ("The GPU device instance has been suspended"). The cross-device fuzzer (#129) lost WARP on all four opcodes. WARP is what a GPU-less CI runner has.

Tested

One machine: RX 9070 (RDNA4, 32.0.32029.2010), Ryzen 7 7700 iGPU (gfx1036, RDNA2, 32.0.21045.29003) and WARP. Windows 11 Pro 26200; VICTORY_DXIL = dxil.dll 1.8.2502.11. No game data.

New test v_cmp_f_and_tru_are_constants_and_keep_the_device: all four opcodes, including NaN operands, on every host. Like the other VALU tests, it runs on the hardware adapter and on WARP.

000ffdd this PR
RX 9070 fails: WARP's device removed passes
gfx1036 fails: WARP's device removed passes
VICTORY_WARP=1 fails: device removed passes

cargo test -p victory-shader --lib -- --test-threads=1:

000ffdd this PR
RX 9070 266 passed, 0 failed 267 passed, 0 failed
gfx1036 264 passed, 2 failed 265 passed, 2 failed (the two #2 wave-size tests, fixed by #110)
WARP 252 passed, 14 failed 253 passed, the same 14 failed

cargo clippy -p victory-shader --all-targets --locked: no new warnings (the same 10 as on main).

AI use: Claude Code (Claude Opus 5.5) found it with the fuzzer, ported the upstream change and ran the tests on my machine.

🤖 Generated with Claude Code

**@⁠alexdeliu** on GitHub · 2026-11-25 18:49 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/173) `alexdeliu:fix/v-cmp-f-tru-constant` → `main` · +32 −0 · 2 files · 1 commits · open ## What The always-false and always-true f32/f16 compares (`v_cmp_f_f32`, `v_cmp_tru_f32`, `v_cmp_f_f16`, `v_cmp_tru_f16`) now lower to the constants they mean, instead of `fcmp false` / `fcmp true`. This is the same change as upstream Marvisak/VIctory `77053a0`. f64 has its own path (`compare_f64`) and is unchanged. ## Why A dispatch with `fcmp false` or `fcmp true` makes WARP remove its device ("The GPU device instance has been suspended"). The cross-device fuzzer (#129) lost WARP on all four opcodes. WARP is what a GPU-less CI runner has. ## Tested One machine: RX 9070 (RDNA4, 32.0.32029.2010), Ryzen 7 7700 iGPU (gfx1036, RDNA2, 32.0.21045.29003) and WARP. Windows 11 Pro 26200; `VICTORY_DXIL` = dxil.dll 1.8.2502.11. No game data. New test `v_cmp_f_and_tru_are_constants_and_keep_the_device`: all four opcodes, including NaN operands, on every host. Like the other VALU tests, it runs on the hardware adapter and on WARP. | | `000ffdd` | this PR | |---|---|---| | RX 9070 | fails: WARP's device removed | passes | | gfx1036 | fails: WARP's device removed | passes | | `VICTORY_WARP=1` | fails: device removed | passes | `cargo test -p victory-shader --lib -- --test-threads=1`: | | `000ffdd` | this PR | |---|---|---| | RX 9070 | 266 passed, 0 failed | 267 passed, 0 failed | | gfx1036 | 264 passed, 2 failed | 265 passed, 2 failed (the two #2 wave-size tests, fixed by #110) | | WARP | 252 passed, 14 failed | 253 passed, the same 14 failed | `cargo clippy -p victory-shader --all-targets --locked`: no new warnings (the same 10 as on main). AI use: Claude Code (Claude Opus 5.5) found it with the fuzzer, ported the upstream change and ran the tests on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The always-false and always-true f32/f16 compares lowered to fcmp false
and fcmp true, and a dispatch with either made WARP remove its device
(the cross-device fuzzer, #129, lost WARP on all four). They are now the
constants they mean, as upstream Marvisak/VIctory 77053a0 does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:14 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-25 18:55 UTC · original

Independent verification on PR head 5dd0f7d (Bazzite Linux 45 x86_64, Rust 1.98.1, NVIDIA RTX 3090 driver 620.73.04):

  • Linux cargo test --locked -p victory-shader: 185 passed, 0 failed, 6 ignored (lib) + 3 passed, 0 failed, 1 ignored (tests/resource_tracking.rs).
  • Windows GNU victory-shader test binary run under GE-Proton 10-34 / Wine 10.0 / vkd3d-proton 3.0.0 on NVIDIA RTX 3090:
    • emit::valu_tests::v_cmp_f_and_tru_are_constants_and_keep_the_device: 1 passed, 0 failed (note: under Wine/vkd3d-proton EnumWarpAdapter falls back to the RTX 3090 rather than Windows WARP, so this verifies the NVIDIA hardware path).
  • cargo check --workspace --all-targets --locked --target x86_64-pc-windows-gnu: passed.

Minor note: "f" => pred::FALSE and "tru" => pred::TRUE in the inner match op right below the new "f" | "tru" arm in crates/victory-shader/src/emit/lower.rs are now unreachable (fine if kept minimal to match upstream 77053a0).

**@⁠KernelSmoker** on GitHub · 2026-11-25 18:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/173#issuecomment-7171589692) Independent verification on PR head `5dd0f7d` (Bazzite Linux 45 x86_64, Rust 1.98.1, NVIDIA RTX 3090 driver 620.73.04): - Linux `cargo test --locked -p victory-shader`: **185 passed, 0 failed, 6 ignored** (lib) + **3 passed, 0 failed, 1 ignored** (`tests/resource_tracking.rs`). - Windows GNU `victory-shader` test binary run under GE-Proton 10-34 / Wine 10.0 / vkd3d-proton 3.0.0 on **NVIDIA RTX 3090**: - `emit::valu_tests::v_cmp_f_and_tru_are_constants_and_keep_the_device`: **1 passed, 0 failed** (note: under Wine/vkd3d-proton `EnumWarpAdapter` falls back to the RTX 3090 rather than Windows WARP, so this verifies the NVIDIA hardware path). - `cargo check --workspace --all-targets --locked --target x86_64-pc-windows-gnu`: passed. Minor note: `"f" => pred::FALSE` and `"tru" => pred::TRUE` in the inner `match op` right below the new `"f" | "tru"` arm in `crates/victory-shader/src/emit/lower.rs` are now unreachable (fine if kept minimal to match upstream `77053a0`).
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 22:53 UTC · original

Windows 10 data point for 5dd0f7d: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 (#44), system WARP 10.0.19041.5794. Base: a7fa35e (main + #44).

  • With the PR: v_cmp_f_and_tru_are_constants_and_keep_the_device passes on the card and on WARP. Whole victory-shader: 278 passed, 0 failed.
  • The new test alone on the base, without the lower.rs change: it passes too, on both devices (278 passed, 0 failed). No device removal.

So this Windows 10 WARP doesn't remove its device on fcmp false/fcmp true, and the 7900 XTX doesn't either. The test catches the old lowering only on the newer WARP you saw it on (Windows 11 26200). The change is still right, it just can't be checked as a regression here.

**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/173#issuecomment-7176901290) Windows 10 data point for `5dd0f7d`: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 (#44), system WARP 10.0.19041.5794. Base: `a7fa35e` (main + #44). - With the PR: `v_cmp_f_and_tru_are_constants_and_keep_the_device` passes on the card and on WARP. Whole `victory-shader`: 278 passed, 0 failed. - The new test alone on the base, without the `lower.rs` change: it passes too, on both devices (278 passed, 0 failed). No device removal. So this Windows 10 WARP doesn't remove its device on `fcmp false`/`fcmp true`, and the 7900 XTX doesn't either. The test catches the old lowering only on the newer WARP you saw it on (Windows 11 26200). The change is still right, it just can't be checked as a regression here.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 00:18 UTC · original

RDNA2 result. Hardware: RX 6950 XT, Windows 11 build 26300, Rust 1.98.1. This PR (5dd0f7d) merged on main 4f62c2a. Command: cargo test --release -p victory-shader --lib, two runs.

  • main: 275 passed, 2 failed.
  • This PR: 276 passed, 2 failed. The new test v_cmp_f_and_tru_are_constants_and_keep_the_device passes on the RX 6950 XT and on WARP.

The 2 failures are the same on main: scalar_counted_in_a_divergent_loop_read_after_it and scalar_counted_in_nested_divergent_loops, the RDNA2 wave-size tests that #110 and #204 fix. So nothing regresses on this card. Not run in the game.

harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 00:18 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/173#issuecomment-7178614674) RDNA2 result. Hardware: RX 6950 XT, Windows 11 build 26300, Rust 1.98.1. This PR (`5dd0f7d`) merged on `main` `4f62c2a`. Command: `cargo test --release -p victory-shader --lib`, two runs. - `main`: 275 passed, 2 failed. - This PR: **276 passed, 2 failed**. The new test `v_cmp_f_and_tru_are_constants_and_keep_the_device` passes on the RX 6950 XT and on WARP. The 2 failures are the same on `main`: `scalar_counted_in_a_divergent_loop_read_after_it` and `scalar_counted_in_nested_divergent_loops`, the RDNA2 wave-size tests that #110 and #204 fix. So nothing regresses on this card. Not run in the game. harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300 AI-assisted (Claude Code); no game data.
Author
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 21:17 UTC · original · reviewed

Verified on Linux (Rust 1.98.1)

  • cargo test -p victory-shader --lib with 5dd0f7d merged into current main (--no-commit): 196 passed, 0 failed, 6 ignored. The new test is in valu_tests (cfg(all(test, windows))), so it does not run on Linux.
  • cargo clippy -p victory-shader --target x86_64-pc-windows-msvc --lib --tests: the same 10 warnings as main and none new. This also type-checks the new Windows-only test.
  • git merge --no-commit --no-ff into main: merges cleanly.
  • llvm-mc --disassemble -triple=amdgcn -mcpu=gfx1030 on the test's words gives v_cmp_f_f32_e64 s20, v1, v2, v_cmp_tru_f32_e64, v_cmp_f_f16_e64, v_cmp_tru_f16_e64 and v_cndmask_b32_e64 v0, 0, 1, s20. The opcodes in the test are right.
  • Fail-without-fix at the DXIL level, since I can't run WARP. I added a throwaway test in lower.rs (not committed) that lowers each compare plus the v_cndmask through lower_with. I took the bitcode out of the DXIL part and ran llvm-bcanalyzer --dump:
    • With the PR, the four f/tru ops have no INST_CMP2 record. v_cmp_lt_f32, as a control, still has INST_CMP2 ... op2=4 (olt).
    • With the new arm removed, the f32 ops have INST_CMP2 op2=0 / op2=15 and the f16 ops the same. Those are fcmp false / fcmp true, so the PR does remove them.
    • git status was clean afterwards.
  • The f64 path already returns constants for f/tru (compare_f64, lower.rs:9894), as the description says.

Findings

  1. Misplaced doc comment (emit/valu_tests.rs:438-441). The new test was inserted between the /// v_cmp_lg_* is "less or greater" ... comment and fn v_cmp_lg_is_false_for_nan. That comment now documents v_cmp_f_and_tru_are_constants_and_keep_the_device, and the lg test has none. Moving the new test, with its own /// line if you like, above that comment block fixes it.
  2. Unreachable arms (lower.rs:10006 "f" => pred::FALSE and lower.rs:10018 "tru" => pred::TRUE). The new "f" | "tru" arm takes these first. Removing them, or swapping them for a comment, would stop a later reader from thinking fcmp false/true can still be emitted. This is optional if you want to stay byte-for-byte with upstream 77053a0.

The change itself looks right to me. I'm leaving a comment rather than an approval because of item 1 and because I could not run the WARP test.

Not verified

  • The new test on WARP or hardware adapters (Windows + D3D12), and the "device removed" behaviour.

Reviewed with Claude Code.

**@⁠lcg007xd-c** on GitHub · 2026-11-25 21:17 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/173#pullrequestreview-6065104721) · **reviewed** ### Verified on Linux (Rust 1.98.1) - `cargo test -p victory-shader --lib` with 5dd0f7d merged into current main (`--no-commit`): 196 passed, 0 failed, 6 ignored. The new test is in `valu_tests` (`cfg(all(test, windows))`), so it does not run on Linux. - `cargo clippy -p victory-shader --target x86_64-pc-windows-msvc --lib --tests`: the same 10 warnings as main and none new. This also type-checks the new Windows-only test. - `git merge --no-commit --no-ff` into main: merges cleanly. - `llvm-mc --disassemble -triple=amdgcn -mcpu=gfx1030` on the test's words gives `v_cmp_f_f32_e64 s20, v1, v2`, `v_cmp_tru_f32_e64`, `v_cmp_f_f16_e64`, `v_cmp_tru_f16_e64` and `v_cndmask_b32_e64 v0, 0, 1, s20`. The opcodes in the test are right. - Fail-without-fix at the DXIL level, since I can't run WARP. I added a throwaway test in `lower.rs` (not committed) that lowers each compare plus the `v_cndmask` through `lower_with`. I took the bitcode out of the DXIL part and ran `llvm-bcanalyzer --dump`: - With the PR, the four f/tru ops have no `INST_CMP2` record. `v_cmp_lt_f32`, as a control, still has `INST_CMP2 ... op2=4` (olt). - With the new arm removed, the f32 ops have `INST_CMP2 op2=0` / `op2=15` and the f16 ops the same. Those are `fcmp false` / `fcmp true`, so the PR does remove them. - `git status` was clean afterwards. - The f64 path already returns constants for `f`/`tru` (`compare_f64`, `lower.rs:9894`), as the description says. ### Findings 1. **Misplaced doc comment** (`emit/valu_tests.rs:438-441`). The new test was inserted between the `/// v_cmp_lg_* is "less or greater" ...` comment and `fn v_cmp_lg_is_false_for_nan`. That comment now documents `v_cmp_f_and_tru_are_constants_and_keep_the_device`, and the `lg` test has none. Moving the new test, with its own `///` line if you like, above that comment block fixes it. 2. **Unreachable arms** (`lower.rs:10006` `"f" => pred::FALSE` and `lower.rs:10018` `"tru" => pred::TRUE`). The new `"f" | "tru"` arm takes these first. Removing them, or swapping them for a comment, would stop a later reader from thinking `fcmp false/true` can still be emitted. This is optional if you want to stay byte-for-byte with upstream `77053a0`. The change itself looks right to me. I'm leaving a comment rather than an approval because of item 1 and because I could not run the WARP test. ### Not verified - The new test on WARP or hardware adapters (Windows + D3D12), and the "device removed" behaviour. Reviewed with Claude Code.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:40 UTC · original

I tested 5dd0f7d on native Windows 11 (26300) with an RX 7900 XT (RDNA3, driver 32.0.32029.2010), Rust 1.98.1 and the Windows SDK 10.0.26100 dxil.dll. This adds a run without the fix on Windows 11's WARP:

  • The new test on WARP. I applied only the new test to the base 000ffdd, without the lower.rs change. It fails on Windows' WARP adapter with "dispatch failed: The GPU device instance has been suspended" (valu_tests.rs:200). With the PR, it passes.
  • Unit tests. cargo test -p victory-shader --lib -- --test-threads=1 gives 267 passed, 0 failed and 6 ignored, against 266 on 000ffdd.
  • The title's shaders. I ran victory translate --validate --host-lanes 32-64 over the game's whole shaders.rpf. The counts are the same as on 000ffdd: VS/PS 14247/14247, CS 2682/2682 and MS 8694 of 8765 validate, with the same 195 + 71 refusals. A local per-program DXIL hash shows 0 of 25623 programs changed.
    • A disassembly of the archive has no v_cmp/v_cmpx f/tru compares at all (f16, f32 or f64). So this title never reaches the changed path, and the fix matters for WARP and for code that uses these opcodes.

Not tested: the current main (4f62c2a), other GPUs, in-game runs.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/173#issuecomment-7201834265) I tested `5dd0f7d` on native Windows 11 (26300) with an RX 7900 XT (RDNA3, driver 32.0.32029.2010), Rust 1.98.1 and the Windows SDK 10.0.26100 `dxil.dll`. This adds a run without the fix on Windows 11's WARP: - **The new test on WARP.** I applied only the new test to the base `000ffdd`, without the `lower.rs` change. It fails on Windows' WARP adapter with "dispatch failed: The GPU device instance has been suspended" (`valu_tests.rs:200`). With the PR, it passes. - **Unit tests.** `cargo test -p victory-shader --lib -- --test-threads=1` gives 267 passed, 0 failed and 6 ignored, against 266 on `000ffdd`. - **The title's shaders.** I ran `victory translate --validate --host-lanes 32-64` over the game's whole `shaders.rpf`. The counts are the same as on `000ffdd`: VS/PS 14247/14247, CS 2682/2682 and MS 8694 of 8765 validate, with the same 195 + 71 refusals. A local per-program DXIL hash shows 0 of 25623 programs changed. - A disassembly of the archive has no `v_cmp`/`v_cmpx` `f`/`tru` compares at all (f16, f32 or f64). So this title never reaches the changed path, and the fix matters for WARP and for code that uses these opcodes. Not tested: the current main (`4f62c2a`), other GPUs, in-game runs.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/173/head:github-bot/gh-173'
git switch 'github-bot/gh-173'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-173'
git switch 'github-bot/gh-173'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-173'
git switch 'github-bot/gh-173'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-173'
git switch 'main'
git merge --squash 'github-bot/gh-173'
git switch 'main'
git merge --ff-only 'github-bot/gh-173'
git switch 'main'
git merge 'github-bot/gh-173'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.