mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-27 00:28:14 +00:00
The recompiler marks every guest f32 add, subtract and multiply NoContraction, because the guest rounds each one separately. SPIRV-Cross turns each of them into a call to a helper that Metal compiles without optimization, which dominates fragment time on MoltenVK, and its multiply helper, fma(a, b, +0.0), turns a -0.0 product into +0.0. On MoltenVK they are now GLSL Fma whose second step is exact, which gives the separately rounded result: a * b is fma(a, b, -0.0), a + b is fma(1.0, a, b) and a - b is fma(-1.0, b, a). The sin, cos and log2 series and the offset image coordinates and gather texel scale use the same forms. The choice is a SpirvTarget flag set for VK_DRIVER_ID_MOLTENVK, part of the shader cache key and of the request serialization (version 44); other drivers are unchanged. agc_driver_f32_separate_rounding checks a multiply feeding an add or a subtract on rows where fusing them changes the result. It, agc_driver_f32_arithmetic_nan and agc_driver_f32_denormal_flush also run the fused forms on devices that do not use them, so lavapipe checks them against the same rows. Co-authored-by: Ycaro Gabriel <[email protected]>