Commit: ef73d547cc7c663ad180721094c81b3c81482ac3
Author: Martijn Berger
Date:   Tue Feb 25 17:57:05 2014 +0100
https://developer.blender.org/rBef73d547cc7c663ad180721094c81b3c81482ac3

Fix T38815

For AVX support we need to check both OS support and CPU support.

===================================================================

M       intern/cycles/util/util_system.cpp

===================================================================

diff --git a/intern/cycles/util/util_system.cpp 
b/intern/cycles/util/util_system.cpp
index 3d7781f..c489862 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -161,8 +161,24 @@ static CPUCapabilities& system_cpu_capabilities()
                        caps.sse41 = (result[2] & ((int)1 << 19)) != 0;
                        caps.sse42 = (result[2] & ((int)1 << 20)) != 0;
 
-                       caps.avx = (result[2] & ((int)1 << 28)) != 0;
                        caps.fma3 = (result[2] & ((int)1 << 12)) != 0;
+                       caps.avx = false;
+                       bool os_uses_xsave_xrestore = result[2] & ((int)1 << 
27) != 0;
+                       bool cpu_avx_support = (result[2] & ((int)1 << 28)) != 
0;
+
+                       if( os_uses_xsave_xrestore && cpu_avx_support) {
+                               // Check if the OS will save the YMM registers
+                               uint32_t xcr_feature_mask;
+                               #if defined(__GNUC__)
+                                       int edx; // not used
+                                       __asm__ (".byte 0x0f, 0x01, 0xd0" : 
"=a" (xcr_feature_mask) , "=d" (edx) : "c" (0) ); /* actual opcode for xgetbv */
+                               #elif defined(_MSC_VER) && 
defined(_XCR_XFEATURE_ENABLED_MASK)
+                                       xcr_feature_mask = 
(uint32_t)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);  /* min VS2010 SP1 compiler is 
required */
+                               #else
+                                       xcr_feature_mask = 0;
+                               #endif
+                               caps.avx = (xcr_feature_mask & 0x6) == 0x6;
+                       }
                }
 
 #if 0

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to