diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2017-07-06 02:44:18 +0300 |
---|---|---|
committer | Mai Lavelle <mai.lavelle@gmail.com> | 2017-07-06 03:19:12 +0300 |
commit | 222b96e5c7def0d9f29c96ddf30413c5d4fb3223 (patch) | |
tree | e050723e21dda3b63eb57427fae4ddc8f3b6a7b4 /intern | |
parent | cff172c7621d89773baa99a9460f19056efb5f1e (diff) |
Cycles: Detect out of memory before buffer allocation in OpenCL devices
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/device/opencl/opencl_base.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 223a5901197..cf2ef45205e 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -276,6 +276,20 @@ void OpenCLDeviceBase::mem_alloc(const char *name, device_memory& mem, MemoryTyp size_t size = mem.memory_size(); + /* check there is enough memory available for the allocation */ + cl_ulong max_alloc_size = 0; + clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_alloc_size, NULL); + + if(size > max_alloc_size) { + string error = "Scene too complex to fit in available memory."; + if(name != NULL) { + error += string_printf(" (allocating buffer %s failed.)", name); + } + set_error(error); + + return; + } + cl_mem_flags mem_flag; void *mem_ptr = NULL; |