Shaders: apply bitwise modifiers to v_cmp_class_f32 source operands #1327

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

@⁠fuzeofficlal on GitHub · 2026-11-24 17:28 UTC · original
fuzeofficlal:fix/shader-cmp-class-f32-modifiers-830 → main · +121 −16 · 2 files · 1 commits · open

Fixes #830.

Summary

  • Read the raw 32-bit integer operand in Lower::compare (class) for v_cmp_class_f32 / v_cmpx_class_f32, apply SDWA sub-word selection (Self::sdwa_src + select_bits), and perform abs (& 0x7FFF_FFFF) and neg (^ 0x8000_0000) bitwise in i32, matching the existing f16 path.
  • Avoids routing v_cmp_class_f32 through fsrc (FAbs / fsub -0.0, x), which flushes denormals to ±0.0 under FTZ and quiets signaling NaNs before IEEE-754 class testing.

Verification

  • Added valu_tests::v_cmp_class_f32_matches_rdna2 testing all 10 IEEE-754 binary32 classes (±sNaN, ±qNaN, ±inf, ±normal, ±denormal, ±0.0) across plain, neg, abs, abs+neg, and v_cmp_class_f32_sdwa (-word0 preserving -denormal class 4 instead of flushing to -0.0 class 5):
    • dxil.dll validation: passed
    • NVIDIA GeForce RTX 5090: passed
    • Microsoft D3D12 WARP: passed
  • cargo test -p victory-shader, cargo clippy --workspace --all-targets --all-features, and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1327) `fuzeofficlal:fix/shader-cmp-class-f32-modifiers-830` → `main` · +121 −16 · 2 files · 1 commits · open Fixes #830. ### Summary - Read the raw 32-bit integer operand in `Lower::compare` (`class`) for `v_cmp_class_f32` / `v_cmpx_class_f32`, apply SDWA sub-word selection (`Self::sdwa_src` + `select_bits`), and perform `abs` (`& 0x7FFF_FFFF`) and `neg` (`^ 0x8000_0000`) bitwise in `i32`, matching the existing `f16` path. - Avoids routing `v_cmp_class_f32` through `fsrc` (`FAbs` / `fsub -0.0, x`), which flushes denormals to `±0.0` under FTZ and quiets signaling NaNs before IEEE-754 class testing. ### Verification - Added `valu_tests::v_cmp_class_f32_matches_rdna2` testing all 10 IEEE-754 binary32 classes (`±sNaN`, `±qNaN`, `±inf`, `±normal`, `±denormal`, `±0.0`) across `plain`, `neg`, `abs`, `abs+neg`, and `v_cmp_class_f32_sdwa` (`-word0` preserving `-denormal` class 4 instead of flushing to `-0.0` class 5): - `dxil.dll` validation: passed - **NVIDIA GeForce RTX 5090**: passed - **Microsoft D3D12 WARP**: passed - `cargo test -p victory-shader`, `cargo clippy --workspace --all-targets --all-features`, and `cargo xtask policy`: passed.
Read src0 of v_cmp_class_f32 and v_cmpx_class_f32 as raw 32-bit bits (with SDWA sub-dword selection when present) and apply VOP3/SDWA abs and neg modifiers in integer bits rather than through fsrc float operations. This prevents D3D12 FTZ from flushing negated +denormals to -0.0 and prevents float ops from quieting signalling NaNs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:42 +00:00
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 18:10 UTC · original

Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at 4f2eee6. cargo test -p victory-shader --lib -- --test-threads=1 gives 121 passed, 0 failed, 1 ignored. v_cmp_class_f32_matches_rdna2 passes on the hardware adapter and WARP, with the sNaN and denormal rows included.

This is the case where the old fsrc path could differ per driver: FAbs and the -0.0 - x negate may flush denormals or quiet sNaNs. Doing abs/neg as integer ops on the raw bits avoids that. The class numbering in the test (bit 0 sNaN through bit 9 +inf) matches the ISA.

**@⁠marquezinii** on GitHub · 2026-11-24 18:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1327#issuecomment-7140273980) Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at `4f2eee6`. `cargo test -p victory-shader --lib -- --test-threads=1` gives 121 passed, 0 failed, 1 ignored. `v_cmp_class_f32_matches_rdna2` passes on the hardware adapter and WARP, with the sNaN and denormal rows included. This is the case where the old `fsrc` path could differ per driver: `FAbs` and the `-0.0 - x` negate may flush denormals or quiet sNaNs. Doing `abs`/`neg` as integer ops on the raw bits avoids that. The class numbering in the test (bit 0 sNaN through bit 9 +inf) matches the ISA.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:22 UTC · original · edited 2026-11-26 01:19 UTC

Automated triage for the maintainers.

Merge candidate (unchanged). The new head is one commit on current main and merges cleanly. The change is the same as before. In emit/lower.rs::Lower::compare (class), v_cmp_class_f32 reads the raw operand through operand, applies the SDWA selection (sdwa_src + select_bits), and applies abs/neg as bit operations (& 0x7FFF_FFFF, ^ 0x8000_0000). The f16 path now shares that modifier code. This keeps fsrc's float abs/negate from flushing denormals or quieting sNaNs before the class test (#830). v_cmp_class_f32_matches_rdna2 in valu_tests.rs covers all ten classes with each modifier combination, plus an SDWA case.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1327#issuecomment-7149480508) · edited 2026-11-26 01:19 UTC <!-- victory-triage v1 head=7c4663f856987472b0e5805526f5ddfd06237afd verdict=merge-candidate at=2026-11-26T01:19:00Z --> Automated triage for the maintainers. **Merge candidate (unchanged).** The new head is one commit on current `main` and merges cleanly. The change is the same as before. In `emit/lower.rs::Lower::compare` (`class`), `v_cmp_class_f32` reads the raw operand through `operand`, applies the SDWA selection (`sdwa_src` + `select_bits`), and applies `abs`/`neg` as bit operations (`& 0x7FFF_FFFF`, `^ 0x8000_0000`). The f16 path now shares that modifier code. This keeps `fsrc`'s float `abs`/negate from flushing denormals or quieting sNaNs before the class test (#830). `v_cmp_class_f32_matches_rdna2` in `valu_tests.rs` covers all ten classes with each modifier combination, plus an SDWA case. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 02:09 UTC · original

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

Result: no count change against main.

Offline. I merged head 4f2eee6 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).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 02:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1327#issuecomment-7150384004) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 4f2eee6 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).
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/1327/head:github-bot/gh-1327'
git switch 'github-bot/gh-1327'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1327'
git switch 'github-bot/gh-1327'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1327'
git switch 'github-bot/gh-1327'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1327'
git switch 'main'
git merge --squash 'github-bot/gh-1327'
git switch 'main'
git merge --ff-only 'github-bot/gh-1327'
git switch 'main'
git merge 'github-bot/gh-1327'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1327
No description provided.