From 594fc0f85953d11c455e7ab549308a773b312d70 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Thu, 25 Jun 2015 16:47:52 -0700 Subject: 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 --- src/util/rounding.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/util') diff --git a/src/util/rounding.h b/src/util/rounding.h index 0cbe9269f7b..088cf86dd08 100644 --- a/src/util/rounding.h +++ b/src/util/rounding.h @@ -21,6 +21,9 @@ * IN THE SOFTWARE. */ +#ifndef _ROUNDING_H +#define _ROUNDING_H + #include #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 -- cgit v1.2.3