diff --git a/Source/Core/Common/Common.h b/Source/Core/Common/Common.h index 6b1a50b8d3..1f600926ff 100644 --- a/Source/Core/Common/Common.h +++ b/Source/Core/Common/Common.h @@ -101,20 +101,6 @@ private: #endif -// Architecture detection for Windows -// Architecture detection is done in cmake on all other platforms -// Windows is built on only x86/x86_64 -#if _WIN32 || _WIN64 -#define _M_X86 1 -#if _WIN64 -#define _ARCH_64 1 -#define _M_X86_64 1 -#else -#define _ARCH_32 1 -#define _M_X86_32 1 -#endif -#endif - // Windows compatibility #ifndef _WIN32 #include diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 48cbcdfe3c..2aa69ba1b7 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -125,6 +125,7 @@ + diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters index f2b194c007..d932b32be5 100644 --- a/Source/Core/Common/Common.vcxproj.filters +++ b/Source/Core/Common/Common.vcxproj.filters @@ -103,6 +103,7 @@ Logging + diff --git a/Source/Core/Common/XSaveWorkaround.cpp b/Source/Core/Common/XSaveWorkaround.cpp new file mode 100644 index 0000000000..30a2a42b2b --- /dev/null +++ b/Source/Core/Common/XSaveWorkaround.cpp @@ -0,0 +1,40 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#if defined(_WIN32) && defined(_ARCH_64) + +#include +#include + +// This puts the rest of this translation unit into a segment which is +// initialized by the CRT *before* any of the other code (including C++ +// static initializers). +#pragma warning(disable : 4075) +#pragma init_seg(".CRT$XCB") + +struct EnableXSaveWorkaround +{ + EnableXSaveWorkaround() + { + // Some Windows environments may have hardware support for AVX/FMA, + // but the OS does not support it. The CRT math library does not support + // this scenario, so we have to manually tell it not to use FMA3 + // instructions. + + // The API name is somewhat misleading - we're testing for OS support + // here. + if (!IsProcessorFeaturePresent(PF_XSAVE_ENABLED)) + { + _set_FMA3_enable(0); + } + } +}; + +static EnableXSaveWorkaround enableXSaveWorkaround; + +// N.B. Any code after this will still be in the .CRT$XCB segment. Please just +// do not append any code here unless it is intended to be executed before +// static initializers. + +#endif diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props index 36fe12a6ea..d7c6019ce0 100644 --- a/Source/VSProps/Base.props +++ b/Source/VSProps/Base.props @@ -57,7 +57,9 @@ false false true - /d2Zi+ /volatile:iso /D PSAPI_VERSION=1 %(AdditionalOptions) + /d2Zi+ /volatile:iso /D PSAPI_VERSION=1 /D _M_X86=1 %(AdditionalOptions) + /D _ARCH_32=1 /D _M_X86_32=1 %(AdditionalOptions) + /D _ARCH_64=1 /D _M_X86_64=1 %(AdditionalOptions) ProgramDatabase