mesa: Remove rounding bias in _mesa_float_to_half()
mesa: Remove rounding bias in _mesa_float_to_half()

Not all float32 values can be exactly represented as a float16.
_mesa_float_to_half() rounded such intermediate float32 values to zero by
truncating unrepresentable bits in the mantissa.

This patch improves _mesa_float_to_half() by rounding intermediate float32
values to the nearest float16; when the float32 is exactly between two
float16 values we round to the one with an even mantissa. This behavior is
preferred over the old behavior because:
  - It has reduced bias relative to the old behavior.

  - It reproduces the behavior of real hardware: opcode F32TO16 in
    Intel's GPU ISA.

  - By reproducing the behavior of the GPU (at least on Intel hardware),
    compile-time evaluation of constant packHalf2x16 GLSL expressions will
    result in the same value as if the expression were executed on the GPU.

Reviewed-by: Ian Romanick <2b237cafb16dc45038e85df6c85e74e6d899eba9@intel.com>
Reviewed-by: Paul Berry <de21b9f22e6dd0bdf7890875d6e07ef4967c44ce@gmail.com>
Signed-off-by: Chad Versace <a557f7f75bf28dc19ac99107f5cc7cd6b3fbdb1a@linux.intel.com>

bkaradzic/glsl-optimizer,dellis1972/glsl-optimizer,zz85/glsl-optimizer,djreep81/glsl-optimizer,mcanthony/glsl-optimizer,zeux/glsl-optimizer,jbarczak/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,mcanthony/glsl-optimizer,djreep81/glsl-optimizer,mapbox/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,mcanthony/glsl-optimizer,djreep81/glsl-optimizer,wolf96/glsl-optimizer,zeux/glsl-optimizer,benaadams/glsl-optimizer,bkaradzic/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,wolf96/glsl-optimizer,bkaradzic/glsl-optimizer,mcanthony/glsl-optimizer,zeux/glsl-optimizer,mcanthony/glsl-optimizer,dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,dellis1972/glsl-optimizer,jbarczak/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,dellis1972/glsl-optimizer,jbarczak/glsl-optimizer,djreep81/glsl-optimizer,mapbox/glsl-optimizer,metora/MesaGLSLCompiler,benaadams/glsl-optimizer,benaadams/glsl-optimizer,zz85/glsl-optimizer,zz85/glsl-optimizer,mapbox/glsl-optimizer,tokyovigilante/glsl-optimizer,mapbox/glsl-optimizer,bkaradzic/glsl-optimizer,bkaradzic/glsl-optimizer,benaadams/glsl-optimizer,benaadams/glsl-optimizer,zz85/glsl-optimizer,mapbox/glsl-optimizer,metora/MesaGLSLCompiler,zeux/glsl-optimizer,wolf96/glsl-optimizer,zeux/glsl-optimizer,benaadams/glsl-optimizer,metora/MesaGLSLCompiler,djreep81/glsl-optimizer