shader: lower mixed-precision VOP3P FMA in pixel_aot #383
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/389"
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 KomaGuy on 2026-11-22T00:04:50Z.
Change
Lower all three mixed-precision
VOP3PFMA forms intools/pixel_aot.py, covering 3 additionalVOP3Pforms on bothgfx1013andgfx1030:v_fma_mix_f32,v_fma_mixlo_f16, andv_fma_mixhi_f16.op_selselects binary32 (0, default) vs binary16 (1),op_sel_hiselects low (0, default) vs high (1) half for binary16 sources (high-half selection on a binary32 source is rejected),-srcand|src|/abs(src)apply after widening throughwiden16, and optionalclampsaturates to[0, 1]. Inlinef16float constants zero-extend[31:16] = 0matchinggfx1013hardware; unsupported modifiers (neg_lo,neg_hi,mul:2, duplicates, wrong arity) are rejected.v_fma_mixlo_f16writes bits[15:0]while preservingvdst[31:16], andv_fma_mixhi_f16writes bits[31:16]while preservingvdst[15:0](requiringvdstto hold a defined numeric value). Both emit an optionalpack16_rnehelper (bit-exact IEEE-754 binary32→binary16 round-to-nearest-even independent of desktopf32tof16rounding) only when used; existing shaders emit no extra helpers.FMA_MIX_BODYandcheck_fma_mix_drawintests/pixel_aot_check.pyacross 3 constant sets (mixed f16/f32 modifiers, preserved high/low destination halves,[0, 1]clamp, and exact binary16 halfway ties distinguishing RNE from RTZ), 5 negative mutations, and negative controls covering uninitialized destination halves, invalidop_sel_hion f32, WQM, andvmcnt/lgkmcnthazards.Verification
Tested on Linux x86_64 (Python 3.13.5, LLVM 19.1.7, Clang 19.1.7) on top of
9bdbb20:python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so— passed (controls, negative controls, andllvm-mc -mcpu=gfx1013assembly→DXBC/XDAT/XBCH/FSSM→disassembly→lowering parity forFMA_MIX_BODYand all existing fixtures).python3 -B tests/ffx_dispatch_aot_check.py llvm-mc-19 llvm-objcopy-19 libLLVM-19.so— passed.python3 -B tests/script_state_check.py,tests/bcpack_check.py,tests/resource_ranges_check.py,tests/layout_chunks_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py— all passed.tools/form_coverage.pyrecords all 3 forms (v_fma_mix_f32,v_fma_mixhi_f16,v_fma_mixlo_f16) against bothdocs/coverage/gfx1013.tsvanddocs/coverage/rdna2.tsv.FMA_MIX_BODYand all 5 negative mutations (abs,neg,op_sel_hi,mixhihalf preservation,clamp) as C++20 withclang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address— bit-exact match on all 3 constant sets (including odd-mantissa halfway ties distinguishingpack16_rnefrom RTZf32tof16) and all 5 mutations caught; 0 sanitizer errors.dxc -Gis -T ps_6_0), WARP (pixel_aot_warp), and hardware (pixel_aot_hardware) checks were not run locally on Linux; relying on thebuild-and-testWindows CI job to verify DXC compilation and D3D12 WARP readback.Evidence and follow-up
tests/pixel_aot_check.pyare original MIT-licensedgfx1013assembly sequences built from source at test time.v_pk_*_f16) without overlapping its opcodes; remainingVOP3Pfamilies (v_dot*and packed 16-bit integerv_pk_*_i16/u16/b16) stay rejected here for separate focused PRs.Checklist