1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #18439 from komakai:opencl

This commit is contained in:
Alexander Alekhin
2020-09-29 15:07:27 +00:00
2 changed files with 56 additions and 0 deletions
@@ -177,6 +177,55 @@ static void *GetHandle(const char *file)
return handle;
}
#ifdef __ANDROID__
static const char *defaultAndroidPaths[] = {
"libOpenCL.so",
"/system/lib64/libOpenCL.so",
"/system/vendor/lib64/libOpenCL.so",
"/system/vendor/lib64/egl/libGLES_mali.so",
"/system/vendor/lib64/libPVROCL.so",
"/data/data/org.pocl.libs/files/lib64/libpocl.so",
"/system/lib/libOpenCL.so",
"/system/vendor/lib/libOpenCL.so",
"/system/vendor/lib/egl/libGLES_mali.so",
"/system/vendor/lib/libPVROCL.so",
"/data/data/org.pocl.libs/files/lib/libpocl.so"
};
static void* GetProcAddress(const char* name)
{
static bool initialized = false;
static void* handle = NULL;
if (!handle && !initialized)
{
cv::AutoLock lock(cv::getInitializationMutex());
if (!initialized)
{
bool foundOpenCL = false;
for (unsigned int i = 0; i < (sizeof(defaultAndroidPaths)/sizeof(char*)); i++)
{
const char* path = (i==0) ? getRuntimePath(defaultAndroidPaths[i]) : defaultAndroidPaths[i];
if (path) {
handle = GetHandle(path);
if (handle) {
foundOpenCL = true;
break;
}
}
}
initialized = true;
if (!foundOpenCL)
fprintf(stderr, ERROR_MSG_CANT_LOAD);
}
}
if (!handle)
return NULL;
return dlsym(handle, name);
}
#else // NOT __ANDROID__
static void* GetProcAddress(const char* name)
{
static bool initialized = false;
@@ -206,6 +255,8 @@ static void* GetProcAddress(const char* name)
return NULL;
return dlsym(handle, name);
}
#endif // __ANDROID__
#define CV_CL_GET_PROC_ADDRESS(name) GetProcAddress(name)
#endif