summaryrefslogtreecommitdiff
path: root/lib/mesa/src/util/rounding.h
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2020-01-22 02:13:18 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2020-01-22 02:13:18 +0000
commitfdcc03929065b5bf5dd93553db219ea3e05c8c34 (patch)
treeca90dc8d9e89febdcd4160956c1b8ec098a4efc9 /lib/mesa/src/util/rounding.h
parent3c9de4a7e13712b5696750bbd59a18c848742022 (diff)
Import Mesa 19.2.8
Diffstat (limited to 'lib/mesa/src/util/rounding.h')
-rw-r--r--lib/mesa/src/util/rounding.h18
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