fix(shader): flush f16 min/max denormal inputs #2876
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2876"
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 boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-10T17:16:59Z.
What
v_min_f16andv_max_f16keep denormal inputs when the shader asks to flush them, so their selected result differs from RDNA2. #2036 fixed their IEEE NaN handling but left this gap in TechnicalDebt.The binary forms now flush each half input to its signed zero when denorm16 bit 0 is clear. Output flushing alone preserves the selected input. This applies to the comparison value and the bits returned for a NaN fallback. The second commit applies the same rule to
v_min3_f16,v_max3_f16andv_med3_f16, which shareminMaxF16: on gfx1036 they flush the same way (8,024 operand triples in each of the eight IEEE 0/1 x denorm16 0-3 modes, every row matching the rule, changes only at denorm16 0 and 2). The debt entry retains the f64 gap.Measured with the hardware oracle on gfx1036 (Radeon 610M), at IEEE=0/1 and denorm16=0/1/2/3. Other controls: DX10 clamp enabled, f32 denormals flushed, both rounding fields nearest even, FP16_OVFL=0. These example half results are at IEEE=1:
main0x3c01, 0x03ff0x00000x03ff0xbc01, 0x03ff0x00000x03ff0x3c01, 0x03ff0x03ff0x03ffTested
CachyOS Linux, Release build; RTX 4070 Ti (NVIDIA), Radeon 610M (RADV), and lavapipe, including the pinned CI driver.
agc_driver_f16_min_max_nan: 32 measured operand pairs, eight IEEE/denormal modes, plain and neg/abs forms, and SDWA WORD_0/WORD_1 sources. Includes signed zeros, NaNs, denormals and minimum normals. Main fails with0x03ffinstead of0x0000; the fix passes on all three drivers. Original NaN/ternary tables still pass. The ternary rows fail on the first commit (v_min3_f16 v12, v4, v5, v6 is 0x000003ff, expected 0x00000000) and pass with the second. Runtime below 1.2 s.check_conventions.py, andgit diff --checkpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:10:50Z.
Checked on the HW oracle (gfx1035): 2048 operand triples (signed zeros, denormals, min normals, ±1, ±inf, quiet/signaling NaNs) at IEEE=0/1 × denorm16 0–3 for
v_min/max/min3/max3/med3_f16, neg/abs, SDWA and clamp all match "flush inputs when denorm16 bit 0 is clear". Also ran the AGC driver ctest scope (agc_driver_f16_min_max_nanfails without the change). Merging.