Shaders: lower binary64 fractional parts #2726
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2728"
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-25T19:01:35Z.
Summary
Lower RDNA 2 V_FRACT_F64 in VOP1 and VOP3. The lowering uses two 32-bit words, rounds ties to even and keeps finite results below one. It writes both destination words under the lane guard and requires neither host doubles nor int64. VOP3 source abs and neg are supported.
The RDNA 2 ISA defines the operation as x minus floor(x). RDNA 2 and RDNA 4 measurements confirm that tiny negative inputs return the largest binary64 value below one.
Verification
13f91ca, both synthetic tests fail during shader translation with Unsupported v_fract_f64.Coordination claim
Please retain the Git author if cherry-picking or rebasing this commit. If folding it into another commit, add Co-authored-by: andrewpozdnakov7-jpg [email protected].
AI-assisted. The regression uses synthetic inputs.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T19:04:46Z.
Impressive lowering. Verified the hard parts:
Test matrix is genuinely exhaustive. LGTM.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:34:38Z.
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP +
dxil.dllverification and IEEE-754 review of325fda6(on13f91ca):Verification (
rustc 1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warningsand--features host: 0 warnings.cargo test --locked -p victory-shader --lib -- fract_f64 emit::tests emit::lower emit::valu_tests(skipping the 4 long exhaustive 16-bit/3-op tests; RTX 5090 hardware + WARP +dxil.dllactive): 72 passed, 0 failed.0af08f5): clean zero-conflict merge; all 4 binary64 tests pass together on RTX 5090 + WARP +dxil.dll.Review Notes
firstbitLo/firstbitHi+ safeshift_fraction_wordsavoidsSFI0DOUBLE/INT64flags and shift UB, while accurately implementing RDNA2[0.0, 1.0)semantics:fract(-0.0) = +0.0, exact integers and|x| >= 2^52 -> +0.0, positive subnormals preserved without FTZ, negative small/subnormal inputs (-2^-54,-3*2^-54,-2^-1074) rounded-to-nearest-even and clamped tonext_down(1.0), and±Inf/sNaN/qNaNquietened via| 0x0008_0000.f64source decode helper with #2713 if both land).Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:16:40Z.
Automated triage for the maintainers.
This adds a lowering for
v_fract_f64(VOP1 and VOP3) in the newcrates/victory-shader/src/emit/lower/fract.rs, dispatched fromLowerinlower.rs. It works on two 32-bit words, so it needs no double or int64 DXIL flags.What I checked:
The behaviour cites the public RDNA2 ISA document and published hardware measurements. The tests cover 32 inputs through VGPR and SGPR pairs, plus abs and neg. CI:
checkpasses. This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by HAL9000RELOADED on 2026-11-25T23:25:48Z.
First Radeon run of
7b0550c: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 in the shader test binaries through #486. Base:481d699(main842b0cb+ #486).victory-shader: 303 passed, 1 failed. Both new tests pass on the card:fract_f64_vop1_returns_both_words_below_oneandfract_f64_vop3_literals_obey_abs_and_neg.pops_wait_loop_exits_immediately_for_inactive_lanes, which wants an SM 6.6 WARP device (this Windows 10 WARP reports SM 6.2). It fails the same way on the base without this PR.So the lowered binary64 fract matches on RDNA3 hardware as well as on the RTX 5090 and WARP.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:19:52Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP,dxil.dllvalidator active):cargo test -p victory-shader --lib emit::valu_tests::fract_f64: 2 passed, 0 failed (fract_f64_vop1_returns_both_words_below_oneandfract_f64_vop3_literals_obey_abs_and_negpass on both RTX 5090 hardware and WARP).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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:31:59Z.
Review: APPROVED
Looks good — verified locally at
7b0550cd:cargo xtask policy(192 files ok) andcargo clippy --all-targets --all-featurespass with 0 warnings.rustfmt --edition 2024diffs (crates/victory-shader/src/emit/lower/fract.rsis clean; remaining diffs inlower.rsandvalu_tests.rsare pre-existing).emit::valu_tests::fractpasses 2/2 on both RTX 5090 (VICTORY_WARP=0) and WARP (VICTORY_WARP=1), verifyingSFI0 & 0x8001 == 0,< 1.0clamping (0x3FEF_FFFF_FFFF_FFFF),abs/negmodifiers, literals, and SGPR/VGPR sources.(Non-blocking note:
fract_f64currently assumes default RTE + preserved denormals rather than trackingmode16round/denorm changes, and rejectsclamp/omod; those can be extended later if needed.)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.