shader: lower plain binary16 add, sub, subrev and mul in pixel_aot #848
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/854"
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 JB2WIN on 2026-11-23T13:41:29Z.
Change
This adds the first plain binary16 VOP2 slice from #839.
tools/pixel_aot.pynow lowersv_add_f16,v_sub_f16,v_subrev_f16andv_mul_f16in their e32 and_e64spellings. The scope follows the decisions in #839:binary16 operand lacks a finite proof: <tok>, and a NaN/inf constant givesbinary16 operand is not finite: <tok>.binary16 result overflows: v_<op>_f16. Both boundaries are pinned with both signs: 65520 is refused and 65519.99 is accepted.lower(..., half_denorm="preserve"), also exposed as--half-denorm. Without it the four forms are refused withbinary16 denormal mode unknown at entry. MODE writes that could change the denormal field stay refused, and the existing round-toward-zero gate covers all eight spellings.widen16to both low halves, does oneprecisebinary32 operation, thennarrow16. Binary32mulof two halves is exact. Foradd/sub, double rounding through binary32 is harmless (24 ≥ 2·11+2). An offline numpy run over all 4,030,726,144 finite operand pairs ofaddandmulfound 0 differences; that run is not part of CI. CI runs an independent Python reference.("half16", …), separate from integerlow16. Its only readers arev_cvt_f32_f16(e32/e64, without modifiers),v_cvt_f32_f16_sdwawithWORD_0, andv_mov_b32_sdwawithWORD_0. Every other reader is refused, with a control per reader class.clamp, omod, DPP/SDWA spellings and integer inline constants other than 0 are refused.min/maxstay out of scope.v_add_f16_e64refusal neighbour in the controls andform_coverage_check.pyis replaced byv_min_f16_e64, which is still refused.Refs #839. AI-assisted (Claude Code).
Verification
Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, debug layer enabled, at
5d80e54.Draw
draw-f16-arith(pixel_aot_f16_arith_{hardware,warp}). It covers 40 literal operand pairs per op, including chains of proven results. Results are read back losslessly through the integer target and checked against an independent reference. The cases cover halfway rounding, positive and negative subnormals, and signed zero, including(-0)+(-0)and exact cancellation. Programs with subnormal operands also pass under-denorm ftz, because the readers useasuintonly.Mutations. Each of these must report a mismatch and does on both adapters, and a reference-side hook checks before the draw that each one changes an expected word:
An SDWA
WORD_1widen of a result is refused at lowering.Dev-time check (not committed). With the new branch disabled, the new controls fail.
Commands:
ctest --preset dev --no-tests=error -R "^pixel_aot_f16_arith_": 2/2 passed, 33.3 s on hardware.ctest --preset dev --no-tests=error -j4: 435/435 passed. Only capability skips remained (bvh_wave64_*,wave_shuffle_warp,spirv_minlod_*).0xffffas-1. It runs locally withllvm-mcthrough aclang -cc1asshim.form_coverage_check.py,rdna2_tools_check.py,pso_readiness_check.pyanddocs_links_check.pypass.Limits
subrevoperand order and the console's binary16 denormal handling are not measured natively. The destination's high half stays unknown and is guarded only by the refusals.tools/scan_unsupported_shaders.pystill reports these forms as unsupported. That is conservative, since the scanner cannot see the finite proof.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T13:49:26Z.
I refreshed the branch in
c608fc1after #704 and #853. The shared dispatcher retains the divide-FMA, DS NOP and binary16 checks. In an independent run, 80,144 finite-input proof checks matched Python binary16 conversion, and WARP and RTX 4060 Laptop caught all 11 mutations. On the final rebased candidate I reran all three WARP draw modes, the LLVM 15 binary suite, form coverage and docs links. They passed. GitHub CI is running on the updated head.