diff options
author | Matt Turner <mattst88@gmail.com> | 2015-06-25 16:47:52 -0700 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2015-08-03 09:24:51 -0700 |
commit | 594fc0f85953d11c455e7ab549308a773b312d70 (patch) | |
tree | f23cb5f74f95e7f97fcc8e5c01b166c9a90edde9 /src/util/rounding.h | |
parent | f55c408067a3ea3529fcf7cbbaa1a041a4a8849d (diff) | |
download | external_mesa3d-594fc0f85953d11c455e7ab549308a773b312d70.zip external_mesa3d-594fc0f85953d11c455e7ab549308a773b312d70.tar.gz external_mesa3d-594fc0f85953d11c455e7ab549308a773b312d70.tar.bz2 |
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>
Diffstat (limited to 'src/util/rounding.h')
-rw-r--r-- | src/util/rounding.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/rounding.h b/src/util/rounding.h index 0cbe926..088cf86 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 <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 |