fix(victory-shader): lower v_cmp_f and v_cmp_tru floats as constant booleans #448

Open
github-bot wants to merge 3 commits from github-bot/gh-448 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 19:08 UTC · original
mauroalvare:fix/victory-fcmp-const-predicates → main · +51 −3 · 4 files · 3 commits · open

What failed

In third_party/victory/crates/victory-shader/src/emit/lower.rs, floating-point constant-result compares (v_cmp_f_f32, v_cmp_tru_f32, v_cmp_f_f16, v_cmp_tru_f16, and their v_cmpx_* forms) lowered to LLVM/DXIL fcmp false (pred::FALSE = 0) and fcmp true (pred::TRUE = 15).

While integer constant compares (v_cmp_f_{u32,i32,u16,i16}, v_cmp_t_{u32,i32,u16,i16}) already lowered directly to constant lane booleans (self.lane(inst, Some(op == "t"))), emitting fcmp false/fcmp true in DXIL caused D3D12 WARP to fail at dispatch with GPU device removal (DXGI_ERROR_DEVICE_SUSPENDED) on base 50936c0:

thread 'emit::valu_tests::v_cmp_f_and_tru_lower_as_constant_booleans' panicked at crates\victory-shader\src\emit\valu_tests.rs:249:37:
warp: dispatch failed: La instancia de dispositivo de GPU se ha suspendido. Use GetDeviceRemovedReason para averiguar cuál es la acción adecuada.

How to reproduce

From third_party/victory:

cargo test --locked -p victory-shader v_cmp_f_and_tru_lower_as_constant_booleans -- --test-threads=1 --nocapture

The synthetic compute shader encodes v_cmp_f_f32 (0x000), v_cmp_tru_f32 (0x00f), v_cmp_f_f16 (0x0c8), and v_cmp_tru_f16 (0x0ef) followed by v_cndmask_b32, validates the emitted DXIL with dxil.dll, and dispatches across finite values, infinities, quiet NaNs, and signalling NaNs on both the hardware GPU and WARP.

What changed

  • third_party/victory/crates/victory-shader/src/emit/lower.rs: Lower "f" and "tru" for "f32" | "f16" via self.lane(inst, Some(op == "tru")), matching the existing "f" | "t" integer compare path and avoiding fcmp false/fcmp true in emitted DXIL.
  • third_party/victory/crates/victory-shader/src/emit/bitcode.rs: Mark pred::FALSE and pred::TRUE #[allow(dead_code)] with a note explaining why they are not emitted (mirroring pred::ONE).
  • third_party/victory/crates/victory-shader/src/emit/valu_tests.rs: Add synthetic regression test v_cmp_f_and_tru_lower_as_constant_booleans covering v_cmp_f_f32, v_cmp_tru_f32, v_cmp_f_f16, and v_cmp_tru_f16 with normal, infinite, qNaN, and sNaN inputs.

Verification

Tested on Windows x64, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver 621.40), WARP, and dxil.dll (10.0.26100.0), base SHA 50936c0:

  • Base 50936c0: v_cmp_f_and_tru_lower_as_constant_booleans failed (warp: dispatch failed: DXGI_ERROR_DEVICE_SUSPENDED).
  • With fix:
    • cargo test --locked -p victory-shader v_cmp_f_and_tru_lower_as_constant_booleans -- --test-threads=1 --nocapture: 1 passed; 0 failed (RTX 5070 Ti + WARP + dxil.dll).
    • cargo test --locked -p victory-shader -- --test-threads=1: 258 passed; 0 failed; 2 ignored (both ignored are benchmarks: bench_write and bench_opt).
    • cargo xtask policy: asset policy: 215 files ok.

All measurements are from synthetic unit tests only (no game files or game runs).

AI assistance

Assisted by AI (Antigravity) for root-cause analysis, synthetic test authoring, implementation, and verification on local hardware.

