Add OpenCL version 1.2 query into ocl::Context::supportsFeature().
Add backwards portability for OpenCL 1.1 when OpenCV executables are compiled with OpenCL 1.2 profile support.
This commit is contained in:
parent
48a8aefd6b
commit
355bc691fc
@ -155,7 +155,7 @@ namespace cv
|
|||||||
static Context* getContext();
|
static Context* getContext();
|
||||||
static void setContext(Info &oclinfo);
|
static void setContext(Info &oclinfo);
|
||||||
|
|
||||||
enum {CL_DOUBLE, CL_UNIFIED_MEM};
|
enum {CL_DOUBLE, CL_UNIFIED_MEM, CL_VER_1_2};
|
||||||
bool supportsFeature(int ftype);
|
bool supportsFeature(int ftype);
|
||||||
size_t computeUnits();
|
size_t computeUnits();
|
||||||
void* oclContext();
|
void* oclContext();
|
||||||
|
@ -130,6 +130,7 @@ namespace cv
|
|||||||
cl_platform_id oclplatform;
|
cl_platform_id oclplatform;
|
||||||
std::vector<cl_device_id> devices;
|
std::vector<cl_device_id> devices;
|
||||||
std::vector<std::string> devName;
|
std::vector<std::string> devName;
|
||||||
|
std::string clVersion;
|
||||||
|
|
||||||
cl_context oclcontext;
|
cl_context oclcontext;
|
||||||
cl_command_queue clCmdQueue;
|
cl_command_queue clCmdQueue;
|
||||||
@ -304,6 +305,7 @@ namespace cv
|
|||||||
|
|
||||||
char deviceName[256];
|
char deviceName[256];
|
||||||
int devcienums = 0;
|
int devcienums = 0;
|
||||||
|
char clVersion[256];
|
||||||
for (unsigned i = 0; i < numPlatforms; ++i)
|
for (unsigned i = 0; i < numPlatforms; ++i)
|
||||||
{
|
{
|
||||||
cl_uint numsdev;
|
cl_uint numsdev;
|
||||||
@ -319,6 +321,8 @@ namespace cv
|
|||||||
|
|
||||||
Info ocltmpinfo;
|
Info ocltmpinfo;
|
||||||
ocltmpinfo.impl->oclplatform = platforms[i];
|
ocltmpinfo.impl->oclplatform = platforms[i];
|
||||||
|
openCLSafeCall(clGetPlatformInfo(platforms[i], CL_PLATFORM_VERSION, sizeof(clVersion), clVersion, NULL));
|
||||||
|
ocltmpinfo.impl->clVersion = clVersion;
|
||||||
for(unsigned j = 0; j < numsdev; ++j)
|
for(unsigned j = 0; j < numsdev; ++j)
|
||||||
{
|
{
|
||||||
ocltmpinfo.impl->devices.push_back(devices[j]);
|
ocltmpinfo.impl->devices.push_back(devices[j]);
|
||||||
@ -997,6 +1001,8 @@ namespace cv
|
|||||||
return impl->double_support == 1;
|
return impl->double_support == 1;
|
||||||
case CL_UNIFIED_MEM:
|
case CL_UNIFIED_MEM:
|
||||||
return impl->unified_memory == 1;
|
return impl->unified_memory == 1;
|
||||||
|
case CL_VER_1_2:
|
||||||
|
return impl->clVersion.find("OpenCL 1.2") != string::npos;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,8 @@ namespace cv
|
|||||||
CV_Error(-1, "Image forma is not supported");
|
CV_Error(-1, "Image forma is not supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(Context::getContext()->supportsFeature(Context::CL_VER_1_2))
|
||||||
|
{
|
||||||
#if CL_VERSION_1_2
|
#if CL_VERSION_1_2
|
||||||
cl_image_desc desc;
|
cl_image_desc desc;
|
||||||
desc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
desc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||||
@ -176,6 +178,11 @@ namespace cv
|
|||||||
desc.num_samples = 0;
|
desc.num_samples = 0;
|
||||||
texture = clCreateImage((cl_context)mat.clCxt->oclContext(), CL_MEM_READ_WRITE, &format, &desc, NULL, &err);
|
texture = clCreateImage((cl_context)mat.clCxt->oclContext(), CL_MEM_READ_WRITE, &format, &desc, NULL, &err);
|
||||||
#else
|
#else
|
||||||
|
CV_Error(CV_StsBadFunc, "Non-deprecated image creation API call is not supported.");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
texture = clCreateImage2D(
|
texture = clCreateImage2D(
|
||||||
(cl_context)mat.clCxt->oclContext(),
|
(cl_context)mat.clCxt->oclContext(),
|
||||||
CL_MEM_READ_WRITE,
|
CL_MEM_READ_WRITE,
|
||||||
@ -185,7 +192,7 @@ namespace cv
|
|||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
&err);
|
&err);
|
||||||
#endif
|
}
|
||||||
size_t origin[] = { 0, 0, 0 };
|
size_t origin[] = { 0, 0, 0 };
|
||||||
size_t region[] = { mat.cols, mat.rows, 1 };
|
size_t region[] = { mat.cols, mat.rows, 1 };
|
||||||
|
|
||||||
@ -214,7 +221,6 @@ namespace cv
|
|||||||
openCLSafeCall(err);
|
openCLSafeCall(err);
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void releaseTexture(cl_mem& texture)
|
void releaseTexture(cl_mem& texture)
|
||||||
{
|
{
|
||||||
openCLFree(texture);
|
openCLFree(texture);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user