diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-01 23:00:23 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-01 23:00:23 +0400 |
commit | 27102bfec4845df5ba8e65f7ca64d04840fbeab3 (patch) | |
tree | d83efbd5211512c4c504020b3e6f99b4332b62c9 /intern/cycles/device | |
parent | af7171524ab6809a5ebe51c3cbfdff17e2cd74aa (diff) |
Cycles: OpenCL library is now dynamically loaded so that blender doesn't crash
if it's not installed on the system.
Code copied from clew.h/clew.c in CLCC:
http://clcc.sourceforge.net/
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device.cpp | 9 | ||||
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 10 |
2 files changed, 8 insertions, 11 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 2f2d34dcef2..aed0be96229 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -24,6 +24,7 @@ #include "util_cuda.h" #include "util_debug.h" +#include "util_opencl.h" #include "util_opengl.h" #include "util_types.h" #include "util_vector.h" @@ -135,7 +136,10 @@ Device *Device::create(DeviceType type, bool background, int threads) #endif #ifdef WITH_OPENCL case DEVICE_OPENCL: - device = device_opencl_create(background); + if(clLibraryInit()) + device = device_opencl_create(background); + else + device = NULL; break; #endif default: @@ -189,7 +193,8 @@ vector<DeviceType> Device::available_types() #endif #ifdef WITH_OPENCL - types.push_back(DEVICE_OPENCL); + if(clLibraryInit()) + types.push_back(DEVICE_OPENCL); #endif #ifdef WITH_NETWORK diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 34c92986f46..d67fdc970a9 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -22,18 +22,11 @@ #include <stdlib.h> #include <string.h> -#ifdef __APPLE__ -#include <cl.h> -#include <cl_ext.h> -#else -#include <CL/cl.h> -#include <CL/cl_ext.h> -#endif - #include "device.h" #include "device_intern.h" #include "util_map.h" +#include "util_opencl.h" #include "util_opengl.h" #include "util_path.h" #include "util_time.h" @@ -150,7 +143,6 @@ public: string build_options = ""; - string csource = "../blender/intern/cycles"; build_options += "-I " + path_get("kernel") + " -I " + path_get("util"); /* todo: escape path */ build_options += " -Werror -cl-fast-relaxed-math -cl-strict-aliasing"; |