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:
authorMai Lavelle <mai.lavelle@gmail.com>2017-07-06 02:44:18 +0300
committerMai Lavelle <mai.lavelle@gmail.com>2017-07-06 03:19:12 +0300
commit222b96e5c7def0d9f29c96ddf30413c5d4fb3223 (patch)
treee050723e21dda3b63eb57427fae4ddc8f3b6a7b4
parentcff172c7621d89773baa99a9460f19056efb5f1e (diff)
Cycles: Detect out of memory before buffer allocation in OpenCL devices
-rw-r--r--intern/cycles/device/opencl/opencl_base.cpp14
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;