mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
Merge pull request #13722 from alalek:ocl_pass_ptr_for_empty_umat
This commit is contained in:
commit
4e66d078d2
@ -2998,7 +2998,11 @@ int Kernel::set(int i, const KernelArg& arg)
|
|||||||
if( !p || !p->handle )
|
if( !p || !p->handle )
|
||||||
return -1;
|
return -1;
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
{
|
||||||
|
CV_LOG_ERROR(NULL, cv::format("OpenCL: Kernel(%s)::set(arg_index=%d): negative arg_index",
|
||||||
|
p->name.c_str(), (int)i));
|
||||||
return i;
|
return i;
|
||||||
|
}
|
||||||
if( i == 0 )
|
if( i == 0 )
|
||||||
p->cleanupUMats();
|
p->cleanupUMats();
|
||||||
cl_int status = 0;
|
cl_int status = 0;
|
||||||
@ -3007,10 +3011,19 @@ int Kernel::set(int i, const KernelArg& arg)
|
|||||||
int accessFlags = ((arg.flags & KernelArg::READ_ONLY) ? ACCESS_READ : 0) +
|
int accessFlags = ((arg.flags & KernelArg::READ_ONLY) ? ACCESS_READ : 0) +
|
||||||
((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : 0);
|
((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : 0);
|
||||||
bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0;
|
bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0;
|
||||||
|
if (ptronly && arg.m->empty())
|
||||||
|
{
|
||||||
|
cl_mem h_null = (cl_mem)NULL;
|
||||||
|
status = clSetKernelArg(p->handle, (cl_uint)i, sizeof(h_null), &h_null);
|
||||||
|
CV_OCL_DBG_CHECK_RESULT(status, cv::format("clSetKernelArg('%s', arg_index=%d, cl_mem=NULL)", p->name.c_str(), (int)i).c_str());
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
cl_mem h = (cl_mem)arg.m->handle(accessFlags);
|
cl_mem h = (cl_mem)arg.m->handle(accessFlags);
|
||||||
|
|
||||||
if (!h)
|
if (!h)
|
||||||
{
|
{
|
||||||
|
CV_LOG_ERROR(NULL, cv::format("OpenCL: Kernel(%s)::set(arg_index=%d, flags=%d): can't create cl_mem handle for passed UMat buffer (addr=%p)",
|
||||||
|
p->name.c_str(), (int)i, (int)arg.flags, arg.m));
|
||||||
p->release();
|
p->release();
|
||||||
p = 0;
|
p = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user