From 58934f1e166d9531de425f07582ab52c9e67b14e Mon Sep 17 00:00:00 2001 From: Vladimir Dudnik Date: Wed, 12 Aug 2015 17:03:13 +0300 Subject: [PATCH] add condition to skip unmapping for internally allocated host memory. this should fix map_unmap_counting UMat test. --- modules/core/src/ocl.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index c51f90ad69..f3bdf16820 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -4572,13 +4572,16 @@ public: else { // CL_MEM_USE_HOST_PTR (nothing is required) and OTHER cases - 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->flags & UMatData::USER_ALLOCATED) + { + 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); + } } } u->markHostCopyObsolete(false);