Put the cl_image support detection in utils

This commit is contained in:
yao
2013-02-27 10:24:03 +08:00
parent ea433cc496
commit da47ccec9c
3 changed files with 34 additions and 30 deletions

View File

@@ -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