diff options
author | 2016-03-24 15:01:52 +0800 | |
---|---|---|
committer | 2016-04-07 21:15:03 +0800 | |
commit | 136b8eb38e98d96009799eee59d4ea0088544b54 (patch) | |
tree | 7fc308d253205213d5df8610a713189274ddc4b6 /vulkan/libvulkan/loader.cpp | |
parent | 9d51816145b008b7b4b091a8c90faf30ba0394e4 (diff) |
vulkan: move driver::OpenHAL
Move it from loader.cpp to driver.cpp. HAL loading is now done in
driver.cpp while HAL extension queries are still done in loader.cpp.
Change-Id: I15d7ead98497adacb1bd798522f057ff6bf16909
Diffstat (limited to 'vulkan/libvulkan/loader.cpp')
-rw-r--r-- | vulkan/libvulkan/loader.cpp | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/vulkan/libvulkan/loader.cpp b/vulkan/libvulkan/loader.cpp index 9a3a3f854c..2c63b0643c 100644 --- a/vulkan/libvulkan/loader.cpp +++ b/vulkan/libvulkan/loader.cpp @@ -178,34 +178,14 @@ const VkAllocationCallbacks kDefaultAllocCallbacks = { hwvulkan_device_t* g_hwdevice = nullptr; InstanceExtensionSet g_driver_instance_extensions; -void LoadVulkanHAL() { - static const hwvulkan_module_t* module; - int result = - hw_get_module("vulkan", reinterpret_cast<const hw_module_t**>(&module)); - if (result != 0) { - ALOGE("failed to load vulkan hal: %s (%d)", strerror(-result), result); - return; - } - result = module->common.methods->open( - &module->common, HWVULKAN_DEVICE_0, - reinterpret_cast<hw_device_t**>(&g_hwdevice)); - if (result != 0) { - ALOGE("failed to open vulkan driver: %s (%d)", strerror(-result), - result); - module = nullptr; - return; - } - +bool LoadVulkanHAL() { VkResult vkresult; uint32_t count; if ((vkresult = g_hwdevice->EnumerateInstanceExtensionProperties( nullptr, &count, nullptr)) != VK_SUCCESS) { ALOGE("driver EnumerateInstanceExtensionProperties failed: %d", vkresult); - g_hwdevice->common.close(&g_hwdevice->common); - g_hwdevice = nullptr; - module = nullptr; - return; + return false; } VkExtensionProperties* extensions = static_cast<VkExtensionProperties*>( alloca(count * sizeof(VkExtensionProperties))); @@ -213,10 +193,7 @@ void LoadVulkanHAL() { nullptr, &count, extensions)) != VK_SUCCESS) { ALOGE("driver EnumerateInstanceExtensionProperties failed: %d", vkresult); - g_hwdevice->common.close(&g_hwdevice->common); - g_hwdevice = nullptr; - module = nullptr; - return; + return false; } ALOGV_IF(count > 0, "Driver-supported instance extensions:"); for (uint32_t i = 0; i < count; i++) { @@ -230,6 +207,8 @@ void LoadVulkanHAL() { // Ignore driver attempts to support loader extensions g_driver_instance_extensions.reset(kKHR_surface); g_driver_instance_extensions.reset(kKHR_android_surface); + + return true; } // ----------------------------------------------------------------------------- @@ -986,15 +965,18 @@ DebugReportCallbackList& GetDebugReportCallbacks(VkInstance instance) { return GetDispatchParent(instance).debug_report_callbacks; } -namespace driver { - -bool OpenHAL() { - if (!g_hwdevice) - LoadVulkanHAL(); +bool InitLoader(hwvulkan_device_t* dev) { + if (!g_hwdevice) { + g_hwdevice = dev; + if (!LoadVulkanHAL()) + g_hwdevice = nullptr; + } return (g_hwdevice != nullptr); } +namespace driver { + const VkAllocationCallbacks& GetDefaultAllocator() { return kDefaultAllocCallbacks; } |