shader: lower the binary64 rounding and fraction forms #3645
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3645
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3643"
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?
@lambirou on GitHub · 2026-11-30 19:48 UTC · original
lambirou:shader/f64-rounding→main· +0 −0 · 0 files · 0 commits · closed without mergingPart of the f64 slice (P5).
This adds the ten binary64 rounding/fraction forms:
v_ceil_f64,v_floor_f64,v_trunc_f64,v_rndne_f64andv_fract_f64in both the VOP1_e32and VOP3_e64spellings. The lowering works only on the two 32-bit words, with no HLSL double:r64_roundcovers trunc/floor/ceil/rndne (ties to even), andr64_fractcomputes x - floor(x) from the significand, with the below-one ceiling for tiny negative fractions. NaN inputs are quieted and infinities become the canonical qNaN, following the existing binary16/binary32 helpers.Guards: entry EXEC, destination pair
v[d:d+1]withd <= 254, no outstanding sample, preserved entry denormal profile; modifiers, clamp/omod,op_sel, DPP, SDWA, inline constants, literals and unproven pairs are refused.Tests
pixel_aot_f64_round_warpand_hardwarepass on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).pixel_mismatch.form_coverage_check.pypins exactly the ten forms;rdna2_tools_check.pypasses 162 tests (19 LLVM-dependent skips); the neighbouringdraw-cmp-f64,draw-cvt-f64-*anddraw-cvt-*-f64tests still pass on both adapters.Limits
The draws prove the translated shader on desktop adapters, not gfx1013 or the console. NaN quieting and the fract below-one ceiling are chosen from the existing helpers without a console measurement. No LLVM 15 round-trip of the ten forms was run; the spellings are covered by the controls and draws.
AI-assisted.
Merge with origin/main (2026-12-01)
Merged
origin/mainata3bfd019into this branch; head is9601449e. The shared CMake, docs and test files keep both the #3609/#3623 additions and the PR additions. Local post-merge:pixel_aot_check.py,form_coverage_check.pyandrdna2_tools_check.pypass (163 tests, 19 skips); CTestpixel_aot_f64_round_warpandpixel_aot_f64_minmax_ldexp_warppass.2b3459edd2toba4e37f4fa@lukaslw-lab on GitHub · 2026-11-30 19:57 UTC · original · approved these changes
Reviewed
2b3459edby reading the diff; not built or run.Verdict: approve. I traced
r64_round,r64_one_minusandr64_fractby hand and found no wrong result. No MUST. The SHOULD is draw rows for branches no row reaches today; it can follow.SHOULD Several word-split branches in the
f64_roundhelper (tools/pixel_aot.py:991-1177) are never reached byF64_ROUND_ROWS. The finite non-integral rows havebits = 1075 − exponentof 1, 51 or 52 only. So:r64_round'sbits == 32branch (unit_hi = 1,half_lo = 0x80000000,odd = hi & 1) is never drawn, and neither isr64_fract'sbits == 32mask.r64_one_minus, no row reachesshift == 32orshift > 32, i.e. a negative input with magnitude in about [2^-53, 2^-32), or a negative |x| ≥ 1 with such a fractional part. No row takes thedownstep either:-0.1has remainder 2 < half 4, and the other negative fractions have remainder 0.I read these as correct, but they are where a word-boundary slip would hide. The 64-bit Python references would catch one, so rows are cheap to add. Suggested rows: ±(2^20 + 0.5), ±(2^20 + 1.5), ±(2^20 + 0.75); fract of −2^-40, −(1 + 2^-40) and −0.3; and one
r64_one_minustie, e.g. −(0.25 + 2^-54), which has remainder = half.Checked, no finding:
1.5ceil →2.0), theoddbit atbits == 52, the rndne 0.5/1.0 boundary, thelength + 969/length − bits + 1022exponents and the ≤ 969 clamp.exp >= 25). Overlapping destinations are safe.Tests:
check_f64_round_controls(Linux LLVM step, passed) pins the emitted calls and the refusals.pixel_aot_f64_round_{warp,hardware}are not in the Windowsprpreset filter, so the draw has only the author's WARP + RX 9060 XT run. The red Linux job isstartup_close_guard_check.py, which fails to compile startup code this PR does not touch.9601449e04to5770f14e6dPull request closed