From 1d985159ad29c07ade95bbaa6876d7b39e97dc65 Mon Sep 17 00:00:00 2001 From: Matt McClellan Date: Mon, 5 Oct 2020 14:01:33 +0200 Subject: Fix Cycles OpenCL failing when extension string is long This can happen for Intel OpenCL, now support arbitrary string length. Differential Revision: https://developer.blender.org/D9020 --- intern/cycles/device/opencl/opencl_util.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'intern/cycles/device/opencl/opencl_util.cpp') diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp index b8b07cf2947..a72fbbad635 100644 --- a/intern/cycles/device/opencl/opencl_util.cpp +++ b/intern/cycles/device/opencl/opencl_util.cpp @@ -1172,9 +1172,20 @@ bool OpenCLInfo::get_device_extensions(cl_device_id device_id, string *device_extensions, cl_int *error) { - char buffer[1024]; + size_t extension_length = 0; cl_int err; - if ((err = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, sizeof(buffer), &buffer, NULL)) != + /* Determine the size of the extension string*/ + if ((err = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, 0, 0, &extension_length)) != + CL_SUCCESS) { + if (error != NULL) { + *error = err; + } + *device_extensions = ""; + return false; + } + vector buffer(extension_length); + if ((err = clGetDeviceInfo( + device_id, CL_DEVICE_EXTENSIONS, extension_length, buffer.data(), NULL)) != CL_SUCCESS) { if (error != NULL) { *error = err; @@ -1185,7 +1196,7 @@ bool OpenCLInfo::get_device_extensions(cl_device_id device_id, if (error != NULL) { *error = CL_SUCCESS; } - *device_extensions = buffer; + *device_extensions = string(buffer.data()); return true; } -- cgit v1.2.3