diff --git a/src/opencl_wrapper.cpp b/src/opencl_wrapper.cpp index 756a70bc396069e75234245fa81d029b86dfc1a1..099cba75591d5c6512d3fb2328e41543791fd0b8 100644 --- a/src/opencl_wrapper.cpp +++ b/src/opencl_wrapper.cpp @@ -30,22 +30,25 @@ static const std::vector g_opencl_library_paths = { #if defined(__APPLE__) || defined(__MACOSX) "libOpenCL.so", "/System/Library/Frameworks/OpenCL.framework/OpenCL" #else + "/vendor/lib64/chipsetsdk/libGLES_mali.so" "/system/lib64/libGLES_mali.so", "libGLES_mali.so", #endif }; static std::mutex g_initMutex; -bool isInit = false; -void *handle_{nullptr}; +static bool isInit = false; +static bool loadSuccess = false; +static void *handle_{nullptr}; bool InitOpenCL() { std::lock_guard lock(g_initMutex); if (isInit){ - return true; + return loadSuccess; } - isInit = LoadOpenCLLibrary(&handle_); - return isInit; + isInit = true; + loadSuccess = LoadOpenCLLibrary(&handle_); + return loadSuccess; } bool UnLoadOpenCLLibrary(void *handle) { @@ -72,7 +75,6 @@ bool LoadLibraryFromPath(const std::string &library_path, void **handle_ptr) { #define LOAD_OPENCL_FUNCTION_PTR(func_name) \ func_name = reinterpret_cast(dlsym(*handle_ptr, #func_name)); \ if (func_name == nullptr) { \ - UnLoadOpenCLLibrary(*handle_ptr); \ return false; \ } @@ -148,9 +150,6 @@ bool LoadOpenCLLibrary(void **handle_ptr) { if (handle_ptr == nullptr) { return false; } - if (*handle_ptr != nullptr) { - return true; - } auto it = std::find_if(g_opencl_library_paths.begin(), g_opencl_library_paths.end(), [&](const std::string &lib_path) { return OHOS::LoadLibraryFromPath(lib_path, handle_ptr); });