|
|
|
@ -2998,7 +2998,11 @@ int Kernel::set(int i, const KernelArg& arg) |
|
|
|
|
if( !p || !p->handle ) |
|
|
|
|
return -1; |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
if( i == 0 ) |
|
|
|
|
p->cleanupUMats(); |
|
|
|
|
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) + |
|
|
|
|
((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : 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); |
|
|
|
|
|
|
|
|
|
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 = 0; |
|
|
|
|
return -1; |
|
|
|
|