[Bf-blender-cvs] [1d985159ad2] master: Fix Cycles OpenCL failing when extension string is long

Matt McClellan noreply at git.blender.org
Mon Oct 5 14:07:12 CEST 2020


Commit: 1d985159ad29c07ade95bbaa6876d7b39e97dc65
Author: Matt McClellan
Date:   Mon Oct 5 14:01:33 2020 +0200
Branches: master
https://developer.blender.org/rB1d985159ad29c07ade95bbaa6876d7b39e97dc65

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

===================================================================

M	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<char> 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;
 }



More information about the Bf-blender-cvs mailing list