Merge pull request #3367 from akarsakov:ocl_image2d
This commit is contained in:
@@ -4629,6 +4629,9 @@ struct Image2D::Impl
|
||||
|
||||
static bool isFormatSupported(cl_image_format format)
|
||||
{
|
||||
if (!haveOpenCL())
|
||||
CV_Error(Error::OpenCLApiCallError, "OpenCL runtime not found!");
|
||||
|
||||
cl_context context = (cl_context)Context::getDefault().ptr();
|
||||
// Figure out how many formats are supported by this context.
|
||||
cl_uint numFormats = 0;
|
||||
@@ -4652,6 +4655,10 @@ struct Image2D::Impl
|
||||
|
||||
void init(const UMat &src, bool norm, bool alias)
|
||||
{
|
||||
if (!haveOpenCL())
|
||||
CV_Error(Error::OpenCLApiCallError, "OpenCL runtime not found!");
|
||||
|
||||
CV_Assert(!src.empty());
|
||||
CV_Assert(ocl::Device::getDefault().imageSupport());
|
||||
|
||||
int err, depth = src.depth(), cn = src.channels();
|
||||
@@ -4661,6 +4668,9 @@ struct Image2D::Impl
|
||||
if (!isFormatSupported(format))
|
||||
CV_Error(Error::OpenCLApiCallError, "Image format is not supported");
|
||||
|
||||
if (alias && !src.handle(ACCESS_RW))
|
||||
CV_Error(Error::OpenCLApiCallError, "Incorrect UMat, handle is null");
|
||||
|
||||
cl_context context = (cl_context)Context::getDefault().ptr();
|
||||
cl_command_queue queue = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
@@ -4745,7 +4755,7 @@ bool Image2D::canCreateAlias(const UMat &m)
|
||||
{
|
||||
bool ret = false;
|
||||
const Device & d = ocl::Device::getDefault();
|
||||
if (d.imageFromBufferSupport())
|
||||
if (d.imageFromBufferSupport() && !m.empty())
|
||||
{
|
||||
// This is the required pitch alignment in pixels
|
||||
uint pitchAlign = d.imagePitchAlignment();
|
||||
|
Reference in New Issue
Block a user