Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorMartijn Berger <martijn.berger@gmail.com>2014-02-25 20:57:05 +0400
committerMartijn Berger <martijn.berger@gmail.com>2014-02-25 20:57:05 +0400
commitef73d547cc7c663ad180721094c81b3c81482ac3 (patch)
tree541c31db353a91e1d58db60ff4d8fb725a726aef /intern
parent03018353f67a1fc5e65585844144cfdf5addd408 (diff)
Fix T38815
For AVX support we need to check both OS support and CPU support.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/util/util_system.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 3d7781f6146..c4898626481 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