aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-07-12 08:22:55 +0200
committermarha <marha@users.sourceforge.net>2013-07-12 08:22:55 +0200
commitffce4319c2fb6f4f663cc5a9660e1d5837fcde87 (patch)
tree603d92313dadf957fbaba55afa634de25d3bbd96 /mesalib/src/gallium/auxiliary
parentc6069c33e3a4a6d48aa059dbe9a78702dabff9cc (diff)
downloadvcxsrv-ffce4319c2fb6f4f663cc5a9660e1d5837fcde87.tar.gz
vcxsrv-ffce4319c2fb6f4f663cc5a9660e1d5837fcde87.tar.bz2
vcxsrv-ffce4319c2fb6f4f663cc5a9660e1d5837fcde87.zip
libxtrans fontconfig mesa xserver git update 12 Jul 2013
xserver commit 59a6d3f1eb03010ab831b32b03706a1d6143c732 libxtrans commit f6a161f2a003f4da0a2e414b4faa0ee0de0c01f0 fontconfig commit 338ffe6b886ad4ba86ff471cb59c4a5e5ffbe408 mesa commit 1b0d6aef03161eff4c9933548e964fec1258ea44
Diffstat (limited to 'mesalib/src/gallium/auxiliary')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.c64
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h7
2 files changed, 71 insertions, 0 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.c b/mesalib/src/gallium/auxiliary/util/u_math.c
index 2811475fa..f3fe392ba 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.c
+++ b/mesalib/src/gallium/auxiliary/util/u_math.c
@@ -27,7 +27,16 @@
+#include "pipe/p_config.h"
#include "util/u_math.h"
+#include "util/u_cpu_detect.h"
+
+#if defined(PIPE_ARCH_SSE)
+#include <xmmintrin.h>
+/* This is defined in pmmintrin.h, but it can only be included when -msse3 is
+ * used, so just define it here to avoid further. */
+#define _MM_DENORMALS_ZERO_MASK 0x0040
+#endif
/** 2^x, for x in [-1.0, 1.0) */
@@ -70,4 +79,59 @@ util_init_math(void)
}
}
+/**
+ * Fetches the contents of the fpstate (mxcsr on x86) register.
+ *
+ * On platforms without support for it just returns 0.
+ */
+unsigned
+util_fpstate_get(void)
+{
+ unsigned mxcsr = 0;
+
+#if defined(PIPE_ARCH_SSE)
+ if (util_cpu_caps.has_sse) {
+ mxcsr = _mm_getcsr();
+ }
+#endif
+
+ return mxcsr;
+}
+
+/**
+ * Make sure that the fp treats the denormalized floating
+ * point numbers as zero.
+ *
+ * This is the behavior required by D3D10. OpenGL doesn't care.
+ */
+unsigned
+util_fpstate_set_denorms_to_zero(unsigned current_mxcsr)
+{
+#if defined(PIPE_ARCH_SSE)
+ if (util_cpu_caps.has_sse) {
+ /* Enable flush to zero mode */
+ current_mxcsr |= _MM_FLUSH_ZERO_MASK;
+ if (util_cpu_caps.has_sse3) {
+ /* Enable denormals are zero mode */
+ current_mxcsr |= _MM_DENORMALS_ZERO_MASK;
+ }
+ util_fpstate_set(current_mxcsr);
+ }
+#endif
+ return current_mxcsr;
+}
+/**
+ * Set the state of the fpstate (mxcsr on x86) register.
+ *
+ * On platforms without support for it's a noop.
+ */
+void
+util_fpstate_set(unsigned mxcsr)
+{
+#if defined(PIPE_ARCH_SSE)
+ if (util_cpu_caps.has_sse) {
+ _mm_setcsr(mxcsr);
+ }
+#endif
+}
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 64d16cbe7..bc3948875 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -763,6 +763,13 @@ static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits)
return (int32_t)(value * (1<<frac_bits));
}
+unsigned
+util_fpstate_get(void);
+unsigned
+util_fpstate_set_denorms_to_zero(unsigned current_fpstate);
+void
+util_fpstate_set(unsigned fpstate);
+
#ifdef __cplusplus