mirror of
https://github.com/opencv/opencv.git
synced 2026-09-19 15:23:23 -05:00
ocl: workaround option to disable usage of buffer "Rect" operations
This commit is contained in:
@@ -151,6 +151,8 @@ struct DummyImpl
|
|||||||
#define CV_OCL_DBG_CHECK_(expr, check_result) expr; (void)check_result
|
#define CV_OCL_DBG_CHECK_(expr, check_result) expr; (void)check_result
|
||||||
#define CV_OCL_DBG_CHECK(expr) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT(__cl_result, #expr); } while (0)
|
#define CV_OCL_DBG_CHECK(expr) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT(__cl_result, #expr); } while (0)
|
||||||
|
|
||||||
|
static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = false;
|
||||||
|
|
||||||
#else // HAVE_OPENCL
|
#else // HAVE_OPENCL
|
||||||
|
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
@@ -225,6 +227,15 @@ static const bool CV_OPENCL_CACHE_CLEANUP = utils::getConfigurationParameterBool
|
|||||||
static const bool CV_OPENCL_VALIDATE_BINARY_PROGRAMS_VALUE = utils::getConfigurationParameterBool("OPENCV_OPENCL_VALIDATE_BINARY_PROGRAMS", false);
|
static const bool CV_OPENCL_VALIDATE_BINARY_PROGRAMS_VALUE = utils::getConfigurationParameterBool("OPENCV_OPENCL_VALIDATE_BINARY_PROGRAMS", false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Option to disable calls clEnqueueReadBufferRect / clEnqueueWriteBufferRect / clEnqueueCopyBufferRect
|
||||||
|
static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = utils::getConfigurationParameterBool("OPENCV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS",
|
||||||
|
#ifdef __APPLE__
|
||||||
|
true
|
||||||
|
#else
|
||||||
|
false
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
#endif // HAVE_OPENCL
|
#endif // HAVE_OPENCL
|
||||||
|
|
||||||
struct UMat2D
|
struct UMat2D
|
||||||
@@ -5206,8 +5217,7 @@ public:
|
|||||||
CV_OCL_CHECK(clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
CV_OCL_CHECK(clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||||
srcrawofs, total, alignedPtr.getAlignedPtr(), 0, 0, 0));
|
srcrawofs, total, alignedPtr.getAlignedPtr(), 0, 0, 0));
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
else if (CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
|
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
|
||||||
size_t new_srcrawofs = srcrawofs & ~(padding-1);
|
size_t new_srcrawofs = srcrawofs & ~(padding-1);
|
||||||
@@ -5224,7 +5234,6 @@ public:
|
|||||||
for( size_t i = 0; i < new_sz[1]; i++ )
|
for( size_t i = 0; i < new_sz[1]; i++ )
|
||||||
memcpy( (uchar*)dstptr + i*new_dststep[0], ptr + i*new_srcstep[0] + membuf_ofs, new_sz[0]);
|
memcpy( (uchar*)dstptr + i*new_dststep[0], ptr + i*new_srcstep[0] + membuf_ofs, new_sz[0]);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AlignedDataPtr2D<false, true> alignedPtr((uchar*)dstptr, new_sz[1], new_sz[0], new_dststep[0], CV_OPENCL_DATA_PTR_ALIGNMENT);
|
AlignedDataPtr2D<false, true> alignedPtr((uchar*)dstptr, new_sz[1], new_sz[0], new_dststep[0], CV_OPENCL_DATA_PTR_ALIGNMENT);
|
||||||
@@ -5236,7 +5245,6 @@ public:
|
|||||||
new_dststep[0], 0,
|
new_dststep[0], 0,
|
||||||
ptr, 0, 0, 0));
|
ptr, 0, 0, 0));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5343,8 +5351,7 @@ public:
|
|||||||
CV_OCL_CHECK(clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
CV_OCL_CHECK(clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||||
dstrawofs, total, alignedPtr.getAlignedPtr(), 0, 0, 0));
|
dstrawofs, total, alignedPtr.getAlignedPtr(), 0, 0, 0));
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
else if (CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
|
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
|
||||||
size_t new_dstrawofs = dstrawofs & ~(padding-1);
|
size_t new_dstrawofs = dstrawofs & ~(padding-1);
|
||||||
@@ -5366,7 +5373,6 @@ public:
|
|||||||
CV_OCL_CHECK(clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
CV_OCL_CHECK(clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE,
|
||||||
new_dstrawofs, total, ptr, 0, 0, 0));
|
new_dstrawofs, total, ptr, 0, 0, 0));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AlignedDataPtr2D<true, false> alignedPtr((uchar*)srcptr, new_sz[1], new_sz[0], new_srcstep[0], CV_OPENCL_DATA_PTR_ALIGNMENT);
|
AlignedDataPtr2D<true, false> alignedPtr((uchar*)srcptr, new_sz[1], new_sz[0], new_srcstep[0], CV_OPENCL_DATA_PTR_ALIGNMENT);
|
||||||
@@ -5378,7 +5384,6 @@ public:
|
|||||||
new_srcstep[0], 0,
|
new_srcstep[0], 0,
|
||||||
ptr, 0, 0, 0));
|
ptr, 0, 0, 0));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
u->markHostCopyObsolete(true);
|
u->markHostCopyObsolete(true);
|
||||||
#ifdef HAVE_OPENCL_SVM
|
#ifdef HAVE_OPENCL_SVM
|
||||||
@@ -5520,8 +5525,7 @@ public:
|
|||||||
CV_OCL_CHECK(retval = clEnqueueCopyBuffer(q, (cl_mem)src->handle, (cl_mem)dst->handle,
|
CV_OCL_CHECK(retval = clEnqueueCopyBuffer(q, (cl_mem)src->handle, (cl_mem)dst->handle,
|
||||||
srcrawofs, dstrawofs, total, 0, 0, 0));
|
srcrawofs, dstrawofs, total, 0, 0, 0));
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
else if (CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
|
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
|
||||||
size_t new_srcrawofs = srcrawofs & ~(padding-1);
|
size_t new_srcrawofs = srcrawofs & ~(padding-1);
|
||||||
@@ -5554,7 +5558,6 @@ public:
|
|||||||
CV_OCL_CHECK(clEnqueueWriteBuffer(q, (cl_mem)dst->handle, CL_TRUE,
|
CV_OCL_CHECK(clEnqueueWriteBuffer(q, (cl_mem)dst->handle, CL_TRUE,
|
||||||
new_dstrawofs, dst_total, dstptr, 0, 0, 0));
|
new_dstrawofs, dst_total, dstptr, 0, 0, 0));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_OCL_CHECK(retval = clEnqueueCopyBufferRect(q, (cl_mem)src->handle, (cl_mem)dst->handle,
|
CV_OCL_CHECK(retval = clEnqueueCopyBufferRect(q, (cl_mem)src->handle, (cl_mem)dst->handle,
|
||||||
@@ -5563,7 +5566,6 @@ public:
|
|||||||
new_dststep[0], 0,
|
new_dststep[0], 0,
|
||||||
0, 0, 0));
|
0, 0, 0));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (retval == CL_SUCCESS)
|
if (retval == CL_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user