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: mesa/mesa#2828
Fixes: 53c36dfc
       ("replace IROUND with util functions")

Reviewed-by: Matt Turner <>
Part-of: <mesa/mesa!4673>
54 jobs for !4673 with fix-utils-functions in 26 minutes and 41 seconds (queued for 10 seconds)
merge request