Shaders: apply bitwise modifiers to v_cmp_class_f32 source operands #1327
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1327"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:28:47Z.
Fixes #830.
Summary
Lower::compare(class) forv_cmp_class_f32/v_cmpx_class_f32, apply SDWA sub-word selection (Self::sdwa_src+select_bits), and performabs(& 0x7FFF_FFFF) andneg(^ 0x8000_0000) bitwise ini32, matching the existingf16path.v_cmp_class_f32throughfsrc(FAbs/fsub -0.0, x), which flushes denormals to±0.0under FTZ and quiets signaling NaNs before IEEE-754 class testing.Verification
valu_tests::v_cmp_class_f32_matches_rdna2testing all 10 IEEE-754 binary32 classes (±sNaN,±qNaN,±inf,±normal,±denormal,±0.0) acrossplain,neg,abs,abs+neg, andv_cmp_class_f32_sdwa(-word0preserving-denormalclass 4 instead of flushing to-0.0class 5):dxil.dllvalidation: passedcargo test -p victory-shader,cargo clippy --workspace --all-targets --all-features, andcargo xtask policy: passed.Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T18:10:51Z.
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=1gives 121 passed, 0 failed, 1 ignored.v_cmp_class_f32_matches_rdna2passes on the hardware adapter and WARP, with the sNaN and denormal rows included.This is the case where the old
fsrcpath could differ per driver:FAbsand the-0.0 - xnegate may flush denormals or quiet sNaNs. Doingabs/negas integer ops on the raw bits avoids that. The class numbering in the test (bit 0 sNaN through bit 9 +inf) matches the ISA.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:47Z.
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 only run on Windows; macOS covers lowering/structure/IR unit tests.Applies bitwise modifiers to v_cmp_class_f32 source operands and adds v_cmp_class_f32_matches_rdna2 hardware cases.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:22:31Z.
Automated triage for the maintainers.
Merge candidate (unchanged). The new head is one commit on current
mainand merges cleanly. The change is the same as before. Inemit/lower.rs::Lower::compare(class),v_cmp_class_f32reads the raw operand throughoperand, applies the SDWA selection (sdwa_src+select_bits), and appliesabs/negas bit operations (& 0x7FFF_FFFF,^ 0x8000_0000). The f16 path now shares that modifier code. This keepsfsrc's floatabs/negate from flushing denormals or quieting sNaNs before the class test (#830).v_cmp_class_f32_matches_rdna2invalu_tests.rscovers all ten classes with each modifier combination, plus an SDWA case.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T02:09:27Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
4f2eee6ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 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 --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T14:21:08Z.
I tested this PR with the FP16 operand-selection fixes from #926 and #3364 on main
63bcca4. Combined branch 62b8716 retains the three PR heads and their original tests.I also preserved the old fsrc source-selection order for F32 class compares. SDWA uses its selected subword first. Otherwise the lowering uses the lane-selected source when one was already computed and applies ABS/NEG to the bits. The FP16 path keeps its own half selection.
With the unchanged F32 class fixture on the earlier #926/#3364 integration
e002024, WARP gives 0 for the negated signalling NaN0x7f800001tested against class mask 1, where the test expects 1. The combined branch passes that fixture, the F16 class fixture, both FP16 operand-selection regressions, and all 39 VALU tests on app-local WARP 1.0.22 with DXIL validation. Strict shader Clippy and the asset check passed.If folding the merge resolution into another commit, please retain Git authorship or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted with Codex. Synthetic shader tests only.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:07:30Z.
I combined your exact
7c4663fwith #37435397722on currentmainin1d9d947. Both PR commits are direct parents. The constant-mask predicate uses the same raw source bits produced by your modifier handling.The two trees matched all 2,655,576 generated output words on Microsoft WARP 1.0.22 with Agility 1.620.2. The comparison covered CMP, CMPX, literal masks, and both plain and abs/neg source forms. Your f32 class modifier test, including SDWA, passed alongside the f16 class test and the new immediate-mask regression. The f32 NaN and finite fixtures emitted 37 DXIL instructions instead of 57, and the generic mask remained at 57. 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 #3743 into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted with OpenAI Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.