vulkan: initial loader and null driver

Change-Id: Id5ebb5f01e61e9b114990f49c64c88fbbb7b730e
(cherry picked from commit 4df205cdfc61e66de774ba50be9ef59a08cf88bb)
diff --git a/vulkan/include/hardware/hwvulkan.h b/vulkan/include/hardware/hwvulkan.h
new file mode 100644
index 0000000..91dd41e
--- /dev/null
+++ b/vulkan/include/hardware/hwvulkan.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HWVULKAN_H
+#define ANDROID_HWVULKAN_H
+
+#include <hardware/hardware.h>
+#include <vulkan/vulkan.h>
+
+__BEGIN_DECLS
+
+#define HWVULKAN_HARDWARE_MODULE_ID "vulkan"
+
+#define HWVULKAN_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
+#define HWVULKAN_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, 0)
+
+#define HWVULKAN_DEVICE_0 "vk0"
+
+typedef struct hwvulkan_module_t {
+    struct hw_module_t common;
+} hwvulkan_module_t;
+
+/* Dispatchable Vulkan object handles must be pointers, which must point to
+ * instances of hwvulkan_dispatch_t (potentially followed by additional
+ * implementation-defined data). On return from the creation function, the
+ * 'magic' field must contain HWVULKAN_DISPATCH_MAGIC; the loader will overwrite
+ * the 'vtbl' field.
+ */
+#if defined(__LP64__)
+#define HWVULKAN_DISPATCH_MAGIC UINT64_C(0xCA11AB1E00C0DE00)
+#elif defined(__ILP32__)
+#define HWVULKAN_DISPATCH_MAGIC UINT32_C(0xCA11AB1E)
+#else
+#error "unknown pointer size?!"
+#endif
+
+typedef union {
+    uintptr_t magic;
+    const void* vtbl;
+} hwvulkan_dispatch_t;
+
+/* A hwvulkan_device_t corresponds to an ICD on other systems. Currently there
+ * can only be one on a system (HWVULKAN_DEVICE_0). It is opened once per
+ * process when the Vulkan API is first used; the hw_device_t::close() function
+ * is never called. Any non-trivial resource allocation should be done when
+ * the VkInstance is created rather than when the hwvulkan_device_t is opened.
+ */
+typedef struct hwvulkan_device_t {
+    struct hw_device_t common;
+
+    PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties;
+    PFN_vkCreateInstance CreateInstance;
+    PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
+} hwvulkan_device_t;
+
+__END_DECLS
+
+#endif  // ANDROID_HWVULKAN_H