Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_HWVULKAN_H |
| 18 | #define ANDROID_HWVULKAN_H |
| 19 | |
| 20 | #include <hardware/hardware.h> |
| 21 | #include <vulkan/vulkan.h> |
| 22 | |
| 23 | __BEGIN_DECLS |
| 24 | |
| 25 | #define HWVULKAN_HARDWARE_MODULE_ID "vulkan" |
| 26 | |
| 27 | #define HWVULKAN_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) |
| 28 | #define HWVULKAN_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, 0) |
| 29 | |
| 30 | #define HWVULKAN_DEVICE_0 "vk0" |
| 31 | |
| 32 | typedef struct hwvulkan_module_t { |
| 33 | struct hw_module_t common; |
| 34 | } hwvulkan_module_t; |
| 35 | |
| 36 | /* Dispatchable Vulkan object handles must be pointers, which must point to |
| 37 | * instances of hwvulkan_dispatch_t (potentially followed by additional |
| 38 | * implementation-defined data). On return from the creation function, the |
| 39 | * 'magic' field must contain HWVULKAN_DISPATCH_MAGIC; the loader will overwrite |
| 40 | * the 'vtbl' field. |
| 41 | */ |
| 42 | #if defined(__LP64__) |
| 43 | #define HWVULKAN_DISPATCH_MAGIC UINT64_C(0xCA11AB1E00C0DE00) |
| 44 | #elif defined(__ILP32__) |
| 45 | #define HWVULKAN_DISPATCH_MAGIC UINT32_C(0xCA11AB1E) |
| 46 | #else |
| 47 | #error "unknown pointer size?!" |
| 48 | #endif |
| 49 | |
| 50 | typedef union { |
| 51 | uintptr_t magic; |
| 52 | const void* vtbl; |
| 53 | } hwvulkan_dispatch_t; |
| 54 | |
| 55 | /* A hwvulkan_device_t corresponds to an ICD on other systems. Currently there |
| 56 | * can only be one on a system (HWVULKAN_DEVICE_0). It is opened once per |
| 57 | * process when the Vulkan API is first used; the hw_device_t::close() function |
| 58 | * is never called. Any non-trivial resource allocation should be done when |
| 59 | * the VkInstance is created rather than when the hwvulkan_device_t is opened. |
| 60 | */ |
| 61 | typedef struct hwvulkan_device_t { |
| 62 | struct hw_device_t common; |
| 63 | |
| 64 | PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties; |
| 65 | PFN_vkCreateInstance CreateInstance; |
| 66 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
| 67 | } hwvulkan_device_t; |
| 68 | |
| 69 | __END_DECLS |
| 70 | |
| 71 | #endif // ANDROID_HWVULKAN_H |