Revision: 29670 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29670 Author: blendix Date: 2010-06-24 17:54:01 +0200 (Thu, 24 Jun 2010)
Log Message: ----------- Runtime detection of SSE support for raytracing. Also enabled rayoptimization by default now on all platforms since it shouldn't crash anymore if SSE is not there. If this breaks compilation on some platforms, please let me know. Modified Paths: -------------- trunk/blender/CMakeLists.txt trunk/blender/config/linux2-config.py trunk/blender/config/linuxcross-config.py trunk/blender/config/win32-mingw-config.py trunk/blender/config/win32-vc-config.py trunk/blender/config/win64-vc-config.py trunk/blender/source/blender/render/intern/source/rayshade.c Added Paths: ----------- trunk/blender/source/blender/blenlib/BLI_cpu.h trunk/blender/source/blender/blenlib/intern/cpu.c Modified: trunk/blender/CMakeLists.txt =================================================================== --- trunk/blender/CMakeLists.txt 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/CMakeLists.txt 2010-06-24 15:54:01 UTC (rev 29670) @@ -110,7 +110,7 @@ OPTION(WITH_LZMA "Enable best LZMA compression, (used for pointcache)" ON) # Misc -OPTION(WITH_RAYOPTIMIZATION "Enable use of SIMD (SSE) optimizations for the raytracer" OFF) +OPTION(WITH_RAYOPTIMIZATION "Enable use of SIMD (SSE) optimizations for the raytracer" ON) OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF) OPTION(WITH_INSTALL "Install accompanying scripts and language files needed to run blender" ON) Modified: trunk/blender/config/linux2-config.py =================================================================== --- trunk/blender/config/linux2-config.py 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/config/linux2-config.py 2010-06-24 15:54:01 UTC (rev 29670) @@ -168,7 +168,7 @@ WITH_BF_OPENMP = True #Ray trace optimization -WITH_BF_RAYOPTIMIZATION = False +WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread'] ## Modified: trunk/blender/config/linuxcross-config.py =================================================================== --- trunk/blender/config/linuxcross-config.py 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/config/linuxcross-config.py 2010-06-24 15:54:01 UTC (rev 29670) @@ -169,7 +169,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib ${BF_ICONV_LIBPATH}' #Ray trace optimization -WITH_BF_RAYOPTIMIZATION = False +WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse'] CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ] Modified: trunk/blender/config/win32-mingw-config.py =================================================================== --- trunk/blender/config/win32-mingw-config.py 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/config/win32-mingw-config.py 2010-06-24 15:54:01 UTC (rev 29670) @@ -155,7 +155,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' #Ray trace optimization -WITH_BF_RAYOPTIMIZATION = False +WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse'] ## Modified: trunk/blender/config/win32-vc-config.py =================================================================== --- trunk/blender/config/win32-vc-config.py 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/config/win32-vc-config.py 2010-06-24 15:54:01 UTC (rev 29670) @@ -150,7 +150,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' #Ray trace optimization -WITH_BF_RAYOPTIMIZATION = False +WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE'] WITH_BF_STATICOPENGL = False Modified: trunk/blender/config/win64-vc-config.py =================================================================== --- trunk/blender/config/win64-vc-config.py 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/config/win64-vc-config.py 2010-06-24 15:54:01 UTC (rev 29670) @@ -163,7 +163,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' #Ray trace optimization -WITH_BF_RAYOPTIMIZATION = False +WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE','/arch:SSE2'] WITH_BF_STATICOPENGL = False Added: trunk/blender/source/blender/blenlib/BLI_cpu.h =================================================================== --- trunk/blender/source/blender/blenlib/BLI_cpu.h (rev 0) +++ trunk/blender/source/blender/blenlib/BLI_cpu.h 2010-06-24 15:54:01 UTC (rev 29670) @@ -0,0 +1,30 @@ +/* + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BLI_CPU_H +#define BLI_CPU_H + +int BLI_cpu_support_sse2(void); + +#endif + Added: trunk/blender/source/blender/blenlib/intern/cpu.c =================================================================== --- trunk/blender/source/blender/blenlib/intern/cpu.c (rev 0) +++ trunk/blender/source/blender/blenlib/intern/cpu.c 2010-06-24 15:54:01 UTC (rev 29670) @@ -0,0 +1,52 @@ +/** + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "BLI_cpu.h" + +int BLI_cpu_support_sse2(void) +{ +#if defined(__x86_64__) || defined(_M_X64) + /* x86_64 always has SSE2 instructions */ + return 1; +#elif defined(__GNUC__) && defined(i386) + /* for GCC x86 we check cpuid */ + unsigned int a, b, c, d; + __asm__("cpuid": "=a"(a), "=b"(b), "=c"(c), "=d"(d): "a"(1)); + return (d & 0x04000000) != 0; +#elif (defined(_MSC_VER) && defined(_M_IX86)) + /* also check cpuid for MSVC x86 */ + unsigned int d; + __asm { + xor eax, eax + inc eax + push ebx + cpuid + pop ebx + mov d, edx + } + return (d & 0x04000000) != 0; +#endif + + return 0; +} + Modified: trunk/blender/source/blender/render/intern/source/rayshade.c =================================================================== --- trunk/blender/source/blender/render/intern/source/rayshade.c 2010-06-24 13:52:27 UTC (rev 29669) +++ trunk/blender/source/blender/render/intern/source/rayshade.c 2010-06-24 15:54:01 UTC (rev 29670) @@ -41,9 +41,10 @@ #include "BKE_node.h" #include "BKE_utildefines.h" -#include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_cpu.h" #include "BLI_jitter.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "PIL_time.h" @@ -98,7 +99,7 @@ //TODO //if(detect_simd()) #ifdef __SSE__ - type = R_RAYSTRUCTURE_SIMD_SVBVH; + type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH; #else type = R_RAYSTRUCTURE_VBVH; #endif _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs