Added extra checks to ocl::Image2D
This commit is contained in:
@@ -4650,6 +4650,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();
|
||||
@@ -4659,6 +4663,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();
|
||||
|
||||
@@ -4743,7 +4750,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