Avoid unmap an umat(ocl) which hasn't been mapped at all.
authorZhigang Gong <zhigang.gong@intel.com>
Wed, 9 Jul 2014 08:04:22 +0000 (16:04 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Wed, 9 Jul 2014 08:21:20 +0000 (16:21 +0800)
commit2e49ca4903175f507e828047a58acabc1010e827
tree0e1e1772c09131efc4e4b9cf28b88acee901b00e
parent0f1a0a981871ea9b61560a1f1918866beb585550
Avoid unmap an umat(ocl) which hasn't been mapped at all.

According to opencl 1.2 spec 5.4.2:
  enqueues a command to unmap a previously mapped region of a memory object.
  ...
  CL_INVALID_VALUE if mapped_ptr is not a valid pointer returned by
  clEnqueueMapBuffer, or clEnqueueMapImage for memobj.

So if the u->data is not from a clEnqueueMapBuffer call, we should not
call clEnqueueUnmapMemObject() unmap it. With this patch, the cases
./opencv_test_video --gtest_filter=OCL_Video/FarnebackOpticalFlow.Mat/*
could work well with beignet 0.9.1, Otherwise, it will get a
CL_INVALID_VALUE at the clEnqueueUnmapMemObject().

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
modules/core/include/opencv2/core/mat.hpp
modules/core/include/opencv2/core/mat.inl.hpp
modules/core/src/ocl.cpp