diff options
Diffstat (limited to 'lib/mesa/src/util/rounding.h')
-rw-r--r-- | lib/mesa/src/util/rounding.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/mesa/src/util/rounding.h b/lib/mesa/src/util/rounding.h index dfc691eaf..8e302921c 100644 --- a/lib/mesa/src/util/rounding.h +++ b/lib/mesa/src/util/rounding.h @@ -116,7 +116,7 @@ _mesa_lroundevenf(float x) static inline long _mesa_lroundeven(double x) { -#if defined(__SSE__) || defined(_MSC_VER) +#if defined(__SSE2__) || defined(_MSC_VER) #if LONG_MAX == INT64_MAX return _mm_cvtsd_si64(_mm_load_sd(&x)); #elif LONG_MAX == INT32_MAX @@ -129,4 +129,20 @@ _mesa_lroundeven(double x) #endif } +/** + * \brief Rounds \c x to the nearest integer, with ties to the even integer, + * and returns the value as an int64_t. + */ +static inline int64_t +_mesa_i64roundevenf(float x) +{ +#if LONG_MAX == INT64_MAX + return _mesa_lroundevenf(x); +#elif LONG_MAX == INT32_MAX + return llrintf(x); +#else +#error "Unsupported long size" +#endif +} + #endif |