shader: lower v_fract_f64 in direct compute #3639
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!3639
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3637"
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?
@Ammmae0x on GitHub · 2026-11-30 19:02 UTC · original
Ammmae0x:shader/direct-fract-f64→main· +930 −2 · 6 files · 3 commits · merged 2026-12-01 01:17 UTCRefs #2935, #3520
Lowers
v_fract_f64(VOP10x3e, VOP30x1be) in the direct C++ compute path with pure 32-bit integer operations only: no DXILdouble, noi64in@main(), nofcmp, and neitherDoublePrecisionFloatShaderOpsnorInt64ShaderOps.What changed
src/gfx1013_direct_compute.inl: newfloat_aluhandler forv_fract_f64, ending withreturn true;.fract(x) = x - floor(x)is always in[0, 1): NaN is quieted (hi | 0x80000),±Infgives+qNaN(0, 0x7FF80000),±0.0and|x| >= 2^52give+0.0(-0.0becomes+0.0, matchingv_fract_f16), and a positive|x| < 1passes unchanged (including subnormals). A negative|x| < 1givesRNE(1 - |x|)clamped strictly below1.0(0x3FEFFFFFFFFFFFFF): for|x| <= 2^-54RNE(1 - |x|)rounds to1.0and clamps to it, and for2^-54 < |x| < 2^-53RNE(1 - |x|)is already0x3FEFFFFFFFFFFFFF, so allexp < 970return it; for970 <= exp <= 1021the 53-bit significand is shifted right byr = 1022 - exp([1, 52], splitwide = r >= 32likev_ldexp_f64), rounded to nearest2^-53, then subtracted from2^53(biased exponent always1022); forexp == 1022the exact diff(0x00100000, 0) - (field, lo)is normalized left. For1023 <= exp <= 1074the bottom1075 - expfractional bits are extracted acrosshi/lo/maskedlo; an exact integer gives+0.0, a positive fraction is normalized directly, and a negative fraction first takes the exact 64-bitunit - fracand then shares the same 6-step{32, 16, 8, 4, 2, 1}normalizer (biased exponentexp - steps). Every DXIL shift amount is clamped to[0, 31]in every lane.pixel_stage,graphics_input,i.subword,i.dpp_control,permuted,i.clamp,i.scaleand the wide-form S1/S2 bits; MODE gate refuses a non-default rounding/denormal mode, withv_fract_f64added tohalf_binaryin the MODE scan loop; S0/D must be 64-bit register pairs (VGPR pairs, aligned even SGPR pairs, integer0(128), inline f64 constants240..247);absthennegact on bit 63 before the split.src/gfx1013_compute_native.cpp:v_fract_f64added to thepairlist inclear_vector_spills, so a symbolic lane spilled into either half refuses the pair write.Tests
New
tests/native_fract_f64_check.py(model/ir/controls/hardware) +tests/cmake/native_fract_f64.cmake+tests/checks/python-linux/native_fract_f64.txt+docs/experiments/native-direct-fract-f64.md.model: 74 boundary values (±0.0,±MIN_SUB,±2^-55,±2^-54,±(2^-54 + 1ulp),±2^-53,±(2^-53 + 2^-54),±(2^-53 + 1ulp),±(0.5 - 2^-54),±(0.5 - 2^-53),±0.5,±(0.5 + 1ulp),±0.75,±(1 - 1ulp),±1.0,±1.25,±1.5,±(1 + 2^-52), cross-wordexp = 1042/1043/1044,±(2^52 - 1),±(2^52 - 0.5),±2^52,±DBL_MAX,±Inf,±sNaN,±qNaNwith payloads,±(2^-52 + 2^-54)) x plain/abs/neg/abs+neg against an independent exactFractionRNE reference (min(round_exact(Fraction(x) - floor(Fraction(x))), 0x3FEFFFFFFFFFFFFF)); 12 self-mutations killed (clamp,neg_zero,tiny_round,rndne_tie,exp1022,int_zero,neg_sub,unit_hi,unit_lo,pos_neg,inf_nan,absneg). Spot checks:-(0.5 - 2^-54)gives0.5,-(2^-53 + 2^-54)gives1.0 - 2^-52.ir: boundary values + seeded sweep of 100 random doubles in one e32 dump (348 stores), e64 forms (SGPR pairs,128,240..247, abs/neg/abs+neg) in a second dump, and the boundary values as a wave64 container (text-only:{i32 64, i32 1, i32 1}, no@waveExchange, nodouble/i64/fcmp); exact DXIL needles (1072693247,1071644672,2146959360,2097152,1048575,2147483648).controls: compiles the four hardware programs and checks@main()has nodouble,i64orfcmp; 20 forms refused with exact error substrings, including symbolic spills inv10andv11; the truncating (x - trunc(x)), flushing-subnormal and uncapped-1.0references each differ.hardware: 4 programs x 4 cases x 2 words on a 32-byte case stride, NaNs compared by class, 77 on missing caps.Linux verification
tests/native_fract_f64_check.py model: 74 values x abs/neg/absneg matched the Fraction reference; 12 self-mutations killed.[0, 31]in every lane.tests/form_coverage_check.py,tests/docs_links_check.py(188 files / 740 links),tests/bidi_controls_check.py(2744 files): pass.tools/run_checks_parallel.py --from-dir tests/checks/python-linux: 72/72.git merge-tree --write-tree origin/main HEADexits 0;git diff --checkclean; zero personal paths in the diff.The C++ executions (
ir/controls/hardware) run in the WIN-VERIFY round; this host cannot compile the TU or run Windows CTest.WIN-VERIFY fix round (
b56e7b99)Windows verification of
2a5d110epassednative_fract_f64_controlsand caught 2 bugs, both fixed here:0x3FEFFFFF(1.0 - 1ulphigh word) is1072693247, not1071644671(0x3FDFFFFF, ~0.5). Fixed insub_neg_hi(src/gfx1013_direct_compute.inl), in their/wave64/controlsneedles (tests/native_fract_f64_check.py) and indocs/experiments/native-direct-fract-f64.md, with a comment pinning the value ((0xFFFFFFFF, 0x3FEFFFFF) = 1 - 2^-53). The Python model already used the correct hex constant, which is why the Linux model passed while the emitted DXIL constant was wrong.native_store_replay --directreturns an 8256-byte (2064-DWORD) buffer (8 header guards +64 * 32+ 8 tail words).OUTPUT_WORDSis now2064(tests/native_fract_f64_check.py:46).With these two fixes, Windows
devandreleaseboth pass 3/3 including hardware.Merge with upstream/main (
1de4c6b3)Windows verification of
b56e7b99passeddevandrelease3/3, includingnative_fract_f64_hardwareon RTX 4050, and all Python checks. PR #3636 then merged intoupstream/main(d5970858), causing a 1-line conflict inclear_vector_spills(src/gfx1013_compute_native.cpp): the merge keeps bothv_frexp_mant_f64(upstream) andv_fract_f64(this branch) in thepairlist.src/gfx1013_direct_compute.inlmerged cleanly; thev_fract_f64lowering is untouched. Linux on the merge: model passes, form/docs/bidi pass (193 files/745 links, 2766 files),diff --checkclean, merge-tree exits 0.Windows Verification (
1de4c6b3)1de4c6b3f864ddb07d1f232102b9a5dd8cb18979(git merge-tree --write-tree upstream/main HEADexit0,git diff --checkexit0).NVIDIA GeForce RTX 4050 Laptop GPU(vendor=10de device=28e1, driver32.0.15.9186).XBOX2WINDOWS_ADAPTER=NVIDIA):dev: 3/3 passed in4.16 s(native_fract_f64_ir0.83 s,native_fract_f64_controls1.45 s,native_fract_f64_hardware1.77 s— 4/4 dispatches matched 2064 words each).release: 3/3 passed in4.27 s(native_fract_f64_ir0.62 s,native_fract_f64_controls1.42 s,native_fract_f64_hardware2.05 s).native_fract_f64_check.py model(74 values x abs/neg/absneg, 12 mutations killed),form_coverage_check.py,docs_links_check.py(193 files, 745 links),bidi_controls_check.py(2764 files) all passed.d5970858into shader/direct-fract-f64 1de4c6b3f8@R0Y00 on GitHub · 2026-12-01 01:14 UTC · original · approved these changes
Reviewed binary64 fract through the default MODE guard and paired 32-bit integer lowering. The fixture covers signs, the negative clamp below one, special values, paired register bounds, and the refusal paths.
ctest --test-dir <build> --no-tests=error -j1 -R '^native_fract_f64_(ir|controls|hardware)$' --output-on-failurepassed IR, refusal controls and RTX 4060 Laptop readback.