summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorTiziano Bacocco <[email protected]>2015-01-25 12:15:39 +0100
committerAxel Davy <[email protected]>2015-04-29 08:28:10 +0200
commit31bb4cd5c6e3d696b2f240c270a257abfcd8848f (patch)
tree7816671f6a54d7023be80207264c8eb511eca2ee /src/gallium/state_trackers
parente7b1a1e57cdfd8d019ba0ff4cdc2c7239066869f (diff)
st/nine: Change x86 FPU Control word on device creation
As on wined3d and windows, when D3DCREATE_FPU_PRESERVE is not specified, change the fpu control word to all exceptions masked, single precision, round to nearest. Signed-off-by: Axel Davy <[email protected]> Signed-off-by: Tiziano Bacocco <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/nine/device9.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 1a776a777ca..0bd17177497 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -41,6 +41,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
+#include "pipe/p_config.h"
#include "util/u_math.h"
#include "util/u_inlines.h"
#include "util/u_hash_table.h"
@@ -53,6 +54,33 @@
#define DBG_CHANNEL DBG_DEVICE
+#if defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
+
+#include <fpu_control.h>
+
+static void nine_setup_fpu()
+{
+ fpu_control_t c;
+
+ _FPU_GETCW(c);
+ /* clear the control word */
+ c &= _FPU_RESERVED;
+ /* d3d9 doc/wine tests: mask all exceptions, use single-precision
+ * and round to nearest */
+ c |= _FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM |
+ _FPU_MASK_UM | _FPU_MASK_PM | _FPU_SINGLE | _FPU_RC_NEAREST;
+ _FPU_SETCW(c);
+}
+
+#else
+
+static void nine_setup_fpu(void)
+{
+ WARN_ONCE("FPU setup not supported on non-x86 platforms\n");
+}
+
+#endif
+
static void
NineDevice9_SetDefaultState( struct NineDevice9 *This, boolean is_reset )
{
@@ -168,6 +196,9 @@ NineDevice9_ctor( struct NineDevice9 *This,
IDirect3D9_AddRef(This->d3d9);
ID3DPresentGroup_AddRef(This->present);
+ if (!(This->params.BehaviorFlags & D3DCREATE_FPU_PRESERVE))
+ nine_setup_fpu();
+
This->pipe = This->screen->context_create(This->screen, NULL);
if (!This->pipe) { return E_OUTOFMEMORY; } /* guess */