Shaders: cover v_cmp_class_f32 VOPC SGPR/literal, mask bits, and v_cmpx_class_* EXEC narrowing #2079

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2081 into main
fuzeofficlal commented 2026-11-25 04:27:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:27:17Z.


Addresses #799.

Summary

Audited Lower::compare ("class") and lane_bits_for (v_cmpx_*) against RDNA2 V_CMP_CLASS_F32 / V_CMPX_CLASS_* semantics and added hardware + WARP tests in valu_tests::v_cmp_and_cmpx_class_f32_match_rdna2 covering the paths not exercised by 328eec1:

  • v_cmpx_class_f32 (0x098) & v_cmpx_class_f16 (0x09f) EXEC narrowing: verifies direct EXEC masking across matching and non-matching lanes without flushing denormals or quieting sNaN.
  • 32-bit VOPC encoding (v_cmp_class_f32_e32): covers SGPR src0 (s0) and 32-bit literal src0 (0xFF followed by raw +sNaN and -denormal bit patterns).
  • Ignored upper mask bits (src1[31:10]) & combined masks: verifies 0xFFFF_FC00 is ignored by hardware and exercises combined class masks across all 10 IEEE-754 binary32 class min/max boundaries.

Testing

  • cargo test -p victory-shader --locked v_cmp_and_cmpx_class_f32_match_rdna2 -- --test-threads=1 on hardware GPU (RTX 5090), WARP, and dxil.dll validation.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings and cargo xtask policy.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5485171764 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2081). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:27:17Z. --- Addresses #799. ### Summary Audited `Lower::compare` (`"class"`) and `lane_bits_for` (`v_cmpx_*`) against RDNA2 `V_CMP_CLASS_F32` / `V_CMPX_CLASS_*` semantics and added hardware + WARP tests in `valu_tests::v_cmp_and_cmpx_class_f32_match_rdna2` covering the paths not exercised by `328eec1`: - **`v_cmpx_class_f32` (`0x098`) & `v_cmpx_class_f16` (`0x09f`) `EXEC` narrowing**: verifies direct `EXEC` masking across matching and non-matching lanes without flushing denormals or quieting `sNaN`. - **32-bit VOPC encoding (`v_cmp_class_f32_e32`)**: covers SGPR `src0` (`s0`) and 32-bit literal `src0` (`0xFF` followed by raw `+sNaN` and `-denormal` bit patterns). - **Ignored upper mask bits (`src1[31:10]`) & combined masks**: verifies `0xFFFF_FC00` is ignored by hardware and exercises combined class masks across all 10 IEEE-754 binary32 class min/max boundaries. ### Testing - `cargo test -p victory-shader --locked v_cmp_and_cmpx_class_f32_match_rdna2 -- --test-threads=1` on hardware GPU (RTX 5090), WARP, and `dxil.dll` validation. - `cargo clippy --workspace --all-targets --all-features -- -D warnings` and `cargo xtask policy`.
DenRakEiw commented 2026-11-25 04:31:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:31:03Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib v_cmp_and_cmpx_class_f32_match_rdna2 — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Thorough end-to-end GPU+WARP test coverage for v_cmp_class_f32 VOPC SGPR/literal operands, mask bits, and v_cmpx_class_* EXEC narrowing. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051882109 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2081#pullrequestreview-6051882109). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:31:03Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib v_cmp_and_cmpx_class_f32_match_rdna2` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Thorough end-to-end GPU+WARP test coverage for `v_cmp_class_f32` VOPC SGPR/literal operands, mask bits, and `v_cmpx_class_*` EXEC narrowing. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 05:09:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:09:18Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. v_cmp_class_f32 VOPC SGPR/literal coverage, mask bits — compare-class opcode completeness.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052154305 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2081#pullrequestreview-6052154305). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T05:09:18Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. v_cmp_class_f32 VOPC SGPR/literal coverage, mask bits — compare-class opcode completeness.
sinan-cmyk commented 2026-11-25 10:07:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:08:47Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 616de417 onto main 940d32f (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: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157935750 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2081#issuecomment-7157935750). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:08:47Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 616de417 onto `main` 940d32f (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: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 11:05:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:30:58Z.


Automated triage for the maintainers.

This adds valu_tests::v_cmp_and_cmpx_class_f32_match_rdna2. It is test-only and covers the "class" arm of Lower::compare in emit/lower.rs through the VOPC e32 form with an SGPR and a literal src0, mask bits above bit 9, and v_cmpx_class_f32/v_cmpx_class_f16 narrowing EXEC. I decoded the hand-assembled VOPC words (0x088, 0x098, 0x09f; s0, v1, v2, literal 0xFF), and they match the comments. The expected values follow the class table that semantics_tests::class already uses. The per-bit e64 cases mostly repeat semantics_tests::class_compares_match_the_hardware. The new parts are the cmpx, SGPR and literal cases. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159800817 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2081#issuecomment-7159800817). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:30:58Z. --- <!-- victory-triage v1 head=616de4179144003973b1bb052bf28518121540bd verdict=merge-candidate at=2026-11-25T10:30:52Z --> Automated triage for the maintainers. This adds `valu_tests::v_cmp_and_cmpx_class_f32_match_rdna2`. It is test-only and covers the `"class"` arm of `Lower::compare` in `emit/lower.rs` through the VOPC e32 form with an SGPR and a literal `src0`, mask bits above bit 9, and `v_cmpx_class_f32`/`v_cmpx_class_f16` narrowing EXEC. I decoded the hand-assembled VOPC words (0x088, 0x098, 0x09f; s0, v1, v2, literal 0xFF), and they match the comments. The expected values follow the class table that `semantics_tests::class` already uses. The per-bit e64 cases mostly repeat `semantics_tests::class_compares_match_the_hardware`. The new parts are the cmpx, SGPR and literal cases. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-28 13:58:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T13:58:45Z.


I combined your exact test commit 616de417 and #3742 54c11a6 on current main in 3bf1e5d. Both PR commits are direct parents. The new comparison against current main plus your tests differs only in the class calculation.

On Microsoft WARP 1.0.22 with Agility 1.620.2, your VOPC mask and CMPX EXEC regressions passed with the new lowering. The existing f16 and f32 classification tests also passed. A separate generated fixture checked 1,030,258 outputs against an exponent-and-fraction model on both trees, including every half bit pattern. The outputs matched exactly and both emitted class shaders used five fewer DXIL instructions. Strict all-feature shader Clippy and the asset policy passed.

@fuzeofficlal, the combined tree is available for merge coordination. Please retain Git authorship on cherry-pick or rebase. If folding #3742 into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7240322715 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2081#issuecomment-7240322715). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:58:45Z. --- I combined your exact test commit `616de417` and #3742 `54c11a6` on current `main` in [`3bf1e5d`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3bf1e5d69a75fc40bef5474b8807a7dfd11e71fb). Both PR commits are direct parents. The new comparison against current main plus your tests differs only in the class calculation. On Microsoft WARP 1.0.22 with Agility 1.620.2, your VOPC mask and CMPX EXEC regressions passed with the new lowering. The existing f16 and f32 classification tests also passed. A separate generated fixture checked 1,030,258 outputs against an exponent-and-fraction model on both trees, including every half bit pattern. The outputs matched exactly and both emitted class shaders used five fewer DXIL instructions. Strict all-feature shader Clippy and the asset policy passed. @fuzeofficlal, the combined tree is available for merge coordination. Please retain Git authorship on cherry-pick or rebase. If folding #3742 into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with OpenAI Codex.
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/2081:upstream-pr/2081'
git switch 'upstream-pr/2081'

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