Possible fix for [#36086] Activating the opencl option in the compositor causes blend...
authorThomas Dinges <blender@dingto.org>
Wed, 17 Jul 2013 12:57:03 +0000 (12:57 +0000)
committerThomas Dinges <blender@dingto.org>
Wed, 17 Jul 2013 12:57:03 +0000 (12:57 +0000)
* Now OCL_init() returns error messages if the OpenCL library cannot be loaded.

intern/opencl/OCL_opencl.h
intern/opencl/intern/OCL_opencl.c
intern/opencl/intern/clew.c
source/blender/compositor/intern/COM_WorkScheduler.cpp

index 4ee167b2fb43af597666fe86cc627f40009564c7..733e3527197416d16895d54761db44ad609556cf 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 #endif
 
 #include "intern/clew.h"
-void OCL_init(void);
+int OCL_init(void);
 
 #ifdef __cplusplus
 }
index e3130e16bde7aae3ff833acf4c95a86f460f8083..33a936896fd7eaadd0d828238cf79c5630d75661 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "OCL_opencl.h"
 
-void OCL_init(void)
+int OCL_init(void)
 {
 #ifdef _WIN32
        const char *path = "OpenCL.dll";
@@ -32,6 +32,6 @@ void OCL_init(void)
        const char *path = "libOpenCL.so";
 #endif
 
-       clewInit(path);
+       return (clewInit(path) == CLEW_SUCCESS);
 }
 
index d68eb17288f532e8d490b273f5a562ce42658f6a..1e31ebced0a042a083daf0b7433b904eed06949e 100644 (file)
@@ -227,6 +227,11 @@ int clewInit(const char* path)
     __oclEnqueueWaitForEvents          = (PFNCLENQUEUEWAITFOREVENTS        )CLCC_DYNLIB_IMPORT(module, "clEnqueueWaitForEvents");
     __oclEnqueueBarrier                = (PFNCLENQUEUEBARRIER              )CLCC_DYNLIB_IMPORT(module, "clEnqueueBarrier");
     __oclGetExtensionFunctionAddress   = (PFNCLGETEXTENSIONFUNCTIONADDRESS )CLCC_DYNLIB_IMPORT(module, "clGetExtensionFunctionAddress");
+       
+       if(__oclGetPlatformIDs == NULL) return CLEW_ERROR_OPEN_FAILED;
+       if(__oclGetPlatformInfo == NULL) return CLEW_ERROR_OPEN_FAILED;
+       if(__oclGetDeviceIDs == NULL) return CLEW_ERROR_OPEN_FAILED;
+       if(__oclGetDeviceInfo == NULL) return CLEW_ERROR_OPEN_FAILED;
 
     return CLEW_SUCCESS;
 }
index 402fa28e210c856a1eced34cd09a1cae322dae74..be9a3612a0b52de181f1c806c59c3be26e03fb72 100644 (file)
@@ -304,7 +304,8 @@ void WorkScheduler::initialize(bool use_opencl)
                g_context = NULL;
                g_program = NULL;
 
-               OCL_init(); /* this will check and skip if already initialized */
+               if(!OCL_init()) /* this will check for errors and skip if already initialized */
+                       return;
 
                if (clCreateContextFromType) {
                        cl_uint numberOfPlatforms = 0;