diff --git a/modules/ocl/src/mcwutil.cpp b/modules/ocl/src/mcwutil.cpp index dfbf7b1bb..2c132396d 100644 --- a/modules/ocl/src/mcwutil.cpp +++ b/modules/ocl/src/mcwutil.cpp @@ -221,6 +221,36 @@ namespace cv { openCLFree(texture); } + + bool support_image2d(Context *clCxt) + { + static const char * _kernel_string = "__kernel void test_func(image2d_t img) {}"; + static bool _isTested = false; + static bool _support = false; + if(_isTested) + { + return _support; + } + try + { + cv::ocl::openCLGetKernelFromSource(clCxt, &_kernel_string, "test_func"); + _support = true; + } + catch (const cv::Exception& e) + { + if(e.code == -217) + { + _support = false; + } + else + { + // throw e once again + throw e; + } + } + _isTested = true; + return _support; + } }//namespace ocl }//namespace cv diff --git a/modules/ocl/src/mcwutil.hpp b/modules/ocl/src/mcwutil.hpp index d1986b93b..7f2745111 100644 --- a/modules/ocl/src/mcwutil.hpp +++ b/modules/ocl/src/mcwutil.hpp @@ -70,6 +70,10 @@ namespace cv // 2. for faster clamping, there is no buffer padding for the constructed texture cl_mem bindTexture(const oclMat &mat); void releaseTexture(cl_mem& texture); + + // returns whether the current context supports image2d_t format or not + bool support_image2d(Context *clCxt = Context::getContext()); + }//namespace ocl }//namespace cv diff --git a/modules/ocl/src/surf.cpp b/modules/ocl/src/surf.cpp index 736787c15..2e06f4439 100644 --- a/modules/ocl/src/surf.cpp +++ b/modules/ocl/src/surf.cpp @@ -83,36 +83,6 @@ static inline int calcSize(int octave, int layer) namespace { const char* noImage2dOption = "-D DISABLE_IMAGE2D"; - - // default kernel name can be any kernel in nonfree_surf.cl - bool support_image2d(const char* kernel_name = "icvCalcLayerDetAndTrace") - { - static bool _isTested = false; - static bool _support = false; - if(_isTested) - { - return _support; - } - try - { - cv::ocl::openCLGetKernelFromSource(Context::getContext(), &nonfree_surf, kernel_name); - _support = true; - } - catch (cv::Exception& e) - { - if(e.code == -217) - { - _support = false; - } - else - { - // throw e once again - cv::error(e); - } - } - _isTested = true; - return _support; - } } class SURF_OCL_Invoker