Browse Source

Refactor SIMD support. Related to #1293.

Yao Wei Tjong 姚伟忠 9 years ago
parent
commit
e6121551bc

+ 9 - 8
CMake/Modules/CheckCompilerToolchain.cmake

@@ -30,7 +30,7 @@
 #  RPI
 #  POWERPC
 #
-# Compiler version in major.minor.patch format:
+# Compiler version in major.minor.patch format, except MSVC where it follows its own format:
 #  COMPILER_VERSION
 #
 # CPU SIMD instruction extensions support:
@@ -140,16 +140,17 @@ if (NOT ARM)
             set (${VAR} 1)
         endforeach ()
     else ()
-        check_extension (mmx)
-        if (NOT EMSCRIPTEN)     # Emscripten does not support SSE/SSE2 (yet) now but erroneously responding positively to our probe, so skip them for Emscripten for now
+        if (MINGW AND COMPILER_VERSION VERSION_LESS 4.9.1)
+            # Certain MinGW versions fail to compile SSE code. This is the initial guess for known "bad" version range, and can be tightened later
+            message (WARNING "Disabling SSE by default due to MinGW version. It is recommended to upgrade to MinGW with GCC >= 4.9.1. You can also try to re-enable SSE with CMake option -DURHO3D_SSE=1, but this may result in compile errors.")
+        elseif (NOT EMSCRIPTEN)     # Emscripten does not support SSE/SSE2 (yet) now but erroneously responding positively to our probe, so skip them for Emscripten for now
             check_extension (sse)
             check_extension (sse2)
         endif ()
-     endif ()
-    # As newer CPUs from AMD do not support 3DNow! anymore, we cannot make any assumption for 3DNow! extension check
-    # Don't bother with this check on AppleClang and MSVC compiler toolchains (Urho3D only supports CPU with SSE2 on the asscoiated platforms anyway)
-    if (NOT APPLE AND NOT MSVC)
-        check_extension (3dnow __3dNOW__)
+        if (NOT APPLE AND NOT WIN32)    # Linux only
+            check_extension (mmx)
+            check_extension (3dnow __3dNOW__)
+        endif ()
     endif ()
     # For completeness sake as currently we do not support PowerPC (yet)
     if (POWERPC)

+ 44 - 57
CMake/Modules/Urho3D-CMake-common.cmake

@@ -93,7 +93,6 @@ if (IOS OR (RPI AND "${RPI_ABI}" MATCHES NEON))    # Stringify in case RPI_ABI i
     # The 'NEON' CMake variable is already set by android.toolchain.cmake when the chosen ANDROID_ABI uses NEON
     set (NEON TRUE)
 endif ()
-cmake_dependent_option (URHO3D_NEON "Enable NEON instruction set (ARM platforms with NEON only)" TRUE "NEON" FALSE)
 if (CMAKE_HOST_WIN32)
     if (NOT DEFINED URHO3D_MKLINK)
         # Test whether the host system is capable of setting up symbolic link
@@ -138,20 +137,10 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # On Windows platform Direct3D11 can be optionally chosen
     # Using Direct3D11 on non-MSVC compiler may require copying and renaming Microsoft official libraries (.lib to .a), else link failures or non-functioning graphics may result
     cmake_dependent_option (URHO3D_D3D11 "Use Direct3D11 instead of Direct3D9 (Windows platform only); overrides URHO3D_OPENGL option" FALSE "WIN32" FALSE)
-    # Set the default to true for all the platforms that support SSE extension except specificially stated otherwise below
-    if (HAVE_SSE OR HAVE_SSE2)
-        set (URHO3D_DEFAULT_SSE TRUE)
-        if (MINGW)
-            # Certain MinGW versions fail to compile SSE code. This is the initial guess for known "bad" version range, and can be tightened later
-            if (COMPILER_VERSION VERSION_LESS 4.9.1)
-                message (WARNING "Disabling SSE by default due to MinGW version. It is recommended to upgrade to MinGW with GCC >= 4.9.1. You can also try to re-enable SSE with CMake option -DURHO3D_SSE=1, but this may result in compile errors.")
-                set (URHO3D_DEFAULT_SSE FALSE)
-            endif ()
-        endif ()
-    else ()
-        set (URHO3D_DEFAULT_SSE FALSE)
+    if (NOT ARM)
+        # It is not possible to turn SSE off on 64-bit MSVC and it appears it is also not able to do so safely on 64-bit GCC
+        cmake_dependent_option (URHO3D_SSE "Enable SSE/SSE2 instruction set (32-bit Web and Intel platforms only, including Android on Intel Atom); default to true on Intel and false on Web platform; the effective SSE level could be higher, see also URHO3D_DEPLOYMENT_TARGET and CMAKE_OSX_DEPLOYMENT_TARGET build options" ${HAVE_SSE2} "NOT URHO3D_64BIT" TRUE)
     endif ()
