Shaders: lower binary64 class comparisons #1468

Open
Luizbc2 wants to merge 2 commits from upstream-pr/1469 into main
Luizbc2 commented 2026-11-24 18:16:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Luizbc2 on 2026-11-24T18:16:49Z.


What changed

Translate v_cmp_class_f64 and v_cmpx_class_f64 using the existing classification and lane-mask path. The two source words stay as i32, so the low payload participates in distinguishing infinities from NaNs and zero from subnormals, without requiring host driver FP64 support. Source abs/neg only update the sign bit. The FP64 arithmetic and ordered compares are covered separately by #1262.

Reproduction and tests

  • On ffe310e, the synthetic v_cmp_class_f64_preserves_all_binary64_classes test fails at shader lowering with Unsupported { offset: 44, what: "v_cmp_class_f64" }.
  • cargo test -p victory-shader --lib --locked --offline v_cmp_class -- --nocapture passed on Windows with the patch. The new test exercises all ten class bits, negative masks, low-word-only payloads, SGPR input, and abs/neg. The existing binary16 test also passed. The compute cases ran on hardware and WARP.
  • git diff --check passed.

AMD RDNA 2 ISA reference

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588464667 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469). Originally posted by [Luizbc2](https://github.com/Luizbc2) on 2026-11-24T18:16:49Z. --- ## What changed Translate `v_cmp_class_f64` and `v_cmpx_class_f64` using the existing classification and lane-mask path. The two source words stay as `i32`, so the low payload participates in distinguishing infinities from NaNs and zero from subnormals, without requiring host driver FP64 support. Source abs/neg only update the sign bit. The FP64 arithmetic and ordered compares are covered separately by #1262. ## Reproduction and tests - On `ffe310e`, the synthetic `v_cmp_class_f64_preserves_all_binary64_classes` test fails at shader lowering with `Unsupported { offset: 44, what: "v_cmp_class_f64" }`. - `cargo test -p victory-shader --lib --locked --offline v_cmp_class -- --nocapture` passed on Windows with the patch. The new test exercises all ten class bits, negative masks, low-word-only payloads, SGPR input, and abs/neg. The existing binary16 test also passed. The compute cases ran on hardware and WARP. - `git diff --check` passed. [AMD RDNA 2 ISA reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf)
catminou4 commented 2026-11-24 19:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T18:42:13Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and were not run here; lowering/structure coverage only.

v_cmp_class_f64/v_cmpx_class_f64 keep both dwords as i32 and classify on the pair, with abs/neg applied to the sign dword only. The new valu test covers all ten binary64 classes (signaling/quiet NaN with low-word payloads, infinities, normals, denormals, ±0) plus an abs-then-neg SGPR-pair case — exactly the payload-sensitive cases. macOS 96 passed (execution test is Windows-only).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045233906 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469#pullrequestreview-6045233906). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T18:42:13Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), `cargo test -p victory-shader --locked` → 96 passed, 0 failed. Execution/valu tests are `#[cfg(all(test, windows))]` and were not run here; lowering/structure coverage only. `v_cmp_class_f64`/`v_cmpx_class_f64` keep both dwords as i32 and classify on the pair, with abs/neg applied to the sign dword only. The new valu test covers all ten binary64 classes (signaling/quiet NaN with low-word payloads, infinities, normals, denormals, ±0) plus an abs-then-neg SGPR-pair case — exactly the payload-sensitive cases. macOS 96 passed (execution test is Windows-only).
geiyiliyabumo commented 2026-11-24 19:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T18:21:16Z.


Verified commit \ed9f8c6\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, SM 6.6) + WARP:

  • \cargo test -p victory-shader --lib: 121/121 passed (1 ignored), including \emit::valu_tests::v_cmp_class_f64_preserves_all_binary64_classes.
  • Checked \class_src64\ handling of 64-bit inline float constants, 32-bit literal placement in the high dword (\hi = bits, lo = 0), and \bs/
    eg\ sign-bit masking on the high dword; all look consistent with RDNA2 / GFX10.3 ISA.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140525097 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469#issuecomment-7140525097). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T18:21:16Z. --- Verified commit \ed9f8c6\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, SM 6.6)** + **WARP**: - \cargo test -p victory-shader --lib\: **121/121 passed** (1 ignored), including \emit::valu_tests::v_cmp_class_f64_preserves_all_binary64_classes\. - Checked \class_src64\ handling of 64-bit inline float constants, 32-bit literal placement in the high dword (\hi = bits, lo = 0\), and \bs\/\ eg\ sign-bit masking on the high dword; all look consistent with RDNA2 / GFX10.3 ISA. *AI-assisted; synthetic tests only, no game files.*
