pull/26281/head
kallaballa 2 months ago
parent 63b5dee274
commit 50f6d54f87
  1. 12
      modules/core/src/opengl.cpp

@ -1641,20 +1641,20 @@ Context& initializeContextFromGL()
#elif !defined(HAVE_OPENCL_OPENGL_SHARING) #elif !defined(HAVE_OPENCL_OPENGL_SHARING)
NO_OPENCL_SHARING_ERROR; NO_OPENCL_SHARING_ERROR;
#else #else
cl_uint numPlatforms; cl_uint platformsCnt;
cl_uint devCnt; cl_uint devCnt;
cl_device_id* devices; cl_device_id* devices;
cl_uint devUsed; cl_uint devUsed;
cl_context context; cl_context context;
cl_int status = clGetPlatformIDs(0, NULL, &numPlatforms); cl_int status = clGetPlatformIDs(0, NULL, &platformsCnt);
if (status != CL_SUCCESS) if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get number of platforms: %d", status)); CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get number of platforms: %d", status));
if (numPlatforms == 0) if (platformsCnt == 0)
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available platforms"); CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available platforms");
std::vector<cl_platform_id> platforms(numPlatforms); std::vector<cl_platform_id> platforms(platformsCnt);
status = clGetPlatformIDs(numPlatforms, &platforms[0], NULL); status = clGetPlatformIDs(platformsCnt, &platforms[0], NULL);
if (status != CL_SUCCESS) if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get platforms: %d", status)); CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get platforms: %d", status));
@ -1662,7 +1662,7 @@ Context& initializeContextFromGL()
// TODO Filter platforms by name from OPENCV_OPENCL_DEVICE // TODO Filter platforms by name from OPENCV_OPENCL_DEVICE
bool sharingSupported = false; bool sharingSupported = false;
for (unsigned int i = 0; (!sharingSupported && (i < numPlatforms)); ++i) { for (unsigned int i = 0; (!sharingSupported && (i < platformsCnt)); ++i) {
status = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, 0, NULL, &devCnt); status = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, 0, NULL, &devCnt);
if (status != CL_SUCCESS) if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: No devices available: %d", status)); CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: No devices available: %d", status));

Loading…
Cancel
Save