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.
This commit is contained in:
parent
4c81019823
commit
93238c3a3d
@ -110,7 +110,7 @@ OPTION(WITH_LZO "Enable fast LZO compression (used for pointcache)" ON
|
||||
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)
|
||||
|
||||
|
@ -168,7 +168,7 @@ BF_EXPAT_LIBPATH = '/usr/lib'
|
||||
WITH_BF_OPENMP = True
|
||||
|
||||
#Ray trace optimization
|
||||
WITH_BF_RAYOPTIMIZATION = False
|
||||
WITH_BF_RAYOPTIMIZATION = True
|
||||
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
|
||||
|
||||
##
|
||||
|
@ -169,7 +169,7 @@ BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader Open
|
||||
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' ]
|
||||
|
@ -155,7 +155,7 @@ BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader Open
|
||||
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
|
||||
|
||||
#Ray trace optimization
|
||||
WITH_BF_RAYOPTIMIZATION = False
|
||||
WITH_BF_RAYOPTIMIZATION = True
|
||||
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
|
||||
|
||||
##
|
||||
|
@ -150,7 +150,7 @@ BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader Open
|
||||
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
|
||||
|
@ -163,7 +163,7 @@ BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader Open
|
||||
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
|
||||
|
30
source/blender/blenlib/BLI_cpu.h
Normal file
30
source/blender/blenlib/BLI_cpu.h
Normal file
@ -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
|
||||
|
52
source/blender/blenlib/intern/cpu.c
Normal file
52
source/blender/blenlib/intern/cpu.c
Normal file
@ -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;
|
||||
}
|
||||
|
@ -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 @@ RayObject* RE_rayobject_create(Render *re, int type, int size)
|
||||
//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
|
||||
|
Loading…
Reference in New Issue
Block a user