summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/Android.libmesa_glsl_utils.mk10
-rw-r--r--src/mesa/main/imports.c20
-rw-r--r--src/mesa/main/imports.h3
3 files changed, 31 insertions, 2 deletions
diff --git a/src/mesa/Android.libmesa_glsl_utils.mk b/src/mesa/Android.libmesa_glsl_utils.mk
index 9c5f3493cbd..47f2e151b40 100644
--- a/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/src/mesa/Android.libmesa_glsl_utils.mk
@@ -35,10 +35,13 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libmesa_glsl_utils
-LOCAL_C_INCLUDES := $(MESA_TOP)/src/glsl
+LOCAL_C_INCLUDES := \
+ $(MESA_TOP)/src/glsl \
+ $(MESA_TOP)/src/mapi
LOCAL_SRC_FILES := \
main/hash_table.c \
+ main/imports.c \
program/prog_hash_table.c \
program/symbol_table.c
@@ -54,10 +57,13 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libmesa_glsl_utils
LOCAL_IS_HOST_MODULE := true
-LOCAL_C_INCLUDES := $(MESA_TOP)/src/glsl
+LOCAL_C_INCLUDES := \
+ $(MESA_TOP)/src/glsl \
+ $(MESA_TOP)/src/mapi
LOCAL_SRC_FILES := \
main/hash_table.c \
+ main/imports.c \
program/prog_hash_table.c \
program/symbol_table.c
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 76f835e0ec3..26c91dce535 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -314,6 +314,26 @@ _mesa_bitcount_64(uint64_t n)
#endif
+/* Using C99 rounding functions for roundToEven() implementation is
+ * difficult, because round(), rint, and nearbyint() are affected by
+ * fesetenv(), which the application may have done for its own
+ * purposes. Mesa's IROUND macro is close to what we want, but it
+ * rounds away from 0 on n + 0.5.
+ */
+int
+_mesa_round_to_even(float val)
+{
+ int rounded = IROUND(val);
+
+ if (val - floor(val) == 0.5) {
+ if (rounded % 2 != 0)
+ rounded += val > 0 ? -1 : 1;
+ }
+
+ return rounded;
+}
+
+
/**
* Convert a 4-byte float to a 2-byte half float.
* Based on code from:
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 8446ea2a3e8..4b783818b2f 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -548,6 +548,9 @@ _mesa_fls(unsigned int n)
#endif
}
+extern int
+_mesa_round_to_even(float val);
+
extern GLhalfARB
_mesa_float_to_half(float f);