shader: lower quad-local DPP16 and DPP8 binary16 ops in pixel_aot #413
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/419"
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-22T01:07:04Z.
Change
Lower quad-local
DPP16(quad_perm) andDPP8(dpp8) forms for all 23 binary16VOP1/VOP2operations intools/pixel_aot.py, covering 23 additionalDPP16and 23 additionalDPP8forms (+46 forms on bothgfx1013andgfx1030):v_*_dppinstructions (23):v_cvt_f16_f32_dpp,v_ldexp_f16_dpp,v_frexp_mant_f16_dpp,v_frexp_exp_i16_f16_dpp.v_add_f16_dpp,v_sub_f16_dpp,v_subrev_f16_dpp,v_mul_f16_dpp,v_min_f16_dpp,v_max_f16_dpp,v_fmac_f16_dpp.v_floor_f16_dpp,v_ceil_f16_dpp,v_trunc_f16_dpp,v_rndne_f16_dpp,v_fract_f16_dpp.v_log_f16_dpp,v_exp_f16_dpp,v_rcp_f16_dpp,v_sqrt_f16_dpp,v_rsq_f16_dpp,v_sin_f16_dpp,v_cos_f16_dpp.src0asuintbits via SM 6.0 quad intrinsics, preservesvdst[31:16]pergfx101316-bit destination semantics (rejecting uninitialized destination VGPRs), and packs binary16 results with an optionalpack16_rnehelper (plusmin16_num/max16_num,fract16, and exact bit-leveldpp_ldexp_f16/dpp_frexp_{mant,exp}_f16helpers emitted only when used).v_sin_f16_dppandv_cos_f16_dppscale turn inputs by2π.DPP8,row_*/wave_*controls, partial masks (row_mask/bank_mask != 0xf), source modifiers onDPP8and onv_ldexp_f16_dpp'si16exponent operand, non-VGPR operands, WQM, andvmcnthazards.DPP_F16_BODYderives binary16 quad lane ID{0, 1, 2, 3}fromuv.x/uv.y, tests all 23 forms across 2 constant sets (with junk in the high 16 bits of inputs), and checks 5 negative mutations (AcrossXvsAcrossY, cyclicdpp8rotation,rndnetie-to-even,sinvscosturns, andDPP16negation).Verification
Tested on Linux x86_64 (Python 3.13.5, LLVM 19.1.7, Clang 19.1.7) on top of
6549244: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 forDPP_F16_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 23DPP16and 23DPP8forms against bothdocs/coverage/gfx1013.tsvanddocs/coverage/rdna2.tsv.DPP_F16_BODYand all 5 negative mutations on a 4-lane SIMT 2×2 pixel quad C++20 harness withclang++-19 -std=c++20 -O2 -Wall -Wextra -Wpedantic -Werror -fsanitize=undefined,address— bit-exact match across all 4 quad lanes on both constant sets 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 quad readback.Evidence and follow-up
tests/pixel_aot_check.pyare original MIT-licensedgfx1013assembly sequences built from source at test time.f32/move/selectDPPforms) and #414 (23 integer/bitwise/shiftDPPforms) with zero opcode overlap (combined66/101DPP16+66/101DPP8).Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T18:20:26Z.
Review: COMMENTED
Ran the Windows gates the author could not (Linux-only environment) on Windows 11 build 26300.10075, RTX 5070 (10de:2f04) driver 32.0.16.2135, in-box WARP 10.0.26100.10068, debug layer enabled.
Results:
tests/pixel_aot_check.pycontrols: pass.tests/form_coverage_check.py: pass. LLVM 15 gfx1013 binary round-trip: pass.pixel_aot_warp: pass (12.38s, debug_errors=0).pixel_aot_hardware: the newcheck_dpp_f16_drawitself ran and passed on the RTX 5070 (it is invoked beforecheck_dpp_drawincheck_render, which is where the test aborts). DXC compiles the generated HLSL and all five mutations reportpixel_mismatchas designed.One non-code issue: the run then fails in the pre-existing f32
dppfixture withTranslated pixel pipeline failed (HRESULT 0x8007000e)on the RTX 5070. That failure is a stale-base artifact, not a defect in this change: upstreamb7a0597(#569) already fixed this exact NVIDIA PSO failure by switching thedppfixture tomode="any", and it is not in this branch's merge base (579f58f). A fresh merge or rebase onto currentmainshould turn the hardware run green. The PR's ownmode="any"commit fordpp_f16is incidentally the same remedy.Semantic review of the new code:
DPP_F16table is faithful: f16 ops pack viapack16_rneand merge withvdst[31:16]preserved (dpp{i}_hi | dpp{i}_lo), matching gfx1013 16-bit destination semantics.v_fmac_f16_dppcorrectly accumulatesprev_valof the destination VGPR;v_ldexp_f16_dppsign-extends the low-16 exponent operand;v_cvt_f16_f32_dppreads its source as f32 rather thanwiden16— all three special cases handled.allow_mods = not is_dpp8enforces the ISA rule that DPP8 forms take no source modifiers.fract16,dpp_ldexp_f16,dpp_frexp_*_f16are bit-exact helpers (zero/inf/NaN passthrough, exponent clamps, mantissa forced into [0.5,1)), consistent with the f32 frexp/ldexp approach documented in experiments.v_*_f16_dppmnemonics are auto-denied inside exec-masked regions by the existing_dpppattern inREGION_DENIED— correct, since quad-local ops are not pure per-lane.No blockers on the change itself; flagging only the stale base for the hardware gate.
AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.
Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-22T12:22:58Z.
Refreshed onto
main(579f58f), reusing the shared DPP helpers from #408 andcompile_shader. All 4/4 CI checks are green (9a773f3). Holding #421, #423, and #428 until this lands.Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-22T13:05:03Z.
Updated
check_dpp_f16_draw(96fa78f) to compile withmode="any"and assertflush_ftz(word) == wordon every expected word (matching #363'scurveexception and #569 fordpp, sinceDPP_F16_BODYalso exerciseslog2/exp2/rcp). All 4/4 CI checks are green.Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T17:43:33Z.
@KomaGuy Independent AMD (RDNA4, native wave64) result on
96fa78f. Measurements only, no code change.Environment
native_wave_width=64 logical_width=64measured in the same worktree (bvh_waves_hardware); thepixel_aotharness does not print the wave width itself.debug_layer=unavailable(Tools.Graphics.DirectXisNotPresenthere)96fa78f, whose last commit istests: use mode="any" for dpp_f16 draw fixture— so this run covers the fixture after that change, not before it.Commands
Observed
pixels=4096 channels=16384and one atpixels=64 channels=256, every onemax_absolute_error=0.max_absolute_error=0.What it establishes
The binary16 quad-local ops produce bit-identical output to the CPU reference on a native wave64 adapter, with the
mode="any"fixture in place. Half-precision conversions and comparisons are sensitive to flush and rounding behaviour, so a vendor difference here would surface as a small non-zero absolute error rather than a failure to compile — none appeared across 16,384 channels per draw, on both the hardware and the WARP backend.Limit
The harness prints per-draw counters but no per-program label, so this is a whole-suite result rather than a per-form attribution. And this run is on the PR head only: the tree has no per-case
dpp_f16breakdown in its output.AI-assisted; runs executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-22T18:50:06Z.
Independent RTX 3060 Ti run on
96fa78f179100803c0a535366e04165bfbdb6264. Windows 10 22H2 build19045.6466, MSVC19.44.35230, Windows SDK10.0.26100.0, DXC1.8.2502.11. D3D12 debug layer unavailable.10de:2414), driver621.24(32.0.16.2124via DXGI). The full suite passed, including the existing FP32check_dpp_draw.1414:008c), driver10.0.19041.5794. The full suite passed.I also ran
check_dpp_f16_drawdirectly on each backend. The two expected RGBA values were(9.5, 32.5, 16.0, 3.125)and(6.25, -23.5, 27.0, -2.25). Both draws matched all 4,096 pixels on both backends with zero absolute error. All five shader mutations returned exit 1 withpixel_mismatch.AI-assisted. All tests were run locally.
Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-22T20:13:26Z.
Thanks @thepatrickworld (RX 9070 XT wave64), @rwZephyr (RTX 3060 Ti), and @MarlomMedeiros (RTX 5070 + semantic review) for the independent hardware runs!
Merged latest
main(b5509fe, which includes #569'sdppfix) into this branch at64c4329so the full RTX 50-series hardware gate is green too. CI is running now.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T08:56:55Z.
I fast-forwarded the branch to
68603ab. The merge preserves the existing binary fixtures and puts the new DPP half-float draw in its ownpixel_aot_dpp_f16_*CTest. I also reproduced a raw mismatch that the aggregate color missed: WARP returned0x8001forv_cos_f16(0.25)before the fix, where AMD's RDNA 2 ISA reference gives0x0000. The updated fixture checks the exact words for quarter turns, largest finite values, signed zero and infinities, plus the wrong-word control. LLVM 15 round-trip, WARP and RTX 4060 Laptop passed locally. The destination high-half sentinel checks what the translation does. If you have a DPP-specific gfx1013 reference or native readback for that preserved upper half, please link it here for review before merging.Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-23T10:53:00Z.
@R0Y00 Thanks for fast-forwarding and catching that v_cos_f16(0.25) mismatch! I don't have a native gfx1013 readback or a DPP-specific reference for the preserved upper half on hand. I'm away from my PC for ~8 hours, so feel free to merge as-is if the current sentinel check looks good to you, or let me know if you'd like me to dig into the ISA docs once I'm back.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T17:19:13Z.
Measured on RDNA4 at
68603ab: the sentinel check works, andsinat half turns lands on an f16 subnormal that the two backends disagree about.Environment and result
Windows 11 25H2 (build 26200.9711), MSVC 19.44 + DXC, adapter AMD Radeon RX 9070 XT (vendor
1002, device7550), driver32.0.32029.2010,debug_layer=unavailable, head68603ab, clean build.pixel_aot_dpp_f16_hardwarePassed 3.47 s,pixel_aot_dpp_f16_warpPassed 2.62 s, and the pre-existingpixel_aot_hardwarePassed 15.27 s (no regression). The new CTest entry registers correctly.Two mutations
1. Destination high half zeroed (
dpp_hi = asuint(...) & 0u):pixel_aot_dpp_f16_hardwarefails, all five trig rows reportpixel_mismatch. So the sentinel incheck_dpp_f16_trig(0x3f400000) genuinely pinsvdst[31:16]— the first fixture in this series where that claim is observable at all. The hardware also confirms it independently: witht = 0.25, channel 0 comes back as0x3f400000, high half intact.2.
turns()removed fromdpp_sincos_f16(phase = value): the test still passes, including the 65504 row. At binary16 precision the packing absorbs the whole difference, so the "correct trigonometric endpoints" commit is not pinned by any case. The per-form fixture would not notice either.The one that needs a decision:
sinat half turnsdpp_sincos_f16special-casescosine && abs(phase) == 0.25and!cosine && phase == 0.0, then falls through topack16_rne(sin(phase * 2π)). At a half turn that evaluates to a subnormal. I ran the trig program witht = 0.5, 1.5, -0.5, 2.5on both backends (channels 1 and 3 aresin, 0 and 2 arecos):0x8001is the f16 subnormal-2^-24. So the lowering emits a subnormal at every half turn, WARP keeps it, and the hardware flushes it to zero. Two consequences:_warpand_hardwareshare one expected word, and they disagree on it. That is very likely why the endpoint list stops at0,±0.25,±65504,±inf.sin(phase)guard at±0.5turns (returning0with the right sign) makes the case stable on both backends and removes the subnormal from the path entirely. Right now the fix that was made forcosat quarter turns has no counterpart forsinat half turns.Related, smaller:
sinatt = -1.0returns+0on both backends, because afterturns()the phase is+0.0and the sign test only looks at0x80000000of the input. If the ISA returns-0there, it is the same endpoint gap on the other side. I could not settle that here — both backends run our HLSL, so they agree by construction.Note this is the same denormal/FTZ fault line as the
pixel_aot_comparisons_hardwarefailure I reported on #855, with the polarity reversed: there WARP preserved a subnormal and the GPU flushed it, here the emitted value is a subnormal and the GPU flushes it to zero.What the fixture still does not establish
vdst[31:16]in the 23-form fixture. All destinations are zeroed before use and every consumer reads the low half, so preserving or zeroing the high half gives the same pixels. Only the singlecoscase in the trig program observes it — one form out of twenty-three.v29,v30,v31arev_movcopies ofs45..s47), so their permutations are provably inert. Channel 0 carries all the live swizzles and collapses to8 + aon every pixel; channels 1-3 are scalar-op tests, not DPP tests.frexp/ldexp"bit-level exact". The helpers are right on paper —widen16turns an f16 subnormal into a normal f32 beforefirstbithigh, andldexpbeyond±64saturates correctly for every non-zero f16. But no subnormal,inf,NaNor out-of-range exponent ever enters them:cis2.5/-1.5and the exponents are6,7,2,1. The claim is reasoned, not measured.must_reject/expect_value_error. Untested new rules: destination abovev255, operand count, duplicated modifier,fi:/bound_ctrl:(parsed and ignored), and the "rejecting uninitialized destination VGPRs" sentence indocs/experiments.md— the genericdpp_vgprcheck is its only backing, and nothing exercises it.ch1-ch3are real formulas, butch0 = 8.0 + are-derives the fixture's own lane algebra (the8is the64 × 1/64UV step),sin/cosare a two-entry lookup,half_rtzduplicates the emitted export algorithm, and theflush_ftz(word) == wordassertion is vacuous — the eight expected words are9.5,32.5,16,3.125,6.25,-23.5,27,-2.25, all normal.Verdict
The emitter is consistent,
turns()is the right reduction, the three bit-level helpers hold up, the sentinel case finally makesvdst[31:16]observable, and both the carry-free and DPP paths are green on this adapter. The open item is thesinhalf-turn endpoint: it is a real class of inputs, it currently yields a subnormal that differs between WARP and hardware, and one guard plus one case would close it.AI-assisted; the runs, the mutations and the endpoint probe were executed locally on the adapter above. The coverage inventory comes from a separate review pass and was re-verified here at
68603ab.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T18:01:16Z.
I integrated current main and kept the new DPP draws, the bit operations and the integer-to-binary16 fixture. The translated sine at positive and negative half turns now returns zero. The raw-word check catches the previous 0x8001 result on WARP, and the earlier cosine, signed-zero, large-input and infinity cases remain. The combined LLVM 15 run and Windows draws passed. The high-half sentinel and uninitialized-destination rejection establish the translated profile. Gfx1013 native high-half readback or an explicit instruction reference remains the outstanding evidence for that guest guarantee.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T19:11:51Z.
Measured the integrated head
a9720b9(base2514903) here, RX 9070 XT / RDNA4 / native wave64. Everything you describe reproduces, and one thing needs saying about where the new checks can actually bite.Status on this adapter
pixel_aot_dpp_f16_hardwarePassed 3.43 spixel_aot_dpp_f16_warpPassed 2.64 spixel_aot_hardware(draw non-regression) Passed 20.90 sThe sine at both half turns returns zero here too, and the sentinel in channel 0 survives.
But the two new guards have no teeth on this adapter
I removed one guard at a time from
dpp_sincos_f16and rebuiltoffscreen_check:abs(phase) == 0.5f(sin, half turns)00008001vs00000000, channels 1 and 3)cosine && abs(phase) == 0.25f(cos, quarter turn)3f408001vs3f400000)phase == 0.0f(signed zero)So the raw-word check does catch the
0x8001regression — on WARP. On this card, deleting either guard changes nothing observable.Why, and a correction to my earlier note
On this adapter
sin()already returns exactly0for a half-turn argument; WARP returns-8.7422780e-08, which is whatpack16_rneturns into0x8001. The divergence was never in the binary16 pack — it is the transcendental itself, andpack16_rneis integer arithmetic that cannot flush anything.That means my earlier probe read was wrong: I attributed the
0x8001-vs-0split to the packed subnormal being flushed by the hardware. It is the sine. Same consequence for the review, different mechanism, and the mechanism matters here: a guard placed aftersin()cannot be exercised on a backend whosesin()already agrees with the guard.What I think this leaves open
-8.74e-08instead, the guard is modelling WARP against the console. Nothing in this fixture can settle which, and it is the same unknown as #958: the harness recordspreserveas its assumption, and this adapter disagrees with it in some places and not others.abs(phase) == 0.5fbranch returns0ufor both signs, while thephase == 0.0fbranch distinguishes0x8000. Row((0x3800, 0xb800), (0xbc00, 0, 0xbc00, 0), "pass")therefore bakes in+0forsin(-0.5). If the console returns a negative zero there — the odd-function convention thephase == 0.0fbranch already follows — the row would pin the wrong sign. Unmeasurable here; flagging it as a modelling question rather than a defect.phase == 0.0fis redundant with the natural path:sin(-0.0)already yields-0.0on both backends, so removing that branch changes nothing (third row above). Harmless, but it is not the thing protecting the signed-zero row.gfx1013high-half readback: nothing to add, I agree it is the remaining evidence for that guarantee, and I have no way to produce it.Happy to run any further mutation against this card if it helps — the whole loop (guard edit, rebuild, both backends) is about four minutes.
AI-assisted; runs executed locally on the adapter above.
Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-23T19:54:19Z.
Thanks @R0Y00 for integrating
mainand adding the half-turnsinzero guard ata9720b9, and @thepatrickworld for the RX 9070 XT re-run and clarifying that the0x8001vs0x0000split came fromsin()rather thanpack16_rne(plus flagging thesin(-0.5)zero-sign modeling point).On the preserved upper 16 bits (
vdst[31:16]): I don't have nativegfx1013silicon readback — the backing is the ISA and LLVM 15.0.7 target model:VOP1/VOP2ops writeD0.f16/D0.u16(VDST[15:0]) and leaveVDST[31:16]unmodified; DPP16 (0xFA) and DPP8 (0xE9) areSRC0encoding prefixes onVOP1/VOP2and do not change destination write width.llvm::GCNSubtarget::zeroesHigh16BitsOfDest(llvm/lib/Target/AMDGPU/GCNSubtarget.cpp) models GFX10 16-bit destination preservation the same way already cited intools/pixel_aot.pyforv_cvt_f16_f32.That stays an ISA/LLVM-model reference rather than native
gfx1013readback. Let me know if you want me to either refresha9720b9onto currentmain(23d2e93) as-is, or switchDPP_F16to the low-16-only unknown-high-half contract from #732/#881 until native readback is available.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T21:08:40Z.
Use the shared low-16-only contract from #732/#881. This lets the verified low-half cases proceed without assuming preservation of the old high half for these DPP encodings. Please keep the raw-word positive and negative controls: low-half widening succeeds, while WORD_1 and whole-word reads reject, even with a preloaded sentinel. The endpoint run shows which desktop compiler path needs the trig guard. Keep the half-turn zero sign separate until there is a native result or a primary definition for that exact form. A small arithmetic slice is fine if the trig evidence needs more time. Please keep the split DPP CTest when refreshing onto main.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T21:51:16Z.
The new head fixes the high-half contract. Preloaded destinations still reject WORD_1 and whole-word consumers, and the matching low-half reads are explicit.
There is a separate f16 arithmetic issue. I ran a source-built identity-quad case at
f1c515df:v_fmac_f16_dppwith operands0x3e00,0x3956and accumulator0x0001, then an SDWA WORD_0 integer readback. RTX 4060 Laptop (32.0.16.1656) and in-box WARP (10.0.26100.9818) both read0x3c00, the result of rounding through f32. The exact product-plus-accumulator rounds directly to0x3c01in binary16 RNE, the same discriminator as #990. Please leave FMAC out until a direct-half path and an independent mode witness are available. The low-half proof can ship in a smaller slice, for example f32-to-f16 using the existing rounding helper and explicit mode, with one in-range rounding discriminator. The transcendental and exceptional-input cases can follow with their own domain checks.Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-23T22:04:23Z.
Updated in
a6728e06and refreshed ontomain(2d8a0cc9, post-#423) inf1c515df, with all 4 CI checks green:DPP_F16now writes("low16", alu)forfrexp_exp_i16_f16and("half16", alu)for the remaining 22 binary16 ops instead of mergingprev_val & 0xffff0000u.dpp_vgpracceptsallow_tag="half16"for binary16 DPP sources /fmac_f16accumulators andallow_tag="low16"forldexp_f16src1, while keeping 32-bitcvt_f16_f32and all non-f16 DPP ops strict.dpp_f16_trig_program()preloads sentinel0x3f400000intov22and reads the raw low-16 half throughv_mov_b32_sdwa ... src0_sel:WORD_0, andcheck_dpp_f16_contract_controls()verifies thatv_cvt_f32_f16andWORD_0SDWA succeed whileWORD_1SDWA, whole-word reads (v_mov_b32_e32/v_add_f32_e32), direct whole-word exports, cross-tag mismatches, and uninitializedfmac_f16accumulators reject even with the preloaded sentinel.check_dpp_f16_trigchecks positive half turns (+0.5/+1.5/+2.5, plus0x8001wrong-word controls) without pinningsin(-0.5)zero sign.pixel_aot_dpp_f16_{hardware,warp}alongsidepixel_aot_dpp_extra_{hardware,warp}withFORM_COVERAGE_RECORDwired up, and updateddocs/experiments.md.Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T22:17:34Z.
Two separate things at
f1c515df, both measured on an RX 9070 XT, one for @R0Y00 and one for @KomaGuy.For @R0Y00 — the FMAC request is not in this head, and no test can see it
v_fmac_f16_dppstill lowers through the samepack16_rne(mad(...))path (tools/pixel_aot.py:1140, plus the accumulator branch at4114-4116), unchanged betweena6728e0andf1c515df.docs/experiments.mdin the same diff listsfmac_f16among the forms that lower.Your case checks out arithmetically, and the numbers are worth writing down because they explain why no test in the tree can contradict it:
0x3e00×0x3956= 1.5 × 0.6669921875 = 1.00048828125, which is exactly the binary16 midpoint between0x3c00(1.0) and0x3c01(1.0009765625).0x0001is 2⁻²⁴, which is exactly half a binary32 ulp at 1.0 — so the f32 addition is an exact tie, RNE keeps the even mantissa, and the sum stays on the midpoint.pack16_rneof that midpoint is another tie broken to even →0x3c00. A single binary16 RNE rounding of the exact sum lands above the midpoint →0x3c01.The tree already contains the argument that this can happen: the enumeration at
tests/pixel_aot_check.py:9443-9457proves "one binary32 operation followed by one binary16 rounding equals the single rounding" foradd/sub/subrev/mul. That proof does not extend tofmac— the product of two 11-bit mantissas needs 22 bits and the third operand pushes the exact sum past the 24 bits of a binary32. Your case is the counterexample.Two more things that point the same way: the only
v_fmac_f16_dppdraw in the fixture (6565) uses1.0 × 2.0 + 3.0, exact and lane-uniform, so it is blind to both the rounding and the DPP8 swizzle; andv_fmac_f16_e32is already refused as unsupported (9595), so the tree has already decided there is no direct-half path for non-DPP FMAC. Adding the DPP form through f32 is the inconsistency, not just the rounding risk.Splitting FMAC out leaves the rest intact: the low-16-only contract, the raw-word controls, the positive half turns and the split CTest all pass here (see below).
For @KomaGuy —
pixel_aot_dpp_extra_hardwareis red on AMD, deterministicallyFresh clone at
f1c515df(114 tests registered), RX 9070 XT1002:7550, driver32.0.32029.2010, DXC1.9.2602.17,-denorm preserve:Three runs, identical failure each time. The failing assertion is
check_dpp_extra_subnormal_draw, casedpp_dotc_wrap.cso, channel 2 only:Channel 3 is the same value taken from the SGPR and it is right; channel 2 is the
dpp8:[1,2,3,0,...]form whose source is a VGPR. I isolated the cause in the emitted HLSL rather than guessing:dpp29_sis produced byQuadReadLaneAt(asuint(alu26), q)withq = WaveGetLaneIndex() & 3u. Three probes, same case file and compiler flags:0x08080808u0x80000010(read gave 0)0x80000030(correct)params[0].w(the test's own form)0x80000010dpp29_s = dpp29_in, no intrinsic0x11111111u + WaveGetLaneIndex()(varies per lane)So on this adapter and driver,
QuadReadLaneAtreturns 0 when the value is uniform across the quad — whether it comes from a literal or from the constant buffer — and returns the right value when the input varies per lane.QuadReadAcrossXbehaves the same way. The intrinsic itself is fine in isolation: with a lane-varying input it returns0x11111111for lane 0 and0x11111112for lane 1 on both backends.That matters beyond this test: any DPP8 whose source is a constant collapses to zero on AMD, which is most fixture code.
Correction to my own first reading. I checked the merged #423 commit on its own (
2d8a0cc, 110 of 112 passing on this adapter) and it fails the same way:pixel_aot_dpp_extra_hardware4.89 s, samedpp_dotc_wrapcase, same channel 2, same words.dpp_dot4c_i32_i8and that fixture came in with #423, so this branch inherits the failure rather than introducing it — the fix belongs in a separate change, and this PR simply cannot go green on AMD hardware until it lands. The other red on that merged commit is the known #958 comparison divergence (0008ccccvs000ccccc), also inherited.The CI point stands: it runs
-E '_hardware$'(.github/workflows/windows.yml:127), so a warp-only green cannot see either of these.Two directions if it helps: keep a per-lane-varying sentinel for DPP8 sources instead of a constant, or make the emulation read the lane value without
QuadReadLaneAtwhen the operand is uniform. I have no position on which is right — the measurement is that the intrinsic is not a reliable lane read for uniform values here.Measurements and logs available on request; the numbers above are from a single machine, one adapter,
debug_layer=unavailable.AI-assisted; runs on the adapter and driver listed above.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T22:38:02Z.
A follow-up on the FMAC point, since part of it changed today: a direct-half path now exists on
main.5b2b07b(merged as64ecc87via #1004) addsfma16_rneattools/pixel_aot.py:909— an exact fused binary16 multiply-accumulate in 32-bit integer arithmetic, taking the three operands as single 16-bit encodings, with no binary32 intermediate and no dependence on the binary32 denormal modes. It is already used for the packed form at4305-4306.That is the direct-half path the FMAC request named. It is only half of what was asked for, though: the request also wanted an independent mode witness, and this is a reference, not a measurement — it assumes binary16 denormals preserved, which the DPP path pins anyway with
half_denorm="preserve".Two caveats before anyone reaches for it:
tools/pixel_aot.py:911, "Operates on finite binary16 encodings"). Its current callers enforce that at translation time:pk_fmac_f16_sourceraises on a half that is not statically known finite, andf16_pk_fmac_lane_resultrejects an overflowing result.v_fmac_f16_dppreads its operands from a constant buffer, where infinity and NaN are reachable at run time, so a straight swap is not equivalent: I checked a few non-finite triples and the helper returns0x7c00forqNaN * 1 + 1and drops the sign of an infinite accumulator. Thewiden16/pack16_rnepath in this branch handles those correctly today. Reuse needs a guard or a non-finite branch in front.v_fmac_f16_dppthroughpack16_rne(mad(...))(tools/pixel_aot.py:1140plus the accumulator branch at4114), still in the fixture attests/pixel_aot_check.py:6565, and still listed indocs/experiments.md. Notev_fmac_f16in the plain form is not implemented at all — it refuses as unsupported — so the affected instruction here is the DPP one this PR adds.So "leave FMAC out until a direct-half path is available" now has a concrete alternative rather than a wait: reuse the packed path with the finiteness guard. Whether that belongs in this PR or after it is your call.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:39:15Z.
The conversion-only revision is now combined with the verified quad-routing fix #1030 at
d1ea7d50. Static pixel checks and both draw-dpp-f16 and draw-dpp-extra passed locally on RTX 4060 Laptop and WARP. This keeps the low-16 result and explicit preserve/RNE scope, with FMAC outside this PR. Fresh CI is running on the combined commit.Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T22:43:06Z.
Confirming the combined head, and closing the loop on my two points.
FMAC is out. At
d1ea7d5the DPP table no longer has afmac_f16entry (tools/pixel_aot.py), andv_fmac_f16_dppis refused explicitly (tests/pixel_aot_check.py:7272, "Unsupported instruction"). Thev_pk_fmac_f16hits in the same file are the packed path from main, not this PR.The quad-routing fix carries, on a third adapter.
d1ea7d5merges4bc40d05(#1030). On the RX 9070 XT (32.0.32029.2010, DXC1.9.2602.17, presetdev):The same entry, strict comparison, three consecutive runs at
d1ea7d5: exit 0, zeropixel_mismatchlines, each drawpixels=4096 channels=16384 max_absolute_error=0. Full details are on #1024, which asked for this retest.So the low-16 contract, the raw-word controls and the split CTest all hold here, and the one red I reported earlier is gone once the routing fix is in the tree.
AI-assisted; one machine, one adapter.