[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39849] branches/cycles: Cycles: OpenCL library is now dynamically loaded so that blender doesn't crash
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu Sep 1 21:00:23 CEST 2011
Revision: 39849
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39849
Author: blendix
Date: 2011-09-01 19:00:23 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
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/
Modified Paths:
--------------
branches/cycles/intern/cycles/CMakeLists.txt
branches/cycles/intern/cycles/app/CMakeLists.txt
branches/cycles/intern/cycles/cmake/external_libs.cmake
branches/cycles/intern/cycles/device/device.cpp
branches/cycles/intern/cycles/device/device_opencl.cpp
branches/cycles/intern/cycles/doc/license/readme.txt
branches/cycles/intern/cycles/util/CMakeLists.txt
branches/cycles/source/creator/CMakeLists.txt
Added Paths:
-----------
branches/cycles/intern/cycles/doc/license/Boost.txt
branches/cycles/intern/cycles/util/util_opencl.c
branches/cycles/intern/cycles/util/util_opencl.h
Modified: branches/cycles/intern/cycles/CMakeLists.txt
===================================================================
--- branches/cycles/intern/cycles/CMakeLists.txt 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/CMakeLists.txt 2011-09-01 19:00:23 UTC (rev 39849)
@@ -54,8 +54,6 @@
if(WITH_CYCLES_OPENCL)
add_definitions(-DWITH_OPENCL)
- include_directories(${OPENCL_INCLUDE_DIR})
-
endif()
include_directories(
Modified: branches/cycles/intern/cycles/app/CMakeLists.txt
===================================================================
--- branches/cycles/intern/cycles/app/CMakeLists.txt 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/app/CMakeLists.txt 2011-09-01 19:00:23 UTC (rev 39849)
@@ -35,10 +35,6 @@
list(APPEND LIBRARIES ${PARTIO_LIBRARIES})
endif()
-if(WITH_CYCLES_OPENCL)
- list(APPEND LIBRARIES ${OPENCL_LIBRARIES})
-endif()
-
if(WITH_CYCLES_TEST)
add_executable(cycles_test cycles_test.cpp cycles_xml.cpp cycles_xml.h)
target_link_libraries(cycles_test ${LIBRARIES})
Modified: branches/cycles/intern/cycles/cmake/external_libs.cmake
===================================================================
--- branches/cycles/intern/cycles/cmake/external_libs.cmake 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/cmake/external_libs.cmake 2011-09-01 19:00:23 UTC (rev 39849)
@@ -104,24 +104,3 @@
endif()
-###########################################################################
-# OpenCL
-
-if(WITH_CYCLES_OPENCL)
-
- if(APPLE)
- set(OPENCL_INCLUDE_DIR "/System/Library/Frameworks/OpenCL.framework/Headers")
- set(OPENCL_LIBRARIES "-framework OpenCL")
- endif()
-
- if(WIN32)
- set(OPENCL_INCLUDE_DIR "")
- set(OPENCL_LIBRARIES "OpenCL")
- endif()
-
- if(UNIX AND NOT APPLE)
- set(OPENCL_INCLUDE_DIR ${CYCLES_OPENCL})
- set(OPENCL_LIBRARIES "OpenCL")
- endif()
-endif()
-
Modified: branches/cycles/intern/cycles/device/device.cpp
===================================================================
--- branches/cycles/intern/cycles/device/device.cpp 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/device/device.cpp 2011-09-01 19:00:23 UTC (rev 39849)
@@ -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 @@
#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 @@
#endif
#ifdef WITH_OPENCL
- types.push_back(DEVICE_OPENCL);
+ if(clLibraryInit())
+ types.push_back(DEVICE_OPENCL);
#endif
#ifdef WITH_NETWORK
Modified: branches/cycles/intern/cycles/device/device_opencl.cpp
===================================================================
--- branches/cycles/intern/cycles/device/device_opencl.cpp 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/device/device_opencl.cpp 2011-09-01 19:00:23 UTC (rev 39849)
@@ -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 @@
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";
Added: branches/cycles/intern/cycles/doc/license/Boost.txt
===================================================================
--- branches/cycles/intern/cycles/doc/license/Boost.txt (rev 0)
+++ branches/cycles/intern/cycles/doc/license/Boost.txt 2011-09-01 19:00:23 UTC (rev 39849)
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
Modified: branches/cycles/intern/cycles/doc/license/readme.txt
===================================================================
--- branches/cycles/intern/cycles/doc/license/readme.txt 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/doc/license/readme.txt 2011-09-01 19:00:23 UTC (rev 39849)
@@ -8,4 +8,5 @@
* Sobol direction vectors are licensed under the Modified BSD license.
* Matrix code adapted from OpenEXR under the Modified BSD license.
* Procedural texture functions from Blender are licensed under GPL v2 or later.
+* Boost and OpenCL dynamic loading under Boost License.
Modified: branches/cycles/intern/cycles/util/CMakeLists.txt
===================================================================
--- branches/cycles/intern/cycles/util/CMakeLists.txt 2011-09-01 18:45:50 UTC (rev 39848)
+++ branches/cycles/intern/cycles/util/CMakeLists.txt 2011-09-01 19:00:23 UTC (rev 39849)
@@ -9,6 +9,7 @@
util_cuda.cpp
util_dynlib.cpp
util_md5.cpp
+ util_opencl.c
util_path.cpp
util_string.cpp
util_system.cpp
@@ -34,6 +35,7 @@
util_map.h
util_math.h
util_md5.h
+ util_opencl.h
util_opengl.h
util_param.h
util_path.h
Added: branches/cycles/intern/cycles/util/util_opencl.c
===================================================================
--- branches/cycles/intern/cycles/util/util_opencl.c (rev 0)
+++ branches/cycles/intern/cycles/util/util_opencl.c 2011-09-01 19:00:23 UTC (rev 39849)
@@ -0,0 +1,317 @@
+//////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2009 Organic Vectory B.V.
+// Written by George van Venrooij
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file doc/license/Boost.txt)
+// Extracted from the CLCC project - http://clcc.sourceforge.net/
+//////////////////////////////////////////////////////////////////////////
+
+#include "util_opencl.h"
+
+#ifndef CLCC_GENERATE_DOCUMENTATION
+#ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #define VC_EXTRALEAN
+ #include <windows.h>
+
+ typedef HMODULE CLCC_DYNLIB_HANDLE;
+
+ #define CLCC_DYNLIB_OPEN LoadLibrary
+ #define CLCC_DYNLIB_CLOSE FreeLibrary
+ #define CLCC_DYNLIB_IMPORT GetProcAddress
+#else
+ #include <dlfcn.h>
+
+ typedef void* CLCC_DYNLIB_HANDLE;
+
+ #define CLCC_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
+ #define CLCC_DYNLIB_CLOSE dlclose
+ #define CLCC_DYNLIB_IMPORT dlsym
+#endif
+#else
+ //typedef implementation_defined CLCC_DYNLIB_HANDLE;
+ //#define CLCC_DYNLIB_OPEN(path) implementation_defined
+ //#define CLCC_DYNLIB_CLOSE implementation_defined
+ //#define CLCC_DYNLIB_IMPORT implementation_defined
+#endif
+
+#include <stdlib.h>
+
+//! \brief module handle
+static CLCC_DYNLIB_HANDLE module = NULL;
+
+// Variables holding function entry points
+#ifndef CLCC_GENERATE_DOCUMENTATION
+PFNCLGETPLATFORMIDS __clewGetPlatformIDs = NULL;
+PFNCLGETPLATFORMINFO __clewGetPlatformInfo = NULL;
+PFNCLGETDEVICEIDS __clewGetDeviceIDs = NULL;
+PFNCLGETDEVICEINFO __clewGetDeviceInfo = NULL;
+PFNCLCREATECONTEXT __clewCreateContext = NULL;
+PFNCLCREATECONTEXTFROMTYPE __clewCreateContextFromType = NULL;
+PFNCLRETAINCONTEXT __clewRetainContext = NULL;
+PFNCLRELEASECONTEXT __clewReleaseContext = NULL;
+PFNCLGETCONTEXTINFO __clewGetContextInfo = NULL;
+PFNCLCREATECOMMANDQUEUE __clewCreateCommandQueue = NULL;
+PFNCLRETAINCOMMANDQUEUE __clewRetainCommandQueue = NULL;
+PFNCLRELEASECOMMANDQUEUE __clewReleaseCommandQueue = NULL;
+PFNCLGETCOMMANDQUEUEINFO __clewGetCommandQueueInfo = NULL;
+PFNCLSETCOMMANDQUEUEPROPERTY __clewSetCommandQueueProperty = NULL;
+PFNCLCREATEBUFFER __clewCreateBuffer = NULL;
+PFNCLCREATEIMAGE2D __clewCreateImage2D = NULL;
+PFNCLCREATEIMAGE3D __clewCreateImage3D = NULL;
+PFNCLRETAINMEMOBJECT __clewRetainMemObject = NULL;
+PFNCLRELEASEMEMOBJECT __clewReleaseMemObject = NULL;
+PFNCLGETSUPPORTEDIMAGEFORMATS __clewGetSupportedImageFormats = NULL;
+PFNCLGETMEMOBJECTINFO __clewGetMemObjectInfo = NULL;
+PFNCLGETIMAGEINFO __clewGetImageInfo = NULL;
+PFNCLCREATESAMPLER __clewCreateSampler = NULL;
+PFNCLRETAINSAMPLER __clewRetainSampler = NULL;
+PFNCLRELEASESAMPLER __clewReleaseSampler = NULL;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list