Put the cl_image support detection in utils
This commit is contained in:
parent
ea433cc496
commit
da47ccec9c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user