Skip to content

compiler/spirv, nir: flag nclamp/nmin/nmax as exact and make fsat return 0.0 with NaN

Fixes https://github.com/daniel-schuermann/mesa/issues/178 (which happened because of the fmin(a(is_not_negative), 1.0) -> fsat(a) optimization).

Also fixes #2587 (closed) (which happened because of the 1.0 - fsat(a) -> fsat(1.0 - a) optimization).

I've marked this as WIP because I'm not certain other drivers return 0.0 from fsat(NaN).

pipeline-db (ACO/Navi):

 PERCENTAGE DELTAS    Shaders     SGPRs     VGPRs SpillSGPR SpillVGPR  PrivVGPR   Scratch  CodeSize  MaxWaves     Instrs
 battlefront2            4566    0.06 %   -0.02 %     .         .         .         .        0.04 %     .        0.26 %
 britannia                465     .         .         .         .         .         .         .         .         .    
 dirt4                   4030     .         .         .         .         .         .         .         .         .    
 doom                    5775     .         .         .         .         .         .         .         .         .    
 dota2                    985     .         .         .         .         .         .         .         .         .    
 dow3                     294     .         .         .         .         .         .         .         .         .    
 evilwithin_demo          740     .         .         .         .         .         .        0.07 %     .        0.20 %
 f12017                  5462     .         .         .         .         .         .         .         .         .    
 gtav                    2955   -0.01 %   -0.01 %     .         .         .         .       -0.01 %     .        0.22 %
 madmax                   922     .         .         .         .         .         .         .         .         .    
 nier                    7030     .         .         .         .         .         .        0.01 %     .        0.06 %
 redout                  2487     .         .         .         .         .         .       -0.03 %     .        0.03 %
 rottr                   8039     .         .         .         .         .         .         .         .         .    
 shadowofmordor          2055     .         .         .         .         .         .         .         .         .    
 sottr_demo              5618     .         .         .         .         .         .        0.05 %     .        0.08 %
 strange_brigade         1412     .         .         .         .         .         .         .         .         .    
 talos                    782     .         .         .         .         .         .       -0.08 %     .       -0.08 %
 thewitness              3150     .         .         .         .         .         .         .         .        0.49 %
 threekingdoms            887     .         .         .         .         .         .         .         .         .    
 warhammer2              1871     .         .         .         .         .         .         .         .         .    
 worldofwarships         8536     .        0.04 %     .         .         .         .        0.07 %   -0.04 %    0.28 %
 youngblood               843     .         .         .         .         .         .         .         .         .    
 -----------------------------------------------------------------------------------------------------------------------
 All affected           13383     .        0.02 %     .         .         .         .        0.05 %   -0.03 %    0.29 %
 -----------------------------------------------------------------------------------------------------------------------
 Total                  68904     .         .         .         .         .         .        0.02 %     .        0.12 %
Edited by Rhys Perry

Merge request reports