ocl: fix kernels launching with USE_HOST_PTR UMat

created from RAW memory buffers (without proper lifetime management)
pull/13269/head
Alexander Alekhin 6 years ago
parent dc80f9d0fb
commit 9fd822f97e
  1. 7
      modules/core/src/ocl.cpp

@ -2777,6 +2777,7 @@ struct Kernel::Impl
for( int i = 0; i < MAX_ARRS; i++ ) for( int i = 0; i < MAX_ARRS; i++ )
u[i] = 0; u[i] = 0;
haveTempDstUMats = false; haveTempDstUMats = false;
haveTempSrcUMats = false;
} }
void cleanupUMats() void cleanupUMats()
@ -2793,6 +2794,7 @@ struct Kernel::Impl
} }
nu = 0; nu = 0;
haveTempDstUMats = false; haveTempDstUMats = false;
haveTempSrcUMats = false;
} }
void addUMat(const UMat& m, bool dst) void addUMat(const UMat& m, bool dst)
@ -2803,6 +2805,8 @@ struct Kernel::Impl
nu++; nu++;
if(dst && m.u->tempUMat()) if(dst && m.u->tempUMat())
haveTempDstUMats = true; 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) void addImage(const Image2D& image)
@ -2840,6 +2844,7 @@ struct Kernel::Impl
int nu; int nu;
std::list<Image2D> images; std::list<Image2D> images;
bool haveTempDstUMats; bool haveTempDstUMats;
bool haveTempSrcUMats;
}; };
}} // namespace cv::ocl }} // 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); cl_command_queue qq = getQueue(q);
if (haveTempDstUMats) if (haveTempDstUMats)
sync = true; sync = true;
if (haveTempSrcUMats)
sync = true;
if (timeNS) if (timeNS)
sync = true; sync = true;
cl_event asyncEvent = 0; cl_event asyncEvent = 0;

Loading…
Cancel
Save