Merge pull request #22866 from asmorkalov:as/error_formatting

pull/22780/head^2
Alexander Alekhin 2 years ago
commit bc6544c0bc
  1. 40
      modules/core/src/opengl.cpp

@ -1638,14 +1638,14 @@ Context& initializeContextFromGL()
cl_uint numPlatforms;
cl_int status = clGetPlatformIDs(0, NULL, &numPlatforms);
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)
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available platforms");
std::vector<cl_platform_id> platforms(numPlatforms);
status = clGetPlatformIDs(numPlatforms, &platforms[0], NULL);
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));
// TODO Filter platforms by name from OPENCV_OPENCL_DEVICE
@ -1667,7 +1667,7 @@ Context& initializeContextFromGL()
status = clGetPlatformInfo(platforms[i], CL_PLATFORM_EXTENSIONS, extensionSize, (char*)extensionStr.data(), NULL);
}
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLInitError, "OpenCL: Can't get platform extension string: %d ", status);
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't get platform extension string: %d", status));
if (!strstr((const char*)extensionStr.data(), "cl_khr_gl_sharing"))
continue;
@ -1759,31 +1759,31 @@ void convertToGLTexture2D(InputArray src, Texture2D& texture)
cl_int status = 0;
cl_mem clImage = clCreateFromGLTexture(context, CL_MEM_WRITE_ONLY, gl::TEXTURE_2D, 0, texture.texId(), &status);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLTexture failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clCreateFromGLTexture failed: %d", status));
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
status = clEnqueueAcquireGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireGLObjects failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueAcquireGLObjects failed: %d", status));
size_t offset = 0; // TODO
size_t dst_origin[3] = {0, 0, 0};
size_t region[3] = { (size_t)u.cols, (size_t)u.rows, 1};
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, dst_origin, region, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueCopyBufferToImage failed: %d", status));
status = clEnqueueReleaseGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseGLObjects failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueReleaseGLObjects failed: %d", status));
status = clFinish(q); // TODO Use events
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clFinish failed: %d", status));
status = clReleaseMemObject(clImage); // TODO RAII
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMemObject failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clReleaseMemObject failed: %d", status));
#endif
}
@ -1821,31 +1821,31 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst)
cl_int status = 0;
cl_mem clImage = clCreateFromGLTexture(context, CL_MEM_READ_ONLY, gl::TEXTURE_2D, 0, texture.texId(), &status);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLTexture failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clCreateFromGLTexture failed: %d", status));
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
status = clEnqueueAcquireGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireGLObjects failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueAcquireGLObjects failed: %d", status));
size_t offset = 0; // TODO
size_t src_origin[3] = {0, 0, 0};
size_t region[3] = { (size_t)u.cols, (size_t)u.rows, 1};
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueCopyImageToBuffer failed: %d", status));
status = clEnqueueReleaseGLObjects(q, 1, &clImage, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseGLObjects failed: %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueReleaseGLObjects failed: %d", status));
status = clFinish(q); // TODO Use events
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed: : %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clFinish failed: %d", status));
status = clReleaseMemObject(clImage); // TODO RAII
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMemObject failed: : %d ", status);
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clReleaseMemObject failed: %d", status));
#endif
}
@ -1883,13 +1883,13 @@ UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags)
cl_int status = 0;
cl_mem clBuffer = clCreateFromGLBuffer(context, clAccessFlags, buffer.bufId(), &status);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLBuffer failed: %d ", status);
CV_Error(cv::Error::OpenCLApiCallError, ("OpenCL: clCreateFromGLBuffer failed: %d", status));
gl::Finish();
status = clEnqueueAcquireGLObjects(clQueue, 1, &clBuffer, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireGLObjects failed: %d ", status);
CV_Error(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueAcquireGLObjects failed: %d", status));
size_t step = buffer.cols() * buffer.elemSize();
int rows = buffer.rows();
@ -1921,15 +1921,15 @@ void unmapGLBuffer(UMat& u)
cl_int status = clEnqueueReleaseGLObjects(clQueue, 1, &clBuffer, 0, NULL, NULL);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseGLObjects failed: %d ", status);;
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clEnqueueReleaseGLObjects failed: %d", status));
status = clFinish(clQueue);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clFinish failed: %d ", status);;
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clFinish failed: %d", status));
status = clReleaseMemObject(clBuffer);
if (status != CL_SUCCESS)
CV_Error_(cv::Error::OpenCLApiCallError, "OpenCL: clReleaseMemObject failed: %d ", status);;
CV_Error_(cv::Error::OpenCLApiCallError, ("OpenCL: clReleaseMemObject failed: %d", status));
#endif
}

Loading…
Cancel
Save