-    cmake_dependent_option (URHO3D_SSE "Enable SSE/SSE2 instruction set (Web and Intel platforms only including Android on Intel Atom); default to true on Intel and false on Web platform; the effective SSE level could be higher, see also URHO3D_DEPLOYMENT_TARGET and CMAKE_OSX_DEPLOYMENT_TARGET build options" ${URHO3D_DEFAULT_SSE} "NOT ARM" FALSE)
     cmake_dependent_option (URHO3D_3DNOW "Enable 3DNow! instruction set (Linux platform only); should only be used for older CPU with (legacy) 3DNow! support" ${HAVE_3DNOW} "NOT WIN32 AND NOT APPLE AND NOT WEB AND NOT ARM AND NOT URHO3D_SSE" FALSE)
     cmake_dependent_option (URHO3D_MMX "Enable MMX instruction set (32-bit Linux platform only); the MMX is effectively enabled when 3DNow! or SSE is enabled; should only be used for older CPU with MMX support" ${HAVE_MMX} "NOT WIN32 AND NOT APPLE AND NOT WEB AND NOT ARM AND NOT URHO3D_64BIT AND NOT URHO3D_SSE AND NOT URHO3D_3DNOW" FALSE)
     # For completeness sake - this option is intentionally not documented as we do not officially support PowerPC (yet)
@@ -199,8 +188,10 @@ else ()
     if (URHO3D_PCH OR URHO3D_UPDATE_SOURCE_TREE OR URHO3D_TOOLS)
         # Just reference it to suppress "unused variable" CMake warning on downstream projects using this CMake module
     endif ()
-    # All Urho3D downstream projects require Urho3D library, so find Urho3D library here now
-    if (NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
+    if (CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
+        set (URHO3D_SSE ${HAVE_SSE2})
+    else ()
+        # All Urho3D downstream projects require Urho3D library, so find Urho3D library here now
         find_package (Urho3D REQUIRED)
         include_directories (${URHO3D_INCLUDE_DIRS})
     endif ()
@@ -342,9 +333,11 @@ if ($ENV{COVERITY_SCAN_BRANCH})
     add_definitions (-DCOVERITY_SCAN_MODEL)
 endif ()
 
-# Enable NEON instruction set.
-if (URHO3D_NEON)
-    add_definitions (-DURHO3D_NEON -DSTBI_NEON)     # BT_USE_NEON is already being self-defined by Bullet library as appropriate
+# Enable/disable SIMD instruction set for STB image (do it here instead of in the STB CMakeLists.txt because the header files are exposed to Urho3D library user)
+if (NEON AND NOT XCODE)
+    add_definitions (-DSTBI_NEON)       # Cannot define it directory for Xcode due to universal binary support, we define it in the setup_target() macro instead for Xcode
+elseif (NOT URHO3D_SSE)
+    add_definitions (-DSTBI_NO_SIMD)    # GCC/Clang/MinGW will switch this off automatically except MSVC, but no harm to make it explicit for all
 endif ()
 
 # Enable structured exception handling and minidumps on MSVC only.
@@ -564,9 +557,15 @@ if (MSVC)
     set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_RUNTIME} /fp:fast /Zi /GS- /D _SECURE_SCL=0")
     set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
     # In Visual Studio, SSE2 flag is redundant if already compiling as 64bit; it is already the default for VS2012 (onward) on 32bit
-    if (URHO3D_SSE AND NOT URHO3D_64BIT AND MSVC_VERSION LESS 1700)
-        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
-        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
+    # Instead, we must turn SSE/SSE2 off explicitly if user really intends to turn it off
+    if (URHO3D_SSE)
+        if (NOT URHO3D_64BIT AND MSVC_VERSION LESS 1700)
+            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
+            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
+        endif ()
+    else ()
+        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:IA32")
+        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:IA32")
     endif ()
     set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF /DEBUG")
     set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF")
@@ -593,7 +592,7 @@ else ()
             set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${RPI_CFLAGS}")
             set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RPI_CFLAGS}")
         else ()
-            if (NOT XCODE AND NOT WEB)
+            if (URHO3D_SSE AND NOT XCODE AND NOT WEB)
                 # This may influence the effective SSE level when URHO3D_SSE is on as well
                 set (URHO3D_DEPLOYMENT_TARGET native CACHE STRING "Specify the minimum CPU type on which the target binaries are to be deployed (Linux, MinGW, and non-Xcode OSX native build only), see GCC/Clang's -march option for possible values; Use 'generic' for targeting a wide range of generic processors")
                 if (NOT URHO3D_DEPLOYMENT_TARGET STREQUAL generic)
@@ -607,38 +606,32 @@ else ()
             # The compiler flags will be added later conditionally when the effective arch is i386 during build time (using XCODE_ATTRIBUTE target property)
             if (NOT XCODE)
                 if (NOT URHO3D_64BIT)
-                    if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
-                        # Clang enables SSE support for i386 ABI by default, so use the '-mno-sse' compiler flag to nullify that and make it consistent with GCC
-                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-sse")
-                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-sse")
-                    endif ()
                     # Not the compiler native ABI, this could only happen on multilib-capable compilers
-                    # We don't add the ABI flag for Xcode because it automatically passes '-arch i386' compiler flag when targeting 32 bit which does the same thing as '-m32'
                     if (NATIVE_64BIT)
                         set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
                         set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
                     endif ()
-                    if (URHO3D_MMX)
-                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmmx")
-                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx")
-                    endif()
                     # The effective SSE level could be higher, see also URHO3D_DEPLOYMENT_TARGET and CMAKE_OSX_DEPLOYMENT_TARGET build options
                     # The -mfpmath=sse is not set in global scope but it may be set in local scope when building LuaJIT sub-library for x86 arch
-                    if (URHO3D_SSE AND HAVE_SSE)
-                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse")
-                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
-                    endif ()
-                    if (URHO3D_SSE AND HAVE_SSE2)
-                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
-                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
+                    if (URHO3D_SSE)
+                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2")
+                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2")
                     endif ()
                 endif ()
-                if (URHO3D_3DNOW)
-                    if (URHO3D_64BIT)
-                        set (DISABLE_SSE_FLAG -mno-sse)
+                if (NOT URHO3D_SSE)
+                    if (URHO3D_64BIT OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
+                        # Clang enables SSE support for i386 ABI by default, so use the '-mno-sse' compiler flag to nullify that and make it consistent with GCC
+                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-sse")
+                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-sse")
+                    endif ()
+                    if (URHO3D_MMX)
+                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmmx")
+                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx")
+                    endif()
+                    if (URHO3D_3DNOW)
+                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m3dnow")
+                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m3dnow")
                     endif ()
-                    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DISABLE_SSE_FLAG} -m3dnow")
-                    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DISABLE_SSE_FLAG} -m3dnow")
                 endif ()
                 # For completeness sake only as we do not support PowerPC (yet)
                 if (URHO3D_ALTIVEC)
@@ -685,6 +678,7 @@ else ()
                 if (URHO3D_SSE)
                     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mstackrealign")
                     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
+                    add_definitions (-DSTBI_MINGW_ENABLE_SSE2)
                 else ()
                     if (DEFINED ENV{TRAVIS})
                         # TODO: Remove this workaround when Travis CI VM has been migrated to Ubuntu 14.04 LTS
@@ -1006,25 +1000,18 @@ macro (setup_target)
         unset (LINK_DEPENDS)
     endif ()
     # Extra compiler flags for Xcode which are dynamically changed based on active arch in order to support Mach-O universal binary targets
+    # We don't add the ABI flag for Xcode because it automatically passes '-arch i386' compiler flag when targeting 32 bit which does the same thing as '-m32'
     if (XCODE)
         # Speed up build when in Debug configuration by building active arch only
         list (FIND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH ATTRIBUTE_ALREADY_SET)
         if (ATTRIBUTE_ALREADY_SET EQUAL -1)
             list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
         endif ()
-        if (URHO3D_SSE OR URHO3D_NEON)
+        if (URHO3D_SSE OR NEON)
             # When targeting x86 with SSE enabled; or when targeting iOS with NEON enabled as universal binary includes iPhoneSimulator x86 arch too
