diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 6d66e702ff..0bf4e07856 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -2777,6 +2777,7 @@ struct Kernel::Impl for( int i = 0; i < MAX_ARRS; i++ ) u[i] = 0; haveTempDstUMats = false; + haveTempSrcUMats = false; } void cleanupUMats() @@ -2793,6 +2794,7 @@ struct Kernel::Impl } nu = 0; haveTempDstUMats = false; + haveTempSrcUMats = false; } void addUMat(const UMat& m, bool dst) @@ -2803,6 +2805,8 @@ struct Kernel::Impl nu++; if(dst && m.u->tempUMat()) haveTempDstUMats = true; + if(m.u->originalUMatData == NULL && m.u->tempUMat()) + haveTempSrcUMats = true; // UMat is created on RAW memory (without proper lifetime management, even from Mat) } void addImage(const Image2D& image) @@ -2840,6 +2844,7 @@ struct Kernel::Impl int nu; std::list images; bool haveTempDstUMats; + bool haveTempSrcUMats; }; }} // namespace cv::ocl @@ -3113,6 +3118,8 @@ bool Kernel::Impl::run(int dims, size_t globalsize[], size_t localsize[], cl_command_queue qq = getQueue(q); if (haveTempDstUMats) sync = true; + if (haveTempSrcUMats) + sync = true; if (timeNS) sync = true; cl_event asyncEvent = 0;