1 /* 2 * Copyright 2016 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 // WARNING: This file is generated. See ../README.md for instructions. 18 19 #ifndef LIBVULKAN_DRIVER_GEN_H 20 #define LIBVULKAN_DRIVER_GEN_H 21 22 #include <vulkan/vk_android_native_buffer.h> 23 #include <vulkan/vulkan.h> 24 25 #include <bitset> 26 #include <optional> 27 #include <vector> 28 29 namespace vulkan { 30 namespace driver { 31 32 struct ProcHook { 33 enum Type { 34 GLOBAL, 35 INSTANCE, 36 DEVICE, 37 }; 38 enum Extension { 39 ANDROID_native_buffer, 40 EXT_debug_report, 41 EXT_hdr_metadata, 42 EXT_swapchain_colorspace, 43 GOOGLE_display_timing, 44 GOOGLE_surfaceless_query, 45 KHR_android_surface, 46 KHR_get_surface_capabilities2, 47 KHR_incremental_present, 48 KHR_shared_presentable_image, 49 KHR_surface, 50 KHR_surface_protected_capabilities, 51 KHR_swapchain, 52 EXT_swapchain_maintenance1, 53 EXT_surface_maintenance1, 54 ANDROID_external_memory_android_hardware_buffer, 55 KHR_bind_memory2, 56 KHR_get_physical_device_properties2, 57 KHR_device_group_creation, 58 KHR_external_memory_capabilities, 59 KHR_external_semaphore_capabilities, 60 KHR_external_fence_capabilities, 61 KHR_external_fence_fd, 62 63 EXTENSION_CORE_1_0, 64 EXTENSION_CORE_1_1, 65 EXTENSION_CORE_1_2, 66 EXTENSION_CORE_1_3, 67 EXTENSION_COUNT, 68 EXTENSION_UNKNOWN, 69 }; 70 71 const char* name; 72 Type type; 73 Extension extension; 74 75 PFN_vkVoidFunction proc; 76 PFN_vkVoidFunction checked_proc; // always nullptr for non-device hooks 77 }; 78 79 struct InstanceDriverTable { 80 // clang-format off 81 PFN_vkDestroyInstance DestroyInstance; 82 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; 83 PFN_vkGetInstanceProcAddr GetInstanceProcAddr; 84 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; 85 PFN_vkCreateDevice CreateDevice; 86 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; 87 PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; 88 PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; 89 PFN_vkDebugReportMessageEXT DebugReportMessageEXT; 90 PFN_vkGetPhysicalDeviceFeatures2 GetPhysicalDeviceFeatures2; 91 PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR; 92 PFN_vkGetPhysicalDeviceProperties2 GetPhysicalDeviceProperties2; 93 PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR; 94 PFN_vkGetPhysicalDeviceFormatProperties2 GetPhysicalDeviceFormatProperties2; 95 PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2KHR; 96 PFN_vkGetPhysicalDeviceImageFormatProperties2 GetPhysicalDeviceImageFormatProperties2; 97 PFN_vkGetPhysicalDeviceImageFormatProperties2KHR GetPhysicalDeviceImageFormatProperties2KHR; 98 PFN_vkGetPhysicalDeviceQueueFamilyProperties2 GetPhysicalDeviceQueueFamilyProperties2; 99 PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR GetPhysicalDeviceQueueFamilyProperties2KHR; 100 PFN_vkGetPhysicalDeviceMemoryProperties2 GetPhysicalDeviceMemoryProperties2; 101 PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR; 102 PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 GetPhysicalDeviceSparseImageFormatProperties2; 103 PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR; 104 PFN_vkGetPhysicalDeviceExternalBufferProperties GetPhysicalDeviceExternalBufferProperties; 105 PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR GetPhysicalDeviceExternalBufferPropertiesKHR; 106 PFN_vkGetPhysicalDeviceExternalSemaphoreProperties GetPhysicalDeviceExternalSemaphoreProperties; 107 PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR GetPhysicalDeviceExternalSemaphorePropertiesKHR; 108 PFN_vkGetPhysicalDeviceExternalFenceProperties GetPhysicalDeviceExternalFenceProperties; 109 PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR GetPhysicalDeviceExternalFencePropertiesKHR; 110 PFN_vkEnumeratePhysicalDeviceGroups EnumeratePhysicalDeviceGroups; 111 PFN_vkEnumeratePhysicalDeviceGroupsKHR EnumeratePhysicalDeviceGroupsKHR; 112 // clang-format on 113 }; 114 115 struct DeviceDriverTable { 116 // clang-format off 117 PFN_vkGetDeviceProcAddr GetDeviceProcAddr; 118 PFN_vkDestroyDevice DestroyDevice; 119 PFN_vkGetDeviceQueue GetDeviceQueue; 120 PFN_vkQueueSubmit QueueSubmit; 121 PFN_vkCreateImage CreateImage; 122 PFN_vkDestroyImage DestroyImage; 123 PFN_vkAllocateCommandBuffers AllocateCommandBuffers; 124 PFN_vkImportFenceFdKHR ImportFenceFdKHR; 125 PFN_vkBindImageMemory2 BindImageMemory2; 126 PFN_vkBindImageMemory2KHR BindImageMemory2KHR; 127 PFN_vkGetDeviceQueue2 GetDeviceQueue2; 128 PFN_vkGetSwapchainGrallocUsageANDROID GetSwapchainGrallocUsageANDROID; 129 PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID; 130 PFN_vkGetSwapchainGrallocUsage3ANDROID GetSwapchainGrallocUsage3ANDROID; 131 PFN_vkGetSwapchainGrallocUsage4ANDROID GetSwapchainGrallocUsage4ANDROID; 132 PFN_vkAcquireImageANDROID AcquireImageANDROID; 133 PFN_vkQueueSignalReleaseImageANDROID QueueSignalReleaseImageANDROID; 134 // clang-format on 135 }; 136 137 const ProcHook* GetProcHook(const char* name); 138 ProcHook::Extension GetProcHookExtension(const char* name); 139 140 bool InitDriverTable(VkInstance instance, 141 PFN_vkGetInstanceProcAddr get_proc, 142 const std::bitset<ProcHook::EXTENSION_COUNT>& extensions); 143 bool InitDriverTable(VkDevice dev, 144 PFN_vkGetDeviceProcAddr get_proc, 145 const std::bitset<ProcHook::EXTENSION_COUNT>& extensions); 146 147 std::optional<uint32_t> GetInstanceExtensionPromotedVersion(const char* name); 148 uint32_t CountPromotedInstanceExtensions(uint32_t begin_version, 149 uint32_t end_version); 150 std::vector<const char*> GetPromotedInstanceExtensions(uint32_t begin_version, 151 uint32_t end_version); 152 153 } // namespace driver 154 } // namespace vulkan 155 156 #endif // LIBVULKAN_DRIVER_TABLE_H 157