mesa: Follow OpenGL conversion rules for values that exceed storage size
authorDylan Baker <dylan@pnwbakers.com>
Wed, 22 Apr 2020 06:32:45 +0000 (23:32 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Apr 2020 04:26:41 +0000 (04:26 +0000)
commit35ee6b3d361b13c6380cf357ef05c9681639cfc1
tree72b034c561ca6804b2bebbbba550756662b3f753
parent76c5688018931544fc36b55d3968b484cbbd56bf
mesa: Follow OpenGL conversion rules for values that exceed storage size

Section 2.2.2 (Data Conversions For State Query Commands) of the
OpenGL 4.5 spec says:

  Following these steps, if a value is so large in magnitude that
  it cannot be represented by the returned data type, then the
  nearest value representable using that type is returned.

The current code doesn't do the correct thing, because it truncates a
long (potentially a 64bit values) to an int.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2828
Fixes: 53c36dfcfe3eb3749a53267f054870280afb0d71
       ("replace IROUND with util functions")

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4673>
src/mesa/main/texparam.c