zink: fix isNan mismatch between NIR and SPIR-V
authorSoroushIMG <soroush.kashani@imgtec.com>
Fri, 30 Sep 2022 15:08:27 +0000 (16:08 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 11 Oct 2022 20:51:48 +0000 (20:51 +0000)
commit69c22dd81736ee825d345078ffb252b39190e89d
treedbb8649f2e44b0d9a02c1ff79e7b164c86e7650e
parenta730b1bb0a43c9bf8b57269744a12b8fbdbd460f
zink: fix isNan mismatch between NIR and SPIR-V

SPIR-V and Vulkan allow implementations to optimize
float ops assuming inputs are not NaN unless SignedZeroInfNanPreserve
execution mode is enabled.

This means isnan which is turned to nir_op_fneu(a,a) and then emitted
as SpvOpFUnordNotEqual could potentially be optimised to a const 0.

isnan is special in this approach and therefore recognise this pattern,
and emit SpvOpIsNan instead of enabling SignedZeroInfNanPreserve which
will hurt performace of some vulkan drivers.

Fixes dEQP-GL45-ES31.functional.shaders.builtin_functions.common.isnan.*

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18910>
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c