pixel_aot: lower 25 exact binary16 min, max, fract, and frexp forms #2570
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2578"
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-25T21:37:10Z.
Summary
Lowers 25 exact binary16 forms across all 5 GFX10/RDNA 2 encodings (
VOP1/VOP2,VOP3_e64,DPP16,DPP8,SDWA) intools/pixel_aot.py(counted in bothdocs/coverage/gfx1013.tsvanddocs/coverage/rdna2.tsv), with static contract controls,pixel_aot_f16_exact_extra_{warp,hardware}draw tests, LLVM 15check_binaryfixtures, andform_coverage_checkcoverage assertions:v_min_f16,v_max_f16(10 forms):VOP2(_e32/bare),VOP3_e64,DPP16,DPP8,SDWAv_fract_f16(5 forms):VOP1(_e32/bare),VOP3_e64,DPP16,DPP8,SDWAv_frexp_mant_f16,v_frexp_exp_i16_f16(10 forms):VOP1(_e32/bare),VOP3_e64,DPP16,DPP8,SDWAContracts & Semantics
half_denorm="preserve", refuseHALF_RTZ(viaHW_REG_MODE), and enforce the static finite-proof contract (half16_arith_source,half16_dpp_source,half16_sdwa_source).v_min_f16/v_max_f16: Compare finite 16-bit bit patterns directly in signed integer order (f16_min_bits/f16_max_bitshelpers) so subnormals and-0.0are preserved bit-for-bit even under-denorm ftz, while opposite-signed zeros (+0.0vs-0.0) are refused statically.v_fract_f16: Computesnarrow16(widen16(x) - floor(widen16(x)))and statically refuses tiny negative inputs (-2^-11 < x < 0, bit patterns0x8001..0x93ff) where1 + xis not representable on the binary16 grid (so every accepted input is exact in binary16).v_frexp_mant_f16/v_frexp_exp_i16_f16: Pure 16-bit integer decomposition (frexp_mant_f16/frexp_exp_i16_f16helpers) preserving subnormals and-0.0.v_frexp_mant_f16produces("half16", alu)(withknown_halffor chaining) andv_frexp_exp_i16_f16produces("low16", alu)(or full 32-bitknown_ssa_bitswords under SDWAWORD_0/WORD_1UNUSED_PAD/UNUSED_PRESERVE).Verification
python3 tests/pixel_aot_check.py(including newcheck_f16_exact_extra_controls)form_coverage_check:check_f16_exact_extra_forms(+25 forms ingfx1013.tsvandrdna2.tsv, unlowered neighbours excluded, single-opcode removal control) + all existing f16/DPP/SDWA coverage checksplain_e32,plain_e64,dpp16,dpp8,sdwa) and all 20 mutations + inspection of generated HLSLpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,python3 tests/rdna2_tools_check.py(156 tests OK)git merge-tree --write-tree --name-only origin/main HEADandgit diff --check origin/mainpixel_aot_binaryassembly/disassembly round-trips for all 5F16_EXACT_EXTRA_PROGRAMSfixturespixel_aot_f16_exact_extra_warp/pixel_aot_f16_exact_extra_hardwaredraws (both default denorm mode and-denorm ftz+ all 20 mutations)Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:42:43Z.
Review: COMMENTED
Review of head
ad6e22fe(main merged into the PR; the PR's own diff is the same 6 files as before). Comment only.Result: sound. I found no blocking issue.
What I checked:
tools/pixel_aot.py: the 25 forms needhalf_denorm="preserve", refuseHALF_RTZ, and keep the static finite-proof contract. min/max compare the bit patterns, so subnormals and -0.0 are kept. Opposite-sign zeros are refused. fract refuses the tiny-negative range.check_f16_exact_extra_controlsplus thepixel_aot_f16_exact_extra_{warp,hardware}draw tests (real draw readback against a CPU reference, with built-in mutations that must be caught).form_coverage_checkhas new coverage assertions.0x9400to0x9300(line 1894) makescheck_f16_exact_extra_controlsfail.docs/experiments.mdandCMakeLists.txtare all updated.Not run here:
tests/form_coverage_check.pyneedsiced_x86, which is not installed on this Linux box. The Windows run covers it.Commands run:
python3 tests/pixel_aot_check.py(pass)python3 tests/rdna2_tools_check.py(OK, 19 skipped)python3 tests/docs_links_check.pypython3 tests/bidi_controls_check.pygit diff --check origin/main...HEADgit checkout -- .AI-assisted; commands listed were executed locally.
upstream-sync referenced this pull request2026-11-25 23:01:48 +00:00
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:18:14Z.
Win2025 WARP receipt for head
ad6e22feafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
ad6e22fed9ec7621392e67b0e995b956ec9c3685:--preset dev):cmake --build --preset dev -- -j 2):707.05s(configure2.20s)ctest --preset dev -R 'pixel_aot_f16_exact_extra_warp|pixel_aot_check|form_coverage' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (20.72s:pixel_aot_f16_exact_extra_warp11.32s,form_coverage20.52s)/O2(--preset release):cmake --build --preset release -- -j 2):947.86s(configure3.95s)ctest --preset release -R 'pixel_aot_f16_exact_extra_warp|pixel_aot_check|form_coverage' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (16.96s:pixel_aot_f16_exact_extra_warp8.97s,form_coverage16.77s)tests/form_coverage_check.pyok (17.9s),tests/mesh_clip_cull_check.pyok (9.0s),tests/mesh_dynamic_geometry_check.pyok (0.4s),tests/mesh_heap_sampler_check.pyok (1.1s),tests/pso_readiness_check.pyok (1.4s),tests/rdna2_tools_check.pyok (4.1s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.4s),tests/startup_gfx2hlsl_f32_lg_check.pyok (2.0s),tests/startup_gfx2hlsl_f32_nan_check.pyok (9.6s),tests/startup_gfx2hlsl_fma_mix_check.pyok (0.4s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (14.2s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (9.8s),tests/startup_image_load_d16_check.pyok (1.2s),tests/startup_image_sample_a16_check.pyok (0.1s),tests/startup_ngg_slice_check.pyok (0.3s),tests/vk_offscreen.pyok (1.3s)sccache: 477/4568 hits; wall1769.9sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by alvaroolt on 2026-11-25T23:07:14Z.
Hardware results for the merged change. Until now only WARP had been run.
Tested
mainatb41f6fca, which contains this PR's merge commitaf172024. The machine runs Windows 11 build 26300 with MSVC 14.52, Windows SDK 10.0.26100 and DXC 1.9.2602.17. The D3D12 debug layer is not available (Graphics Tools not installed).devreleaseXBOX2WINDOWS_ADAPTER=Radeon)In every run,
pixel_aot_f16_exact_extra_{hardware,warp}passed and all 20 mutations reportedmismatch: 120 of 120 across the six runs, none escaped. The other binary16 draws (pixel_aot_f16_{arith,round,fmac_ldexp,cvt_int16,to_int16}_*) also passed on all three adapters in both presets. There were no capability skips. The LLVM 15 round trip (tests/pixel_aot_check.py binary, LLVM 15.0.7) exited 0.Commands, from a dev shell (
.\tools\dev.ps1):As an independent cross-check, I had written a separate lowering of only the VOP2/e64
v_min_f16/v_max_f16forms before this PR landed. It also refused opposite-signed zeros. Its own draws, with a CPU reference and min/max-swap, unsigned-compare, flush and high-half mutations, passed on the same three adapters. It is not being submitted, because this PR covers it.This comment was AI-assisted (Claude Code); I reviewed the commands and the results.