shader: lower quad-local DPP16 and DPP8 binary16 fmac, ldexp and int16 conversions in pixel_aot #2477
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2485"
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-25T18:13:32Z.
What this changes
Extends the quad-local
DPP16/DPP8binary16 slice (#1971) to lower the six remaining contracted binary16 opcodes (+12 forms acrossgfx1013andrdna2):VOP2DPP16 + DPP8):v_fmac_f16_dpp,v_ldexp_f16_dppVOP1DPP16 + DPP8):v_cvt_f16_i16_dpp,v_cvt_f16_u16_dpp,v_cvt_i16_f16_dpp,v_cvt_u16_f16_dppLowering & contract (
tools/pixel_aot.py)int16_dpp_source()alongsidehalf16_dpp_source()under the existing#839contracts:src0is quad-swizzled viaemit_quad_swizzle_u32;src1and thev_fmac_f16_dppaccumulator stay on the current lane.DPP16allows bit-15abs/negmodifiers on float sources only (src0/src1onv_fmac_f16_dpp,src0onv_ldexp_f16_dppandv_cvt_{i16,u16}_f16_dpp);DPP8and integer operands refuse modifiers.v_fmac_f16_dppusesfma16_rnefor single-rounding fused multiply-accumulate with overflow checked viaf16_pk_fmac_lane_result.v_ldexp_f16_dpprequires a statically proven signed 16-bit exponent in[-64, 64]and checks overflow viaf16_ldexp_result.v_cvt_f16_i16_dppaccepts runtimei16/low16sources;v_cvt_f16_u16_dpprequires a static proof< 65520(f16_cvt_int_result). Both tag destinations("half16", alu)with proven bits when statically known.v_cvt_{i16,u16}_f16_dpptruncates proven in-range binary16 values (f16_to_int_result) into("low16", alu).half_denorm="preserve"andHW_REG_MODERNE remain required.Tests & docs (
tests/pixel_aot_check.py,tests/form_coverage_check.py,docs/experiments.md)pixel_aot_dpp_f16_{warp,hardware}with:fmac_ldexp_dpp16,fmac_ldexp_dpp8,cvt_int16_dpp16,cvt_int16_dpp8) covering fused-vs-non-fused rounding (0x1c01vs0x1c00), subnormal preservation (in both default denorm mode and-denorm ftz), ties-to-even rounding, the65519max finiteu16boundary, truncation toward zero,half16/low16chaining, noisy upper-16 halves, preloaded sentinels, andDPP16-/|.|modifiers, plus 13 numerically distinct mutations (none relying on a signed-zero-only delta).DPP_F16_CVT_I16_LANES) forv_cvt_f16_i16_dppover signed 16-bit lane values{-4, -3, -2, -1}with noisy upper halves (0x1234) across bothDPP16AcrossXandDPP8cyclic rotation, with permutation mutations.check_binary(for LLVM 15 assembly/disassembly round-trip in CI).check_dpp_f16_contract_controlsand existing plain f16 control lists, addscheck_dpp_f16_cvt_fmac_ldexp_forms()intests/form_coverage_check.py, and documents the slice indocs/experiments.md.Verification (Linux)
python3 tests/pixel_aot_check.py: PASS (includingcheck_dpp_f16_contract_controlsand all updated f16 controls).form_coverage_check(check_dpp_f16_cvt_fmac_ldexp_forms,check_dpp_f16_arith_round_forms,check_f16_fmac_ldexp_forms,check_f16_cvt_int16_forms,check_f16_to_int16_forms): PASS (exact +12 forms ingfx1013.tsvandrdna2.tsv, unlowered neighbours excluded).python3 tests/docs_links_check.py: PASS (19 files, 466 links).python3 tests/bidi_controls_check.py: PASS (1,726 files).python3 tests/rdna2_tools_check.py: PASS (156 tests OK, 19 skipped).DPP_F16_CVT_FMAC_LDEXP_MUTATIONSproduce non-zero-sign-only channel diffs.git merge-tree --write-tree --name-only origin/main HEAD&git diff --check origin/main: clean.Windows draws (
pixel_aot_dpp_f16_{warp,hardware}) and LLVM 15check_binaryrun in CI. Synthetic fixture coverage only; console behavior is not measured.AI-assisted: yes.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:47:33Z.
The modifier matrix the comment describes is exactly what the code does — I probed it instruction by instruction
check_binaryneedsllvm-mcwith gfx1013, which I do not have here, so I drove the translator directly with hand-written instruction text through the test file's owntranslate_f16helper (sources defined first, since the DPP sources must be written before they are read):v_fmac_f16_dpp v24, -v20, |v21| quad_perm:…v_fmac_f16_dpp v25, v22, -v23 quad_perm:…v_ldexp_f16_dpp v26, -v22, v28 quad_perm:…v_ldexp_f16_dpp v26, v22, -v28 quad_perm:…Source modifiers are not allowed on -v28v_fmac_f16_dpp v24, -v20, v21 dpp8:[…]Source modifiers are not allowed on -v20v_ldexp_f16_dpp v26, v25, -v28 dpp8:[…]Source modifiers are not allowed on -v28v_cvt_f16_i16_dpp v24, -v20(integer source)Source modifiers are not allowed on -v20v_cvt_i16_f16_dpp v26, -v22(float source)That is the whole rule as stated in the comment — "DPP16 allows bit-15 abs/neg modifiers on float sources (src0 and src1 for fmac, src0 only for ldexp); DPP8 and integer src1 refuse modifiers" — and every clause of it holds on the real code path, including the asymmetric one (fmac takes modifiers on both, ldexp only on src0) that is the easiest to get wrong and the hardest to notice.
The two "accepted" rows that end in a different error (
Unsupported instruction … s_endpgm,Unexpected sample count or missing color export,ldexp exponent out of range: 15360) got past the modifier check — those messages come from later stages, which is the point: the modifier gate said yes.What the fixture itself asserts beyond that
DPP_F16_CVT_FMAC_LDEXP_PROGRAMSis fed tocheck_binaryas translation fixtures, so each program's lowered text is compared against a CPU model of the expected arithmetic — the modifier probes above only show the gate accepts, not that the arithmetic is right. That part I could not run.One suggestion
The
fmac_ldexp_dpp16program exercises-v20with|v21|in one instruction and-v23alone in another, so abs-on-src1 and neg-on-src1 separately both appear. Worth checking whether abs alone onv_ldexp_f16_dpp's src1 is also covered — my probe only triednegthere, and the refusal message is generic (Source modifiers are not allowed on …), so a fixture case would pin thatabsis refused for the same reason rather than by accident of the neg branch.Docs
experiments.mdgrows by 4 lines; the capability claim matches what I measured. NoAGENTS.md/CI-list entry is needed because the check rides on the existingpixel_aotregistration.AI-assisted; all eight probes were run locally on Windows 11 build 26300.9974 on the PR branch head, no GPU needed since this path is pure Python.
Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-25T18:56:54Z.
Thanks @ChazY11 for probing the modifier matrix and the suggestion!
Pushed
ef9c4340adding explicit|v21|andabs(v21)refusal cases onv_ldexp_f16_dpp's integersrc1incheck_dpp_f16_contract_controlsalongside the existing-v21refusal, so both abs spellings are pinned directly. Verified locally on Linux (pixel_aot_check.pyandbidi_controls_check.pypass).Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:16:29Z.
Review: COMMENTED
Review of head
408ce23e7b(comment only; the head is the PR branch updated with main, own change unchanged atef9c4340).Checked against origin/main:
v_fmac_f16_dpp,v_ldexp_f16_dpp,v_cvt_f16_{i16,u16}_dppandv_cvt_{i16,u16}_f16_dpplowerings intools/pixel_aot.pyfollow the same static finite-proof contract as the sibling plain ops and the merged DPP binary16 ops (#419, #1971). DPP8 refuses float modifiers, integer sources refuse them too, the ldexp exponent needs a static proof within the limit, and overflow of the proven result is refused.check_dpp_f16_draw(D3D12 WARP and hardware), with per-lane i16 routing and op/modifier mutations that must report a mismatch, in default and-denorm ftzmodes.Commands run:
tests/pixel_aot_check.pyPASS,tests/docs_links_check.pypass,tests/bidi_controls_check.pypass,git diff --check origin/main...HEADclean.tests/form_coverage_check.pyneedsiced_x86, not available on Linux here; it passed on Win2025.trunc->round): the Linux check FAILS.127 + exponent->128 + exponent): the Linux check still passes, because the numeric result is only proven by the WARP draw. That draw is covered by the Win2025 run below (receipt on this head).ctest -R 'pixel_aot_dpp_f16|pixel_aot_dpp_cvt|pixel_aot_f16'14/14 passed in both.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:16:30Z.
Win2025 WARP receipt for head
408ce23eafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
408ce23e7bb7c828fdb22278dfd0a21b8fa6e9f8:--preset dev):cmake --build --preset dev -- -j 2):0.00s(configure0.00s)ctest --preset dev -R 'pixel_aot_dpp_f16|pixel_aot_dpp_cvt|pixel_aot_f16' --parallel 2 --no-tests=error --output-on-failure): 14/14 passed (45.55s:pixel_aot_f16_arith_warp6.56s,pixel_aot_f16_arith_hardware6.63s,pixel_aot_f16_round_warp4.68s,pixel_aot_dpp_f16_warp7.72s,pixel_aot_f16_round_hardware9.37s,pixel_aot_f16_fmac_ldexp_warp8.24s,pixel_aot_f16_fmac_ldexp_hardware4.23s,pixel_aot_dpp_cvt_warp3.01s,pixel_aot_f16_cvt_int16_hardware2.91s,pixel_aot_f16_cvt_int16_warp2.97s,pixel_aot_f16_to_int16_hardware7.20s,pixel_aot_dpp_cvt_hardware7.73s,pixel_aot_f16_to_int16_warp2.33s,pixel_aot_dpp_f16_hardware9.16s)/O2(--preset release):cmake --build --preset release -- -j 2):0.00s(configure0.00s)ctest --preset release -R 'pixel_aot_dpp_f16|pixel_aot_dpp_cvt|pixel_aot_f16' --parallel 2 --no-tests=error --output-on-failure): 14/14 passed (40.40s:pixel_aot_f16_round_warp6.09s,pixel_aot_f16_arith_warp8.69s,pixel_aot_f16_fmac_ldexp_warp6.00s,pixel_aot_f16_cvt_int16_warp3.78s,pixel_aot_dpp_cvt_warp3.88s,pixel_aot_dpp_f16_warp11.22s,pixel_aot_f16_to_int16_warp3.15s,pixel_aot_dpp_cvt_hardware3.98s,pixel_aot_f16_arith_hardware8.63s,pixel_aot_dpp_f16_hardware9.65s,pixel_aot_f16_fmac_ldexp_hardware4.49s,pixel_aot_f16_round_hardware5.31s,pixel_aot_f16_to_int16_hardware2.22s,pixel_aot_f16_cvt_int16_hardware3.01s)tests/form_coverage_check.pyok (15.1s),tests/mesh_clip_cull_check.pyok (6.5s),tests/mesh_dynamic_geometry_check.pyok (0.3s),tests/mesh_heap_sampler_check.pyok (1.2s),tests/pso_readiness_check.pyok (1.3s),tests/rdna2_tools_check.pyok (3.4s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.6s),tests/startup_gfx2hlsl_f32_nan_check.pyok (6.6s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (10.2s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (5.5s),tests/startup_image_load_d16_check.pyok (1.1s),tests/startup_image_sample_a16_check.pyok (0.2s),tests/vk_offscreen.pyok (1.6s)sccache: 2/100 hits; wall154.6sAI-assisted; commands listed were executed locally.