Commit ad16c243 authored by Jan Solanti's avatar Jan Solanti

core(ocl): Don't query image formats when none exist

clGetSupportedImageFormats returns CL_INVALID_VALUE if called with
num_entries 0 and a non-NULL image_formats pointer so let's not do that.
parent da6ad1c6
......@@ -6445,16 +6445,19 @@ struct Image2D::Impl
CL_MEM_OBJECT_IMAGE2D, numFormats,
NULL, &numFormats);
CV_OCL_DBG_CHECK_RESULT(err, "clGetSupportedImageFormats(CL_MEM_OBJECT_IMAGE2D, NULL)");
AutoBuffer<cl_image_format> formats(numFormats);
err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE,
CL_MEM_OBJECT_IMAGE2D, numFormats,
formats.data(), NULL);
CV_OCL_DBG_CHECK_RESULT(err, "clGetSupportedImageFormats(CL_MEM_OBJECT_IMAGE2D, formats)");
for (cl_uint i = 0; i < numFormats; ++i)
{
if (!memcmp(&formats[i], &format, sizeof(format)))
if (numFormats > 0)
{
AutoBuffer<cl_image_format> formats(numFormats);
err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE,
CL_MEM_OBJECT_IMAGE2D, numFormats,
formats.data(), NULL);
CV_OCL_DBG_CHECK_RESULT(err, "clGetSupportedImageFormats(CL_MEM_OBJECT_IMAGE2D, formats)");
for (cl_uint i = 0; i < numFormats; ++i)
{
return true;
if (!memcmp(&formats[i], &format, sizeof(format)))
{
return true;
}
}
}
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment