shader: record the pixel_aot binary16 denormal mode and draw an f16 subnormal control #543
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/549"
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 roansystemlabs on 2026-11-22T10:47:59Z.
Refs #312. Builds on #363 (merged).
What
F16_DENORM_MODE = "preserve"intests/pixel_aot_check.py, recorded as the harness assumption (as #363 does for f32), with the reason it holds by construction:v_pk_*_f16widens each half from its encoding (widen16), computes in binary32 and narrows in integer arithmetic (pack16_rne). Every binary16 subnormal, and every product or sum of two, is a binary32 normal, so a binary32 flush cannot reach it, and DXIL has no f16 denormal attribute (-denormonly setsfp32-denorm-mode).check_controls, so it also runs on the Linux Python job): pins the reference words, checks that the lowered body callswiden16andpack16_rne, and that it contains nof32tof16,f16tof32,half,min16floatorfloat16_t. If a future lowering switches to driver conversions or native halves, the mode-independence claim stops being true and this fails.pixel_aot_e64_{hardware,warp}, next to the f32 control from #363. The required row isv_pk_add_f16on two normal inputs whose sum is the subnormal0x8001(following the DXILfaddFTZ text, as suggested in #312). Supplementary rows:v_pk_max_f16on the least (0x0001) and largest (0x03ff) binary16 subnormals,v_pk_mul_f16that produces the subnormal0x0200from normal inputs, andv_pk_fma_f16whose halves round to nearest even (0x05fe0002). The words go through the lossless integer readback, because0x80000200is a binary32 subnormal as a word. One preserve reference must pass under both-denorm preserveand-denorm ftz; a reference that flushes binary16 subnormals must fail.docs/experiments.md: one paragraph with the assumption, the control and its limits.This is narrower than the per-fixture f16 mode I offered in #312: no fixture asks for f16 FTZ today, and the lowering cannot produce it, so an explicit flush in the emitted HLSL would have no user yet. It can be added with the first fixture that needs it.
Test
Measured at commit
95728c7on075413d; rebased onto579f58fas419f93b, keeping both the DPPmust_rejectfrom #408 and the new call incheck_controls(the only conflict). Re-run there: CPU checks exit 0; 17 of the 18pixel_aot_*entries passed, andpixel_aot_predicate_rounding_hardwaretimed out at 60 s with other load on the machine, then passed alone in 59.9 s. Windows 11 (26200), NVIDIA GeForce RTX 3070 driver 32.0.16.2101, WARP 10.0.26100.9818, DXC 10.0.26100.0, D3D12 debug layer enabled.python -B tests/pixel_aot_check.py: exit 0.pixel_aot_e64_hardwarepassed in 9.6 s,pixel_aot_e64_warpin 2.5 s,debug_errors=0 debug_warnings=0. The new draw, including its negative case, takes about 1.0 s on the RTX 3070 and 0.35 s on WARP.bvh_wave64_hardware,bvh_wave64_warp,wave_shuffle_warp,cpu_aot_crypto_sha), 1 timeout:pixel_aot_predicate_rounding_hardwareat the 60 s limit. This PR does not touch that test; run alone it passes in 55.3 s on this machine, which looks like the per-case device cost in #448.Negative controls, each observed failing on both adapters:
84018001 03ff0001 80000200 05fe0002vs expected84018000 00000000 80000000 00000000→pixel_mismatch, exit 1 (built into the test)pack16_rneflushes subnormal results → exported84018000 00000000 80000000 05fe0000→ exit 1widen16flushes subnormal inputs → exit 1f16tof32, or to declare a lane ashalf→ AssertionErrorNot claimed
FLOAT_MODEf16 bits are unmeasured; this records the harness assumption only.f32tof16and is not covered here.AI-assisted: prepared with an AI coding agent and reviewed by a human before posting.