mesa: Replace F_TO_I() with _mesa_lroundevenf().

I'm not sure what the true meaning of "The rounding mode may vary." is,
but it is the case that the IROUND() path rounds differently than the
other paths (and does it wrong, at that).

Like _mesa_roundeven{f,}(), just add an use _mesa_lroundeven{f,}() that
has known semantics.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
Matt Turner
2015-06-25 16:47:52 -07:00
parent f55c408067
commit 594fc0f859
6 changed files with 42 additions and 42 deletions

View File

@@ -21,6 +21,9 @@
* IN THE SOFTWARE.
*/
#ifndef _ROUNDING_H
#define _ROUNDING_H
#include <math.h>
#ifdef __SSE4_1__
@@ -76,3 +79,25 @@ _mesa_roundeven(double x)
return rint(x);
#endif
}
/**
* \brief Rounds \c x to the nearest integer, with ties to the even integer,
* and returns the value as a long int.
*/
static inline long
_mesa_lroundevenf(float x)
{
return lrintf(x);
}
/**
* \brief Rounds \c x to the nearest integer, with ties to the even integer,
* and returns the value as a long int.
*/
static inline long
_mesa_lroundeven(double x)
{
return lrint(x);
}
#endif