Loading vulkan/libvulkan/driver.cpp +38 −10 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,11 @@ #include "driver.h" #include "driver.h" #include "stubhal.h" #include "stubhal.h" // TODO(b/37049319) Get this from a header once one exists extern "C" { android_namespace_t* android_get_exported_namespace(const char*); } // Set to true to enable exposing unratified extensions for development // Set to true to enable exposing unratified extensions for development static const bool kEnableUnratifiedExtensions = false; static const bool kEnableUnratifiedExtensions = false; Loading Loading @@ -150,14 +155,12 @@ const std::array<const char*, 2> HAL_SUBNAME_KEY_PROPERTIES = {{ "ro.board.platform", "ro.board.platform", }}; }}; int LoadUpdatedDriver(const hw_module_t** module) { int LoadDriver(android_namespace_t* library_namespace, const hwvulkan_module_t** module) { const android_dlextinfo dlextinfo = { const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = android::GraphicsEnv::getInstance().getDriverNamespace(), .library_namespace = library_namespace, }; }; if (!dlextinfo.library_namespace) return -ENOENT; void* so = nullptr; void* so = nullptr; char prop[PROPERTY_VALUE_MAX]; char prop[PROPERTY_VALUE_MAX]; for (auto key : HAL_SUBNAME_KEY_PROPERTIES) { for (auto key : HAL_SUBNAME_KEY_PROPERTIES) { Loading @@ -171,7 +174,7 @@ int LoadUpdatedDriver(const hw_module_t** module) { if (!so) if (!so) return -ENOENT; return -ENOENT; hw_module_t* hmi = static_cast<hw_module_t*>(dlsym(so, HAL_MODULE_INFO_SYM_AS_STR)); auto hmi = static_cast<hw_module_t*>(dlsym(so, HAL_MODULE_INFO_SYM_AS_STR)); if (!hmi) { if (!hmi) { ALOGE("couldn't find symbol '%s' in HAL library: %s", HAL_MODULE_INFO_SYM_AS_STR, dlerror()); ALOGE("couldn't find symbol '%s' in HAL library: %s", HAL_MODULE_INFO_SYM_AS_STR, dlerror()); dlclose(so); dlclose(so); Loading @@ -183,11 +186,24 @@ int LoadUpdatedDriver(const hw_module_t** module) { return -EINVAL; return -EINVAL; } } hmi->dso = so; hmi->dso = so; *module = hmi; *module = reinterpret_cast<const hwvulkan_module_t*>(hmi); ALOGD("loaded updated driver"); return 0; return 0; } } int LoadBuiltinDriver(const hwvulkan_module_t** module) { auto ns = android_get_exported_namespace("sphal"); if (!ns) return -ENOENT; return LoadDriver(ns, module); } int LoadUpdatedDriver(const hwvulkan_module_t** module) { auto ns = android::GraphicsEnv::getInstance().getDriverNamespace(); if (!ns) return -ENOENT; return LoadDriver(ns, module); } bool Hal::Open() { bool Hal::Open() { ALOG_ASSERT(!hal_.dev_, "OpenHAL called more than once"); ALOG_ASSERT(!hal_.dev_, "OpenHAL called more than once"); Loading @@ -197,9 +213,21 @@ bool Hal::Open() { int result; int result; const hwvulkan_module_t* module = nullptr; const hwvulkan_module_t* module = nullptr; result = LoadUpdatedDriver(reinterpret_cast<const hw_module_t**>(&module)); result = LoadUpdatedDriver(&module); if (result == -ENOENT) { if (result == -ENOENT) { result = hw_get_module(HWVULKAN_HARDWARE_MODULE_ID, reinterpret_cast<const hw_module_t**>(&module)); result = LoadBuiltinDriver(&module); if (result != 0) { // -ENOENT means the sphal namespace doesn't exist, not that there // is a problem with the driver. ALOGW_IF( result != -ENOENT, "Failed to load Vulkan driver into sphal namespace. This " "usually means the driver has forbidden library dependencies." "Please fix, this will soon stop working."); result = hw_get_module(HWVULKAN_HARDWARE_MODULE_ID, reinterpret_cast<const hw_module_t**>(&module)); } } } if (result != 0) { if (result != 0) { ALOGV("unable to load Vulkan HAL, using stub HAL (result=%d)", result); ALOGV("unable to load Vulkan HAL, using stub HAL (result=%d)", result); Loading Loading
vulkan/libvulkan/driver.cpp +38 −10 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,11 @@ #include "driver.h" #include "driver.h" #include "stubhal.h" #include "stubhal.h" // TODO(b/37049319) Get this from a header once one exists extern "C" { android_namespace_t* android_get_exported_namespace(const char*); } // Set to true to enable exposing unratified extensions for development // Set to true to enable exposing unratified extensions for development static const bool kEnableUnratifiedExtensions = false; static const bool kEnableUnratifiedExtensions = false; Loading Loading @@ -150,14 +155,12 @@ const std::array<const char*, 2> HAL_SUBNAME_KEY_PROPERTIES = {{ "ro.board.platform", "ro.board.platform", }}; }}; int LoadUpdatedDriver(const hw_module_t** module) { int LoadDriver(android_namespace_t* library_namespace, const hwvulkan_module_t** module) { const android_dlextinfo dlextinfo = { const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = android::GraphicsEnv::getInstance().getDriverNamespace(), .library_namespace = library_namespace, }; }; if (!dlextinfo.library_namespace) return -ENOENT; void* so = nullptr; void* so = nullptr; char prop[PROPERTY_VALUE_MAX]; char prop[PROPERTY_VALUE_MAX]; for (auto key : HAL_SUBNAME_KEY_PROPERTIES) { for (auto key : HAL_SUBNAME_KEY_PROPERTIES) { Loading @@ -171,7 +174,7 @@ int LoadUpdatedDriver(const hw_module_t** module) { if (!so) if (!so) return -ENOENT; return -ENOENT; hw_module_t* hmi = static_cast<hw_module_t*>(dlsym(so, HAL_MODULE_INFO_SYM_AS_STR)); auto hmi = static_cast<hw_module_t*>(dlsym(so, HAL_MODULE_INFO_SYM_AS_STR)); if (!hmi) { if (!hmi) { ALOGE("couldn't find symbol '%s' in HAL library: %s", HAL_MODULE_INFO_SYM_AS_STR, dlerror()); ALOGE("couldn't find symbol '%s' in HAL library: %s", HAL_MODULE_INFO_SYM_AS_STR, dlerror()); dlclose(so); dlclose(so); Loading @@ -183,11 +186,24 @@ int LoadUpdatedDriver(const hw_module_t** module) { return -EINVAL; return -EINVAL; } } hmi->dso = so; hmi->dso = so; *module = hmi; *module = reinterpret_cast<const hwvulkan_module_t*>(hmi); ALOGD("loaded updated driver"); return 0; return 0; } } int LoadBuiltinDriver(const hwvulkan_module_t** module) { auto ns = android_get_exported_namespace("sphal"); if (!ns) return -ENOENT; return LoadDriver(ns, module); } int LoadUpdatedDriver(const hwvulkan_module_t** module) { auto ns = android::GraphicsEnv::getInstance().getDriverNamespace(); if (!ns) return -ENOENT; return LoadDriver(ns, module); } bool Hal::Open() { bool Hal::Open() { ALOG_ASSERT(!hal_.dev_, "OpenHAL called more than once"); ALOG_ASSERT(!hal_.dev_, "OpenHAL called more than once"); Loading @@ -197,9 +213,21 @@ bool Hal::Open() { int result; int result; const hwvulkan_module_t* module = nullptr; const hwvulkan_module_t* module = nullptr; result = LoadUpdatedDriver(reinterpret_cast<const hw_module_t**>(&module)); result = LoadUpdatedDriver(&module); if (result == -ENOENT) { if (result == -ENOENT) { result = hw_get_module(HWVULKAN_HARDWARE_MODULE_ID, reinterpret_cast<const hw_module_t**>(&module)); result = LoadBuiltinDriver(&module); if (result != 0) { // -ENOENT means the sphal namespace doesn't exist, not that there // is a problem with the driver. ALOGW_IF( result != -ENOENT, "Failed to load Vulkan driver into sphal namespace. This " "usually means the driver has forbidden library dependencies." "Please fix, this will soon stop working."); result = hw_get_module(HWVULKAN_HARDWARE_MODULE_ID, reinterpret_cast<const hw_module_t**>(&module)); } } } if (result != 0) { if (result != 0) { ALOGV("unable to load Vulkan HAL, using stub HAL (result=%d)", result); ALOGV("unable to load Vulkan HAL, using stub HAL (result=%d)", result); Loading