Skip to content

Shaders: lower binary64 class comparisons - #1469

Open
Luizbc2 wants to merge 2 commits into
Marvisak:mainfrom
Luizbc2:fix/rdna2-binary64-class
Open

Luizbc2 wants to merge 2 commits into
Marvisak:mainfrom
Luizbc2:fix/rdna2-binary64-class

Conversation

@Luizbc2

@Luizbc2 Luizbc2 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

Classify binary64 directly from the two 32-bit words.
Exercise all ten class bits, including low-word payloads and source modifiers.
@geiyiliyabumo

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@sinan-cmyk

Copy link
Copy Markdown

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).

Copy link
Copy Markdown
Owner

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

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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 <andrewpozdnakov7-jpg@users.noreply.github.com>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants