Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-09-12 15:25:47 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-09-12 15:25:47 +0400
commit3d38ad1b17028320efbd112cdcd75f77279ef035 (patch)
tree5b31b843f2f22247c88a59d1f3da5e3a2972489a /intern/cycles/device/device_opencl.cpp
parentdb1191d4519251ed93b570f0e09b375c249a4ef2 (diff)
Attempted fix for #32415: tighten up cycles opencl initialization checks to try to
avoid crashes. Don't think these should be needed but maybe it helps.
Diffstat (limited to 'intern/cycles/device/device_opencl.cpp')
-rw-r--r--intern/cycles/device/device_opencl.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index e1cfb9e7ade..ed7229d49da 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -739,29 +739,31 @@ Device *device_opencl_create(DeviceInfo& info, bool background)
void device_opencl_info(vector<DeviceInfo>& devices)
{
vector<cl_device_id> device_ids;
- cl_uint num_devices;
- cl_platform_id platform_id;
- cl_uint num_platforms;
+ cl_uint num_devices = 0;
+ vector<cl_platform_id> platform_ids;
+ cl_uint num_platforms = 0;
/* get devices */
if(clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS || num_platforms == 0)
return;
+
+ platform_ids.resize(num_platforms);
- if(clGetPlatformIDs(1, &platform_id, NULL) != CL_SUCCESS)
+ if(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL) != CL_SUCCESS)
return;
- if(clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, 0, NULL, &num_devices) != CL_SUCCESS)
+ if(clGetDeviceIDs(platform_ids[0], CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, 0, NULL, &num_devices) != CL_SUCCESS || num_devices == 0)
return;
device_ids.resize(num_devices);
- if(clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, num_devices, &device_ids[0], NULL) != CL_SUCCESS)
+ if(clGetDeviceIDs(platform_ids[0], CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, num_devices, &device_ids[0], NULL) != CL_SUCCESS)
return;
/* add devices */
for(int num = 0; num < num_devices; num++) {
cl_device_id device_id = device_ids[num];
- char name[1024];
+ char name[1024] = "\0";
if(clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(name), &name, NULL) != CL_SUCCESS)
continue;