summaryrefslogtreecommitdiff
path: root/vulkan/libvulkan/driver.cpp
diff options
context:
space:
mode:
author Chia-I Wu <olv@google.com> 2016-03-24 15:01:52 +0800
committer Chia-I Wu <olv@google.com> 2016-04-07 21:15:03 +0800
commit136b8eb38e98d96009799eee59d4ea0088544b54 (patch)
tree7fc308d253205213d5df8610a713189274ddc4b6 /vulkan/libvulkan/driver.cpp
parent9d51816145b008b7b4b091a8c90faf30ba0394e4 (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/driver.cpp')
-rw-r--r--vulkan/libvulkan/driver.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 26c192374d..09811a036a 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -17,13 +17,52 @@
#include <sys/prctl.h>
#include "driver.h"
+#include "loader.h"
namespace vulkan {
namespace driver {
+namespace {
+
+hwvulkan_device_t* g_hwdevice = nullptr;
+
+} // anonymous namespace
+
bool Debuggable() {
return (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) >= 0);
}
+bool OpenHAL() {
+ if (g_hwdevice)
+ return true;
+
+ 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 false;
+ }
+
+ hwvulkan_device_t* device;
+ result =
+ module->common.methods->open(&module->common, HWVULKAN_DEVICE_0,
+ reinterpret_cast<hw_device_t**>(&device));
+ if (result != 0) {
+ ALOGE("failed to open vulkan driver: %s (%d)", strerror(-result),
+ result);
+ return false;
+ }
+
+ if (!InitLoader(device)) {
+ device->common.close(&device->common);
+ return false;
+ }
+
+ g_hwdevice = device;
+
+ return true;
+}
+
} // namespace driver
} // namespace vulkan