-            # This is kind of redundant because Clang by default always enable SSE support for both i386 and x86_64 ABIs, still just to be sure
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=i386] "-msse -msse2 $(OTHER_CFLAGS)")
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=i386] "-msse -msse2 $(OTHER_CPLUSPLUSFLAGS)")
-        elseif (URHO3D_3DNOW)
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=i386] "-mno-sse -m3dnow $(OTHER_CFLAGS)")
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=i386] "-mno-sse -m3dnow $(OTHER_CPLUSPLUSFLAGS)")
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=x86_64] "-mno-sse -m3dnow $(OTHER_CFLAGS)")
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "-mno-sse -m3dnow $(OTHER_CPLUSPLUSFLAGS)")
-        elseif (URHO3D_MMX)
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=i386] "-mno-sse -mmmx $(OTHER_CFLAGS)")
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=i386] "-mno-sse -mmmx $(OTHER_CPLUSPLUSFLAGS)")
+            # Clang by default always enable SSE instruction set for both i386 and x86_64 ABIs, so we only need to take care of special compiler flags/defines for NEON
+            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[sdk=iphoneos*] "-DSTBI_NEON $(OTHER_CFLAGS)")
+            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*] "-DSTBI_NEON $(OTHER_CPLUSPLUSFLAGS)")
         else ()
             # Nullify the Clang default so that it is consistent with GCC
             list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=i386] "-mno-sse $(OTHER_CFLAGS)")

+ 4 - 3
Docs/GettingStarted.dox

@@ -56,7 +56,9 @@ To run Urho3D, the minimum system requirements are:
 
 - Web: modern browsers with fast JavaScript engine and HTML5 and WebGL support.
 
