@@ -151,6 +151,8 @@ struct DummyImpl
151
151
#define CV_OCL_DBG_CHECK_ (expr, check_result ) expr; (void )check_result
152
152
#define CV_OCL_DBG_CHECK (expr ) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT (__cl_result, #expr); } while (0 )
153
153
154
+ static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = false ;
155
+
154
156
#else // HAVE_OPENCL
155
157
156
158
#ifndef _DEBUG
@@ -225,6 +227,15 @@ static const bool CV_OPENCL_CACHE_CLEANUP = utils::getConfigurationParameterBool
225
227
static const bool CV_OPENCL_VALIDATE_BINARY_PROGRAMS_VALUE = utils::getConfigurationParameterBool(" OPENCV_OPENCL_VALIDATE_BINARY_PROGRAMS" , false );
226
228
#endif
227
229
230
+ // Option to disable calls clEnqueueReadBufferRect / clEnqueueWriteBufferRect / clEnqueueCopyBufferRect
231
+ static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = utils::getConfigurationParameterBool(" OPENCV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS" ,
232
+ #ifdef __APPLE__
233
+ true
234
+ #else
235
+ false
236
+ #endif
237
+ );
238
+
228
239
#endif // HAVE_OPENCL
229
240
230
241
struct UMat2D
@@ -5206,8 +5217,7 @@ class OpenCLAllocator : public MatAllocator
5206
5217
CV_OCL_CHECK (clEnqueueReadBuffer (q, (cl_mem)u->handle , CL_TRUE,
5207
5218
srcrawofs, total, alignedPtr.getAlignedPtr (), 0 , 0 , 0 ));
5208
5219
}
5209
- #ifdef __APPLE__
5210
- else
5220
+ else if (CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS)
5211
5221
{
5212
5222
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
5213
5223
size_t new_srcrawofs = srcrawofs & ~(padding-1 );
@@ -5224,7 +5234,6 @@ class OpenCLAllocator : public MatAllocator
5224
5234
for ( size_t i = 0 ; i < new_sz[1 ]; i++ )
5225
5235
memcpy ( (uchar*)dstptr + i*new_dststep[0 ], ptr + i*new_srcstep[0 ] + membuf_ofs, new_sz[0 ]);
5226
5236
}
5227
- #else
5228
5237
else
5229
5238
{
5230
5239
AlignedDataPtr2D<false , true > alignedPtr ((uchar*)dstptr, new_sz[1 ], new_sz[0 ], new_dststep[0 ], CV_OPENCL_DATA_PTR_ALIGNMENT);
@@ -5236,7 +5245,6 @@ class OpenCLAllocator : public MatAllocator
5236
5245
new_dststep[0 ], 0 ,
5237
5246
ptr, 0 , 0 , 0 ));
5238
5247
}
5239
- #endif
5240
5248
}
5241
5249
}
5242
5250
@@ -5343,8 +5351,7 @@ class OpenCLAllocator : public MatAllocator
5343
5351
CV_OCL_CHECK (clEnqueueWriteBuffer (q, (cl_mem)u->handle , CL_TRUE,
5344
5352
dstrawofs, total, alignedPtr.getAlignedPtr (), 0 , 0 , 0 ));
5345
5353
}
5346
- #ifdef __APPLE__
5347
- else
5354
+ else if (CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS)
5348
5355
{
5349
5356
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
5350
5357
size_t new_dstrawofs = dstrawofs & ~(padding-1 );
@@ -5366,7 +5373,6 @@ class OpenCLAllocator : public MatAllocator
5366
5373
CV_OCL_CHECK (clEnqueueWriteBuffer (q, (cl_mem)u->handle , CL_TRUE,
5367
5374
new_dstrawofs, total, ptr, 0 , 0 , 0 ));
5368
5375
}
5369
- #else
5370
5376
else
5371
5377
{
5372
5378
AlignedDataPtr2D<true , false > alignedPtr ((uchar*)srcptr, new_sz[1 ], new_sz[0 ], new_srcstep[0 ], CV_OPENCL_DATA_PTR_ALIGNMENT);
@@ -5378,7 +5384,6 @@ class OpenCLAllocator : public MatAllocator
5378
5384
new_srcstep[0 ], 0 ,
5379
5385
ptr, 0 , 0 , 0 ));
5380
5386
}
5381
- #endif
5382
5387
}
5383
5388
u->markHostCopyObsolete (true );
5384
5389
#ifdef HAVE_OPENCL_SVM
@@ -5520,8 +5525,7 @@ class OpenCLAllocator : public MatAllocator
5520
5525
CV_OCL_CHECK (retval = clEnqueueCopyBuffer (q, (cl_mem)src->handle , (cl_mem)dst->handle ,
5521
5526
srcrawofs, dstrawofs, total, 0 , 0 , 0 ));
5522
5527
}
5523
- #ifdef __APPLE__
5524
- else
5528
+ else if (CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS)
5525
5529
{
5526
5530
const size_t padding = CV_OPENCL_DATA_PTR_ALIGNMENT;
5527
5531
size_t new_srcrawofs = srcrawofs & ~(padding-1 );
@@ -5554,7 +5558,6 @@ class OpenCLAllocator : public MatAllocator
5554
5558
CV_OCL_CHECK (clEnqueueWriteBuffer (q, (cl_mem)dst->handle , CL_TRUE,
5555
5559
new_dstrawofs, dst_total, dstptr, 0 , 0 , 0 ));
5556
5560
}
5557
- #else
5558
5561
else
5559
5562
{
5560
5563
CV_OCL_CHECK (retval = clEnqueueCopyBufferRect (q, (cl_mem)src->handle , (cl_mem)dst->handle ,
@@ -5563,7 +5566,6 @@ class OpenCLAllocator : public MatAllocator
5563
5566
new_dststep[0 ], 0 ,
5564
5567
0 , 0 , 0 ));
5565
5568
}
5566
- #endif
5567
5569
}
5568
5570
if (retval == CL_SUCCESS)
5569
5571
{
0 commit comments