**@⁠mauroalvare** on GitHub · 2026-11-26 19:08 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/448) `mauroalvare:fix/victory-fcmp-const-predicates` → `main` · +51 −3 · 4 files · 3 commits · open ## What failed In `third_party/victory/crates/victory-shader/src/emit/lower.rs`, floating-point constant-result compares (`v_cmp_f_f32`, `v_cmp_tru_f32`, `v_cmp_f_f16`, `v_cmp_tru_f16`, and their `v_cmpx_*` forms) lowered to LLVM/DXIL `fcmp false` (`pred::FALSE = 0`) and `fcmp true` (`pred::TRUE = 15`). While integer constant compares (`v_cmp_f_{u32,i32,u16,i16}`, `v_cmp_t_{u32,i32,u16,i16}`) already lowered directly to constant lane booleans (`self.lane(inst, Some(op == "t"))`), emitting `fcmp false`/`fcmp true` in DXIL caused D3D12 WARP to fail at dispatch with GPU device removal (`DXGI_ERROR_DEVICE_SUSPENDED`) on base `50936c0`: ``` thread 'emit::valu_tests::v_cmp_f_and_tru_lower_as_constant_booleans' panicked at crates\victory-shader\src\emit\valu_tests.rs:249:37: warp: dispatch failed: La instancia de dispositivo de GPU se ha suspendido. Use GetDeviceRemovedReason para averiguar cuál es la acción adecuada. ``` ## How to reproduce From `third_party/victory`: ```powershell cargo test --locked -p victory-shader v_cmp_f_and_tru_lower_as_constant_booleans -- --test-threads=1 --nocapture ``` The synthetic compute shader encodes `v_cmp_f_f32` (`0x000`), `v_cmp_tru_f32` (`0x00f`), `v_cmp_f_f16` (`0x0c8`), and `v_cmp_tru_f16` (`0x0ef`) followed by `v_cndmask_b32`, validates the emitted DXIL with `dxil.dll`, and dispatches across finite values, infinities, quiet NaNs, and signalling NaNs on both the hardware GPU and WARP. ## What changed - `third_party/victory/crates/victory-shader/src/emit/lower.rs`: Lower `"f"` and `"tru"` for `"f32" | "f16"` via `self.lane(inst, Some(op == "tru"))`, matching the existing `"f" | "t"` integer compare path and avoiding `fcmp false`/`fcmp true` in emitted DXIL. - `third_party/victory/crates/victory-shader/src/emit/bitcode.rs`: Mark `pred::FALSE` and `pred::TRUE` `#[allow(dead_code)]` with a note explaining why they are not emitted (mirroring `pred::ONE`). - `third_party/victory/crates/victory-shader/src/emit/valu_tests.rs`: Add synthetic regression test `v_cmp_f_and_tru_lower_as_constant_booleans` covering `v_cmp_f_f32`, `v_cmp_tru_f32`, `v_cmp_f_f16`, and `v_cmp_tru_f16` with normal, infinite, qNaN, and sNaN inputs. ## Verification Tested on Windows x64, Ryzen 7 9700X, **NVIDIA GeForce RTX 5070 Ti (driver `621.40`)**, WARP, and `dxil.dll` (`10.0.26100.0`), base SHA `50936c0`: - **Base `50936c0`**: `v_cmp_f_and_tru_lower_as_constant_booleans` **failed** (`warp: dispatch failed: DXGI_ERROR_DEVICE_SUSPENDED`). - **With fix**: - `cargo test --locked -p victory-shader v_cmp_f_and_tru_lower_as_constant_booleans -- --test-threads=1 --nocapture`: **1 passed; 0 failed** (RTX 5070 Ti + WARP + `dxil.dll`). - `cargo test --locked -p victory-shader -- --test-threads=1`: **258 passed; 0 failed; 2 ignored** (both ignored are benchmarks: `bench_write` and `bench_opt`). - `cargo xtask policy`: **asset policy: 215 files ok**. All measurements are from synthetic unit tests only (no game files or game runs). ## AI assistance Assisted by AI (Antigravity) for root-cause analysis, synthetic test authoring, implementation, and verification on local hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:12:16 +00:00
github-bot force-pushed github-bot/gh-448 from 8e7c05fac1 to 727118c1d2 2026-11-26 19:34:43 +00:00 Compare
github-bot force-pushed github-bot/gh-448 from 534396239a to b50d2ee9dd 2026-11-27 00:37:42 +00:00 Compare
Author
Owner

@⁠mauroalvare on GitHub · 2026-11-26 23:37 UTC · original

The Vice-Tay port is up in b50d2ee. The constant false and true comparisons passed on native D3D12 and WARP. Vice-Tay keys the shader cache by translator version in the default mode, so the port bumps that version from 2 to 3.

**@⁠mauroalvare** on GitHub · 2026-11-26 23:37 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/448#issuecomment-7205706635) The Vice-Tay port is up in `b50d2ee`. The constant false and true comparisons passed on native D3D12 and WARP. Vice-Tay keys the shader cache by translator version in the default mode, so the port bumps that version from 2 to 3.
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/448/head:github-bot/gh-448'
git switch 'github-bot/gh-448'

Merge

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