-SSE2/NEON requirement can be eliminated by disabling the use of SSE2/NEON instruction set, see URHO3D_SSE and URHO3D_NEON build options below. For Linux platform using GCC/Clang compiler toolchain, the MMX and 3DNow! extensions can be enabled for older CPUs by using URHO3D_MMX and URHO3D_3DNOW build options when the option is available. The MMX and SSE/SSE2 extensions on x86_64 ABI are always enabled, so the URHO3D_MMX and URHO3D_SSE build option do not exist on x86_64 ABI. Also note that MMX extension is effectively enabled when 3DNow! or SSE/SSE2 extension is enabled, so disabling URHO3D_MMX build option in this case has no effect. The URHO3D_MMX and URHO3D_3DNOW build options are disabled by default. They should only be enabled when targeting older CPU with MMX and 3DNow! support, respectively.
+SSE2 requirement can be eliminated by disabling the use of SSE2 instruction set, see URHO3D_SSE build option below. For Linux platform using GCC/Clang compiler toolchain, the MMX and 3DNow! extensions can be enabled for older CPUs by using URHO3D_MMX and URHO3D_3DNOW build options when the option is available. The MMX and SSE/SSE2 extensions on x86_64 ABI are always enabled, so the URHO3D_MMX and URHO3D_SSE build option do not exist on x86_64 ABI. Also note that MMX extension is effectively enabled when 3DNow! or SSE/SSE2 extension is enabled, so disabling URHO3D_MMX build option in this case has no effect. The URHO3D_MMX and URHO3D_3DNOW build options are disabled by default. They should only be enabled when targeting older CPU with MMX and 3DNow! support, respectively.
+
+The NEON instruction set will be used by default whenever it is available. See the ANDROID_ABI and RPI_ABI build options for more detail for Android and Raspberry-Pi platforms, respectively. The NEON instruction set is always enabled on iOS and tVOS platforms.
 
 CMake (http://www.cmake.org) is required to configure and generate the Urho3D project build tree. The minimum required version is 2.8.6. However, it is recommended to use the latest CMake version available out there, especially when targeting Mac OS X and iOS platforms using the latest Xcode version available. This is because Apple is known to change the internal working of Xcode with little regards to other third party build tools, such as CMake.
 
@@ -114,8 +116,7 @@ A number of build options can be defined when invoking the build scripts or when
 |URHO3D_C++11         |0|Enable use of C++11 standard|
 |URHO3D_MMX           |0|Enable MMX instruction set (32-bit Linux platform only); the MMX is effectively enabled when 3DNow! or SSE is enabled; should only be used for older CPU with MMX support|
 |URHO3D_3DNOW         |0|Enable 3DNow! instruction set (Linux platform only); should only be used for older CPU with (legacy) 3DNow! support|
-|URHO3D_SSE           |*|Enable SSE/SSE2 instruction set (Web and Intel platforms only including Android on Intel Atom); default to true on Intel and false on Web platform; the effective SSE level could be higher, see also URHO3D_DEPLOYMENT_TARGET and CMAKE_OSX_DEPLOYMENT_TARGET build options|
-|URHO3D_NEON          |1|Enable NEON instruction set (ARM platforms with NEON only)|
+|URHO3D_SSE           |*|Enable SSE/SSE2 instruction set (32-bit Web and Intel platforms only, including Android on Intel Atom); default to true on Intel and false on Web platform; the effective SSE level could be higher, see also URHO3D_DEPLOYMENT_TARGET and CMAKE_OSX_DEPLOYMENT_TARGET build options|
 |URHO3D_MINIDUMPS     |1|Enable minidumps on crash (VS only)|
 |URHO3D_FILEWATCHER   |1|Enable filewatcher support|
 |URHO3D_PACKAGING     |*|Enable resources packaging support, on Web platform default to 1, on other platforms default to 0|

+ 1 - 1
Source/ThirdParty/Bullet/src/BulletCollision/Gimpact/gim_memory.h

@@ -118,7 +118,7 @@ void gim_free(void *ptr);
 
 
 // Urho3D - allow to disable SIMD, allow MinGW to use SIMD
-#if defined(URHO3D_SSE) && defined(_WIN32) && !defined(__CYGWIN__)
+#if (!defined(_M_IX86_FP) || _M_IX86_FP || defined(__SSE__)) && defined(_WIN32) && !defined(__CYGWIN__)
     #define GIM_SIMD_MEMORY 1
 #endif
 

+ 7 - 7
Source/ThirdParty/Bullet/src/LinearMath/btScalar.h

@@ -74,10 +74,11 @@ inline int	btGetVersion()
  			#define btFsel(a,b,c) __fsel((a),(b),(c))
 		#else
 
-// Urho3D: allow to disable SSE
 #if defined (_M_ARM)
             //Do not turn SSE on for ARM (may want to turn on BT_USE_NEON however)
-#elif (defined (URHO3D_SSE) && defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))
+
+// Urho3D: allow to disable SSE
+#elif ((!defined(_M_IX86_FP) || _M_IX86_FP) && defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))
 			#if _MSC_VER>1400
 				#define BT_USE_SIMD_VECTOR3
 			#endif
@@ -178,12 +179,11 @@ inline int	btGetVersion()
 
 // Urho3D - allow to disable SSE/NEON and let Linux, MinGW, & Android platforms in besides Apple
 #if (!defined (BT_USE_DOUBLE_PRECISION))
-    #if defined (URHO3D_SSE) && (defined (__i386__) || defined (__x86_64__))
+    #if defined(__SSE__)
 		#define BT_USE_SIMD_VECTOR3
 		#define BT_USE_SSE
 		//BT_USE_SSE_IN_API is enabled on Mac OSX by default, because memory is automatically aligned on 16-byte boundaries
-		// Urho3D - disable BT_USE_SSE_IN_API in all cases, as it had led to issues (#1134, #1193)
-                //#define BT_USE_SSE_IN_API
+		#define BT_USE_SSE_IN_API
         #ifdef BT_USE_SSE
             // include appropriate SSE level
             #if defined (__SSE4_1__)
@@ -196,7 +196,7 @@ inline int	btGetVersion()
                 #include <emmintrin.h>
             #endif
         #endif //BT_USE_SSE
-    #elif defined (URHO3D_NEON) && defined( __ARM_NEON__ )
+    #elif defined( __ARM_NEON__ )
             #define BT_USE_NEON 1
 			#define BT_USE_SIMD_VECTOR3
 		
@@ -261,7 +261,7 @@ inline int	btGetVersion()
 		#define btFullAssert(x)
 		#define btLikely(_c)  _c
 		#define btUnlikely(_c) _c
-#endif //__APPLE__ 
+#endif
 
 #endif // LIBSPE2
 

+ 4 - 2
Source/Urho3D/CMakeLists.txt

@@ -41,8 +41,10 @@ if (URHO3D_CLANG_TOOLS OR URHO3D_BINDINGS)
 endif ()
 
 # Check sincosf support
-include (CheckLibraryExists)
-check_library_exists (m sincosf "" HAVE_SINCOSF)
+if (NOT MSVC)   # There is no chance MSVC would pass this one as it does not have libm
+    include (CheckLibraryExists)
+    check_library_exists (m sincosf "" HAVE_SINCOSF)
+endif ()
 if (HAVE_SINCOSF)
     add_definitions (-DHAVE_SINCOSF)
 else ()