shader: lower the remaining binary16 VOP2 and VOP3 arithmetic #3594
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3594"
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 lambirou on 2026-11-30T12:11:22Z.
Part of the f16 slice (Refs #839).
This adds the remaining binary16 VOP2 and VOP3 arithmetic forms:
v_dot2c_f32_f16,v_fmaak_f16,v_fmamk_f16(VOP2) andv_fma_f16,v_fmac_f16_e64,v_ldexp_f16_e64,v_div_fixup_f16(VOP3).The multiply-add forms use
fma16_rneand round once;v_fmac_f16_e64reads the destination as the accumulator;v_ldexp_f16_e64keeps the e32 exponent range [-64, 64] and its overflow rule;v_dot2c_f32_f16requires two proven finite half words and a proven finite binary32 accumulator, follows the direct-compute model and the subnormal correction;v_div_fixup_f16prefers the S2 NaN and returns0xfe00for 0/0 and Inf/Inf. The existing guards stay: entry EXEC, destination 0..255, no outstanding sample,half_denorm="preserve", refusal under round-toward-zero, and refusal of modifiers,clamp,omod,op_sel, DPP and SDWA.Tests
pixel_aot_f16_vop23_warpand_hardwarepass: 46 programmes plus 20-denorm ftzrepeats over exact/inexact values, negatives, signed zeros, subnormals, binary32 ties both ways, fused-vs-unfused discriminants, subnormal binary32 accumulators, destination aliasing, thediv_fixupspecial cases, four readers and two chains. Seven mutations each reportpixel_mismatch(fused made unfused, accumulator dropped, high-half read, dot2c accumulator read as a half lane,div_fixupsign reduced to S1,0xfe00cases removed, ldexp exponent negated) on WARP and on the RX 9060 XT (driver 32.0.32029.2010).check_f16_vop23_controlscovers spelling, operand kinds, proofs, ranges, mode, scheduling, readers and exact refusal messages;form_coverage_check.pypins exactly the seven forms and leaves conversions, packs, interpolation and SDWA uncovered.rdna2_tools_check.pypasses 162 tests (19 LLVM-dependent skips);draw-f16-arithanddraw-f16-fmac-ldexpstill pass on both adapters.Limits
The high half of the destination is not observed; runtime operands stay refused by the static proof, including the dot2c accumulator; arithmetic NaN/infinity sources other than
v_div_fixup_f16are refused; dot2c routing under a partial EXEC mask and hardware overflow beyond the translator's refusal are not measured. No title is known to execute these forms.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T20:44:24Z.
Review: APPROVED
Reviewed
8d1e8bbcby reading the diff; not built or run.Verdict: approve. The seven lowerings match their stated models, and every operand is static and proven. No MUST. The SHOULD is a docs conflict and can follow.
v_fma_f16refusal that #704 added on purpose ("Unverified v_fma_f16 binary16 FMA semantics"). The #704 paragraph indocs/experiments.mdis still in place and says thatpixel_aot"rejectsv_div_scale_f32andv_fma_f16(including explicit_e64spellings)… until verified by source-built native RDNA readbacks". After this PR the docs contradict the code. The single-rounding half of #704's condition is now covered: the0x3c69·0x3faa + 0x89d1row pins0x4039against the unfused0x403a. High-half preservation is handled by thehalf16reader contract. But the readbacks are desktop, not RDNA. Please rewrite that paragraph, keepingv_div_scale_f32rejected, and state that the native-readback condition is being lifted forv_fma_f16. That last part is the maintainer's call.v_div_fixup_f16matches the ISA order: S2 NaN, then S1 NaN (quieted with| 0x200), then 0/0 and Inf/Inf giving0xfe00, then S1 = 0 or S2 = Inf giving ±Inf, then S1 = Inf or S2 = 0 giving ±0, else|S0|withsign(S1) ^ sign(S2). The helper's overwrite order produces exactly that precedence, and the HLSL and Python copies are identical.fmamkisS0·K + S1andfmaakisS0·S1 + K, which matches LLVM's printed operand order. Only K's low half is read, and it must be finite.fmac_e64readsDbefore writing it.dot2c: both products are exact in binary32, including subnormal halves (2^-48 is normal), with one rounding for the sum and one for the accumulator add. Desktop flushing of a subnormal accumulator only matters when the sum is ±0, anddkcovers that.preciseprevents fusion.ldexp_f16_e64: the exponent is limited to [−64, 64], sowiden16·2^estays a normal, exact binary32 beforenarrow16.Tests: 46 programs plus 20
-denorm ftzrepeats, and seven mutations including fused→unfused and thediv_fixupspecial cases. The controls run in the Linux LLVM job (passed).pixel_aot_f16_vop23_{warp,hardware}are not in the Windowsprpreset filter.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T23:54:55Z.
Review: COMMENTED
Independent exact-head Windows checks passed for
c48f4dd9: the pixel translator, form coverage, anddraw-f16-vop2-vop3-arithon both WARP and RTX 4060 Laptop. All seven built-in mutations mismatched on each adapter. Since #3651 merged,git merge-treeagainstmain72cc7c7fshows one conflict in the CLI dispatch tuple at the end oftests/pixel_aot_check.py. Please retain bothdraw-sopp-denorm-modeanddraw-f16-vop2-vop3-arithwhen merging current main.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T23:58:05Z.
I tested that merge resolution locally against
72cc7c7f. Keeping both CLI entries passes the Python translator and form-coverage checks.draw-f16-vop2-vop3-arithanddraw-sopp-denorm-modeboth pass on WARP and RTX 4060 Laptop, 4/4 across the two selectors, with all seven f16 arithmetic mutations still caught on each adapter. The PR branch still needs the conflict resolution so GitHub can run the integrated checks.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T00:05:01Z.
Review: APPROVED
Re-reviewed
2cdb4381. The conflict resolution keeps both CLI modes. I compared this head with the independently tested merge tree onto72cc7c7f: its only difference is one blank line in the dispatch list. The Python translator and form-coverage checks passed on that tree. Both draw modes passed on WARP and RTX 4060 Laptop (4/4), with all seven binary16 arithmetic mutations caught on each adapter. This head merges cleanly.