Shaders: lower v_div_scale_f64 and its lane mask #2973
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2975"
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 andrewpozdnakov7-jpg on 2026-11-26T01:58:35Z.
Summary
Verification
References: RDNA2 hardware observations, directed downscale measurements, and clamp/OMOD characterization.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:10:44Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 (RTX 5090 + WARP +dxil.dll,VICTORY_D3D12_DEBUG=1) — clean implementation and ready to merge:crates/victory-shader/src/emit/lower/div_scale.rs(zerof64DXIL ops, zeropred::ONEpredicates, preserves SFI0 flags), keepingemit/lower.rsat 520,966 B (+403 B, 3,322 B below the 512 KiB cap).delta >= 768/<= -768,de == 0,de >= 2045,ne <= 53),value == denominatorselection afternegmodifiers, subnormal renormalization viaunaryBits.i32, subnormal downscale rounding across all 4 IEEE rounding modes,±0.0-> canonical-qNaN,clamp, andVCC/lane-mask tracking (Val::Missing("a lane mask read as data")).v_div_fixup_f64), with 3 small adjacent text overlaps inemit/lower.rs(module declaration, opcodematch, and identicaloperand64_dwordshelper).Local verification:
victory-shader(binary64_division_scale_returns_both_words_and_lane_mask+lower::tests+ related): 51/51 passed on both RTX 5090 and WARP (dxil.dll+DEBUG=1)cargo clippy --all-targets -- -D warnings(default &--all-features) +cargo xtask policy(191 files ok): 0 warningsImported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:32:10Z.
Review: COMMENTED
Verified: consistent with #2953's div_fixup model — the mask marks lanes needing fixup, both aliased-input forms (src0=den vs src0=num) are covered, and the round-mode limit table matches (nearest saturates to inf, directed modes saturate sign-side, toward-zero takes max-finite both ways). The subnormal rounding window (exponents 117-128, shift 1-12 so all discarded bits stay in lo) is correctly reasoned. Note: this adds the same operand64_dwords refactor as #2953 — the second to merge gets a trivial conflict.
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T02:29:41Z.
I ran
v_div_scale_f64fromce620efbandv_div_fixup_f64from #2953 (f0f5fb5b) in the same wave32 compute shader. The scale result supplied the first operand of fixup. Both the physical RTX 5080 and Microsoft WARP matched all 5,688 lane records per adapter.s20), at numerator-minus-denominator exponent differences −769, −768, −767, 0, 767, 768 and 769. After executing both instructions on even lanes and restoring EXEC,v_cndmask_b32read back0x55555555at both ±768 thresholds and zero at ±767. The inactive lanes retained both sentinel dwords. With full EXEC the corresponding masks were0xffffffffand zero. All 1,792 records matched, including the quotient-sign repair.0x08000001ffffffffgave0x0008000100000000for nearest-even and toward +∞, and0x00080000fffffffffor toward zero and toward −∞. Both instructions returned those bits.The rounding reference used exact rational power-of-two scaling and the adjacent binary64 values for directed rounding. For exponent field 116 I used the overflow behavior measured on the RX 6900 XT. These synthetic shaders exercise the handoff with a supplied preliminary quotient. Their DXIL validated and the containers requested neither double-precision instructions, double extensions nor int64. Related RDNA2 hardware measurement
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:26:05Z.
Automated triage for the maintainers.
Merge candidate (recommending a look, not approving). This lowers
v_div_scale_f64(VOP3B 0x16e), whichmainrefuses, in a newcrates/victory-shader/src/emit/lower/div_scale.rs: it computes the ±128 exponent scale and the lane mask from the exponent difference (±768) and the denominator and numerator edge cases, handles zero inputs, normalizes and rounds subnormals under the f64 rounding mode, and applies clamp. I compared the cases with the ISA pseudocode. Where they differ (for example the mask on a zero denominator, or overflow below exponent 117), the newsemantics_tests.rstest pins the values the PR cites from RDNA2 hardware measurements in the AnyPS5 oracle, whichsemantics_tests.rsonmainalready cites. A commenter ran it together with #2953 (v_div_fixup_f64) and got matching results, and the two PRs only touch neighbouring lines. CIcheckpasses.Small request: the comment
As measured on RDNA2 (#663)indiv_scale_f64reads as VIctory issue #663; please write it as AnyPS5 #663, as the test does.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T07:10:26Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP +dxil.dll):cargo test -p victory-shader binary64_division_scale_returns_both_words_and_lane_mask -- --test-threads=1(RTX 5090 & WARP): 1 passed, 0 failed on both.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.