feat(recompiler): convert f32 to f16 natively when the device rounds 16-bit floats to nearest even #1252
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1252"
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 MathiasDevelopes on 2026-10-07T19:53:28Z.
What
The integer emulation of round-to-nearest-even f32→f16 conversion (#317) is exact but heavy: a compute shader with ~3600 conversions (2.27M SPIR-V words) never finished compiling on NVIDIA. When the device enables
shaderFloat16and guaranteesshaderRoundingModeRTEFloat16,shaderDenormPreserveFloat16andshaderSignedZeroInfNanPreserveFloat16, the driver advertisesFloat16,RoundingModeRTEandDenormPreserve, and the recompiler emitsOpFConvertunder the 16-bitRoundingModeRTE,DenormPreserveandSignedZeroInfNanPreserveexecution modes. NaNs keep the emulated quiet NaN with the high payload bits. Devices without these guarantees (e.g. RADV's truncatingpackHalf2x16, the reason for #317) keep the emulation.Graphics validation now accepts the three float-controls execution modes for 16-, 32- and 64-bit floats, so vertex and pixel shaders with a native conversion still draw.
Related: #981 plans per-shader float controls from RSRC1 FLOAT_MODE; this change only sets 16-bit modes on shaders that convert to f16 and leaves the 32/64-bit defaults alone.
Tested
Windows 11, NVIDIA.
agc_float16_conversion:v_cvt_f16_f32recompiled with and without the capabilities. Native getsOpFConvertplus the 16-bit modes; without RTE it stays emulated.agc_driver_graphics: vertex and pixel modules with the 16/32/64-bit float-controls modes validate, and an 8-bit width is rejected. It fails without the validator change.agc_driver_float16_rounding(RDNA2-captured, from #317) and the other f16 execution tests pass with the native path.ctest: 396/396 pass;tools/check_conventions.pypasses.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 copilot-pull-request-reviewer[bot] on 2026-10-07T19:53:34Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by hashaam1217 on 2026-10-08T02:33:50Z.
Checked on Linux with the native path active. CI cannot exercise it: llvmpipe (Mesa 25.2.8) reports
shaderDenormPreserveFloat16 = 0, so it stays on the emulation.shaderFloat16,shaderRoundingModeRTEFloat16,shaderDenormPreserveFloat16andshaderSignedZeroInfNanPreserveFloat16: Intel Iris Xe (Alder Lake GT2, Mesa 25.2.8 ANV) and NVIDIA RTX 3060 Laptop (595.91.07).INTEL_DEBUG=cs, theagc_driver_float16_roundingshader has 18f2f16in its NIR (0 on main) and compiles to 121 GEN instructions instead of 209. Its RDNA2-captured expectations pass on both GPUs.df16c4c2:flat_store): fails the same 35 tests as main.agc_float16_conversionpasses on both.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:39:12Z.
Checked on RADV (Radeon 660M, advertises RTE/DenormPreserve/SignedZeroInfNanPreserve for 16-bit floats): full ctest passes with the native path active, including the RDNA2-captured
agc_driver_float16_rounding. The newagc_float16_conversionand theagc_driver_graphicsfloat-controls check fail without the change. The native NaN result matches the emulated one bit for bit by construction. Also confirmed by @hashaam1217 on Intel and NVIDIA. CI green; merging.