Commit 86353eb5 authored by Ilya Lavrenov's avatar Ilya Lavrenov

fix for PR 2196

parent afa62c41
...@@ -2704,10 +2704,12 @@ bool Kernel::empty() const ...@@ -2704,10 +2704,12 @@ bool Kernel::empty() const
int Kernel::set(int i, const void* value, size_t sz) int Kernel::set(int i, const void* value, size_t sz)
{ {
if (!p || !p->handle)
return -1;
CV_Assert(i >= 0); CV_Assert(i >= 0);
if( i == 0 ) if( i == 0 )
p->cleanupUMats(); p->cleanupUMats();
if( !p || !p->handle || clSetKernelArg(p->handle, (cl_uint)i, sz, value) < 0 ) if( clSetKernelArg(p->handle, (cl_uint)i, sz, value) < 0 )
return -1; return -1;
return i+1; return i+1;
} }
...@@ -2725,9 +2727,9 @@ int Kernel::set(int i, const UMat& m) ...@@ -2725,9 +2727,9 @@ int Kernel::set(int i, const UMat& m)
int Kernel::set(int i, const KernelArg& arg) int Kernel::set(int i, const KernelArg& arg)
{ {
CV_Assert( i >= 0 );
if( !p || !p->handle ) if( !p || !p->handle )
return -1; return -1;
CV_Assert( i >= 0 );
if( i == 0 ) if( i == 0 )
p->cleanupUMats(); p->cleanupUMats();
if( arg.m ) if( arg.m )
...@@ -2737,6 +2739,13 @@ int Kernel::set(int i, const KernelArg& arg) ...@@ -2737,6 +2739,13 @@ int Kernel::set(int i, const KernelArg& arg)
bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0; bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0;
cl_mem h = (cl_mem)arg.m->handle(accessFlags); cl_mem h = (cl_mem)arg.m->handle(accessFlags);
if (!h)
{
p->release();
p = 0;
return -1;
}
if (ptronly) if (ptronly)
clSetKernelArg(p->handle, (cl_uint)i++, sizeof(h), &h); clSetKernelArg(p->handle, (cl_uint)i++, sizeof(h), &h);
else if( arg.m->dims <= 2 ) else if( arg.m->dims <= 2 )
......
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