diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2012-05-29 18:13:08 +0400 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2012-05-29 18:13:08 +0400 |
commit | 8a30382a8ad0824ddf85ce667d6bdd3a2e7fdb87 (patch) | |
tree | 7561e72f1325c17aa77543ffbe3099cb6a3eacb8 /source/blender/compositor/intern/COM_WorkScheduler.cpp | |
parent | 45dbb715eea363d33125de04411ac4ce5e7a63a9 (diff) |
* Compositor fix for OpenCL [OpenCL platform installed, but no
available devices]
- could happen when having laptops with a hard switch between video
cards (intel/NVidia switch)
- or when an opencl platform was installed on a machine without any
OpenCL compatible GPU
Diffstat (limited to 'source/blender/compositor/intern/COM_WorkScheduler.cpp')
-rw-r--r-- | source/blender/compositor/intern/COM_WorkScheduler.cpp | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index c5a5a585c19..925ff904cc0 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -236,6 +236,7 @@ void WorkScheduler::initialize() cl_int error; error = clGetPlatformIDs(0, 0, &numberOfPlatforms); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + numberOfPlatforms = 0; if (G.f & G_DEBUG) printf("%d number of platforms\n", numberOfPlatforms); cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms]; error = clGetPlatformIDs(numberOfPlatforms, platforms, 0); @@ -257,36 +258,38 @@ void WorkScheduler::initialize() clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices+numberOfDevicesReceived*sizeof (cl_device_id), 0); numberOfDevicesReceived += numberOfDevices; } - context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - program = clCreateProgramWithSource(context, 1, &sourcecode, 0, &error); - error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0); - if (error != CL_SUCCESS) { - cl_int error2; - size_t ret_val_size; - printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - char *build_log = new char[ret_val_size+1]; - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - build_log[ret_val_size] = '\0'; - printf("%s", build_log); - delete build_log; - - } - unsigned int indexDevices; - for (indexDevices = 0 ; indexDevices < totalNumberOfDevices ; indexDevices ++) { - cl_device_id device = cldevices[indexDevices]; - OpenCLDevice *clDevice = new OpenCLDevice(context, device, program); - clDevice->initialize(), - gpudevices.push_back(clDevice); - if (G.f & G_DEBUG) { - char resultString[32]; - error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0); - printf("OPENCL_DEVICE: %s, ", resultString); - error = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 32, resultString, 0); - printf("%s\n", resultString); + if (totalNumberOfDevices > 0) { + context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + program = clCreateProgramWithSource(context, 1, &sourcecode, 0, &error); + error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0); + if (error != CL_SUCCESS) { + cl_int error2; + size_t ret_val_size; + printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); + error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + char *build_log = new char[ret_val_size+1]; + error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + build_log[ret_val_size] = '\0'; + printf("%s", build_log); + delete build_log; + + } + unsigned int indexDevices; + for (indexDevices = 0 ; indexDevices < totalNumberOfDevices ; indexDevices ++) { + cl_device_id device = cldevices[indexDevices]; + OpenCLDevice *clDevice = new OpenCLDevice(context, device, program); + clDevice->initialize(), + gpudevices.push_back(clDevice); + if (G.f & G_DEBUG) { + char resultString[32]; + error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0); + printf("OPENCL_DEVICE: %s, ", resultString); + error = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 32, resultString, 0); + printf("%s\n", resultString); + } } } delete [] cldevices; |