shader: lower binary64 comparisons on their source words #1342
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1349"
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 R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-24T08:54:04Z.
Change
Lowers the binary64 comparisons:
v_cmp_*_f64for all 16 predicates andv_cmp_class_f64, each in the e32 and e64 encodings (34 forms). The comparison works on the two 32-bit words of each source, so the shader uses no HLSLdouble. That matters because the Windows 10 in-box WARP faults on some double comparisons; see thev_div_fmas_f32helper.Three helpers do the work, and
class64adds the class test:num64detects NaN from the encoding. That includes a signaling NaN whose payload is only in the low word.key64maps every other encoding to an unsigned key with the same order as its value. It inverts negative encodings, sets the sign bit of positive ones, and gives -0 and +0 one key.n*predicates negate them, so they are true on NaN.class64reads the ten classes ofclass32from the encoding.Operand rules:
0, and the binary64 inline constants ±0.5, ±1.0, ±2.0 and ±4.0.-xand|x|are allowed on the comparison sources (they act on the sign bit), but not on the class source.1/(2*pi), literals, the suffix-less spelling, and thev_cmpx_*_f64forms.half_denorm="preserve"entry state, the same declaration the binary16 arithmetic uses.Verification
Commit
46d20eaon upstream0f09ca9. I also checked a trial merge with currentd6cbd5d: the binary mode, the controls and the 8 comparison draws all pass, and git reported no conflicts.Environment: Windows 10 build 19045.6466. NVIDIA GeForce RTX 3080 (10de:2216), driver 32.0.15.9174, and WARP 1.0.22 (Agility SDK 1.620.2), with the debug layer enabled.
ctest --test-dir out/build/w10 --no-tests=error -R '^pixel_aot_cmp_f64_(warp|hardware)$': 2/2 passed, with no skips.python -B tests/pixel_aot_check.py binary <llvm-mc 15> <llvm-objcopy 15> <LLVM-C.dll 15>: exit 0. This runs the controls and the LLVM 15 gfx1013 round trip of the ten new programs.ctestover the 155 record-writing tests with--output-junit: 155/155 passed.tools/form_coverage.pyon that run puts gfx1013 coverage at 960 → 994 of 1968 (+34), with nov_cmp_*_f64gap left. gfx1030 coverage is 984 of 1863.Fixtures and negative controls
pixel_aot_cmp_f64_{warp,hardware}):class64.check_cmp64_controlsandform_coverage_checklistedv_cmp_lt_f64andv_cmp_class_f64as refused neighbours. Those forms now have their own controls, andv_cmpx_lt_f64andv_cmpx_class_f64are asserted as uncovered instead.Assumed, not sourced:
v_cmp_class_f64follow MODE[7:6] the way the arithmetic does.No gfx1013 hardware run checks either assumption. The draws pin the translator's model on desktop adapters only.
This touches lines near #1335 in
tools/pixel_aot.pyandtests/form_coverage_check.py, but the two PRs are independent. If one merges first, the other may need a rebase.Checklist
This change was AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:20:17Z.
Review: COMMENTED
Technical peer-review at commit
46d20eab85e464266755096feea7402b4fb58919.Verification
git diff --check origin/main...HEAD: clean.tests/docs_links_check.py: passed (16 Markdown files, 294 links).tests/bidi_controls_check.py: passed (1108 tracked files).tests/pixel_aot_check.py: passed (138tests,18skipped).tests/rdna2_tools_check.py&tests/form_coverage_check.py: passed.CMPF64_GROUPSbinary roundtrip (llvm-mc-19,llvm-objcopy-19,libLLVM-19.so): 10/10 programs passed. (Fullpixel_aot_check.py binaryon LLVM-19 stops earlier in pre-existingcheck_f16_cvt_int16_binaryonv_cvt_f16_i16_e32 v1, 0xfff0, unrelated to this PR.)--preset dev): 4/4 passed (pixel_aot_cmp_f64_{warp,hardware},pixel_aot_cmp64_{warp,hardware}) in4.89s./O2(--preset release): 4/4 passed in4.94s.tests/form_coverage_check.py: passed (43.4s).Code Review Notes
tools/pixel_aot.py(cmp_f64helpers):num64,key64,lt64,eq64, andclass64accurately model IEEE 754 binary64 ordering, NaN detection (including signaling NaNs with payload only in the low word),-0.0/+0.0equivalence, denormal ordering, and all 10ClassFlagsbits without emitting HLSLdouble.f64_operandrestricts inline constants to0and±0.5, ±1.0, ±2.0, ±4.0, appliese64-x/|x|modifiers on the sign bit (and disallows them one32andv_cmp_class_f64), and enforceshalf_denorm == HALF_DENORM_PRESERVEandv_cmpx_*_f64refusal consistently with the rest of the translator.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:49:44Z.
I pushed
a1a0c149to resolve the overlap with the integer CMPX regions. The merge preserves both comparison helpers and the existing CMPX region controls. On Windows 11 build 26200.9974, form coverage and the integer/binary64 translator controls passed. Bothdraw-cmp-f64anddraw-cmpx-regionspassed on RTX 4060 Laptop (32.0.16.1656) and WARP (10.0.26100.9818) using SDK 26100 DXC and the source-built renderer. GitHub checks are running on the new head.