|
|
|
@ -4514,6 +4514,7 @@ public: |
|
|
|
|
CV_Assert(u->refcount >= 0); |
|
|
|
|
|
|
|
|
|
CV_Assert(u->handle != 0 && u->urefcount == 0); |
|
|
|
|
CV_Assert(u->mapcount == 0); |
|
|
|
|
if(u->tempUMat()) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(u->origdata); |
|
|
|
@ -4572,12 +4573,16 @@ public: |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
cl_int retval = 0; |
|
|
|
|
void* data = clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE, |
|
|
|
|
(CL_MAP_READ | CL_MAP_WRITE), |
|
|
|
|
0, u->size, 0, 0, 0, &retval); |
|
|
|
|
CV_OclDbgAssert(retval == CL_SUCCESS); |
|
|
|
|
CV_OclDbgAssert(clEnqueueUnmapMemObject(q, (cl_mem)u->handle, data, 0, 0, 0) == CL_SUCCESS); |
|
|
|
|
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS); |
|
|
|
|
if (u->tempUMat()) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(u->mapcount == 0); |
|
|
|
|
void* data = clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE, |
|
|
|
|
(CL_MAP_READ | CL_MAP_WRITE), |
|
|
|
|
0, u->size, 0, 0, 0, &retval); |
|
|
|
|
CV_OclDbgAssert(retval == CL_SUCCESS); |
|
|
|
|
CV_OclDbgAssert(clEnqueueUnmapMemObject(q, (cl_mem)u->handle, data, 0, 0, 0) == CL_SUCCESS); |
|
|
|
|
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
u->markHostCopyObsolete(false); |
|
|
|
@ -4715,11 +4720,16 @@ public: |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
cl_int retval = 0; |
|
|
|
|
u->data = (uchar*)clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE, |
|
|
|
|
(CL_MAP_READ | CL_MAP_WRITE), |
|
|
|
|
0, u->size, 0, 0, 0, &retval); |
|
|
|
|
if(u->data && retval == CL_SUCCESS) |
|
|
|
|
cl_int retval = CL_SUCCESS; |
|
|
|
|
if (!u->deviceMemMapped()) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(u->refcount == 1); |
|
|
|
|
CV_Assert(u->mapcount++ == 0); |
|
|
|
|
u->data = (uchar*)clEnqueueMapBuffer(q, (cl_mem)u->handle, CL_TRUE, |
|
|
|
|
(CL_MAP_READ | CL_MAP_WRITE), |
|
|
|
|
0, u->size, 0, 0, 0, &retval); |
|
|
|
|
} |
|
|
|
|
if (u->data && retval == CL_SUCCESS) |
|
|
|
|
{ |
|
|
|
|
u->markHostCopyObsolete(false); |
|
|
|
|
u->markDeviceMemMapped(true); |
|
|
|
@ -4765,7 +4775,6 @@ public: |
|
|
|
|
if( !u->copyOnMap() && u->deviceMemMapped() ) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(u->data != NULL); |
|
|
|
|
u->markDeviceMemMapped(false); |
|
|
|
|
#ifdef HAVE_OPENCL_SVM |
|
|
|
|
if ((u->allocatorFlags_ & svm::OPENCL_SVM_BUFFER_MASK) != 0) |
|
|
|
|
{ |
|
|
|
@ -4792,16 +4801,21 @@ public: |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
CV_Assert( (retval = clEnqueueUnmapMemObject(q, |
|
|
|
|
(cl_mem)u->handle, u->data, 0, 0, 0)) == CL_SUCCESS ); |
|
|
|
|
if (Device::getDefault().isAMD()) |
|
|
|
|
{ |
|
|
|
|
// required for multithreaded applications (see stitching test)
|
|
|
|
|
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (u->refcount == 0) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(u->mapcount-- == 1); |
|
|
|
|
CV_Assert((retval = clEnqueueUnmapMemObject(q, |
|
|
|
|
(cl_mem)u->handle, u->data, 0, 0, 0)) == CL_SUCCESS); |
|
|
|
|
if (Device::getDefault().isAMD()) |
|
|
|
|
{ |
|
|
|
|
// required for multithreaded applications (see stitching test)
|
|
|
|
|
CV_OclDbgAssert(clFinish(q) == CL_SUCCESS); |
|
|
|
|
} |
|
|
|
|
u->markDeviceMemMapped(false); |
|
|
|
|
u->data = 0; |
|
|
|
|
u->markDeviceCopyObsolete(false); |
|
|
|
|
u->markHostCopyObsolete(true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if( u->copyOnMap() && u->deviceCopyObsolete() ) |
|
|
|
|
{ |
|
|
|
@ -4811,9 +4825,9 @@ public: |
|
|
|
|
#endif |
|
|
|
|
CV_Assert( (retval = clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, |
|
|
|
|
u->size, alignedPtr.getAlignedPtr(), 0, 0, 0)) == CL_SUCCESS ); |
|
|
|
|
u->markDeviceCopyObsolete(false); |
|
|
|
|
u->markHostCopyObsolete(true); |
|
|
|
|
} |
|
|
|
|
u->markDeviceCopyObsolete(false); |
|
|
|
|
u->markHostCopyObsolete(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool checkContinuous(int dims, const size_t sz[], |
|
|
|
|