AnoHunted commented 2026-11-24 19:04:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AnoHunted on 2026-11-24T18:38:08Z.


Independent NVIDIA hardware run. No game files were used.

Machine: Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, DXC dxil.dll 1.9.2609 (SDK 10.0.26100) validating.

cargo test -p victory-shader --features host -- --test-threads=1 with this PR:

  • 121 passed, 0 failed, 1 ignored (main: 120 / 0 / 1).
  • v_cmp_class_f64_preserves_all_binary64_classes executes via run_cases on the RTX 5080 (and WARP) and passes; every binary64 class (inf / NaN / zero / subnormal) checks out, so this adapter's FP64 path is exercised (not skipped).

Not tested: the in-game effect; AMD.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140921543 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469#issuecomment-7140921543). Originally posted by [AnoHunted](https://github.com/AnoHunted) on 2026-11-24T18:38:08Z. --- Independent NVIDIA hardware run. No game files were used. Machine: Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, DXC `dxil.dll` 1.9.2609 (SDK 10.0.26100) validating. `cargo test -p victory-shader --features host -- --test-threads=1` with this PR: - **121 passed, 0 failed, 1 ignored** (main: 120 / 0 / 1). - `v_cmp_class_f64_preserves_all_binary64_classes` executes via `run_cases` on the RTX 5080 (and WARP) and passes; every binary64 class (inf / NaN / zero / subnormal) checks out, so this adapter's FP64 path is exercised (not skipped). Not tested: the in-game effect; AMD.
sinan-cmyk commented 2026-11-24 21:03:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:43:50Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head ed9f8c6 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143979283 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469#issuecomment-7143979283). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T20:43:50Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head ed9f8c6 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 121, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 02:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:29:19Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149602756 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469#issuecomment-7149602756). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:29:19Z. --- <!-- victory-triage v1 head=ed9f8c6bdf6b1a8d896619864c8f404eb9fc5e02 verdict=needs-rebase at=2026-11-25T01:29:17Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-25 11:05:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T11:00:26Z.


The conflict with 940d32f is between adjacent tests in valu_tests.rs. I rebased the existing lowering b277c15 and the existing test 412c14d with your Git authorship intact. The test is inserted alongside the tests that main added.

I added a separate c07eb2b to exercise the v_cmpx_class_f64 EXEC update. Its WARP readback sees a write for the matching class and the untouched output for a non-matching class. All 30 VALU tests pass with DXIL validation and app-local WARP. Strict shader Clippy and the staged asset policy pass. If you fold the EXEC test into another commit, please retain Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160461128 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1469#issuecomment-7160461128). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T11:00:26Z. --- The conflict with `940d32f` is between adjacent tests in `valu_tests.rs`. I rebased [the existing lowering `b277c15`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b277c15b5943c31e56f1bbca9007ee15710bd68d) and [the existing test `412c14d`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/412c14d77cc9c8c8500e32bad1aadca5e13b1b3b) with your Git authorship intact. The test is inserted alongside the tests that `main` added. I added a separate [`c07eb2b`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/c07eb2bc92b997ab48e57726cdc76e1d4d8254f1) to exercise the `v_cmpx_class_f64` EXEC update. Its WARP readback sees a write for the matching class and the untouched output for a non-matching class. All 30 VALU tests pass with DXIL validation and app-local WARP. Strict shader Clippy and the staged asset policy pass. If you fold the EXEC test into another commit, please retain `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
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/1469:upstream-pr/1469'
git switch 'upstream-pr/1469'

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/1469'
git switch 'upstream-pr/1469'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1469'
git switch 'upstream-pr/1469'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1469'
git switch 'main'
git merge --squash 'upstream-pr/1469'
git switch 'main'
git merge --ff-only 'upstream-pr/1469'
git switch 'main'
git merge 'upstream-pr/1469'
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
Marvisak/VIctory!1468
No description provided.