Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 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 | #include <string.h> |
Mark Salyzyn | a5e161b | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 20 | |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 21 | #include <algorithm> |
Mark Salyzyn | a5e161b | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 22 | |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 23 | #include <log/log.h> |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 24 | |
| 25 | #include "driver.h" |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 26 | |
| 27 | namespace vulkan { |
| 28 | namespace driver { |
| 29 | |
| 30 | namespace { |
| 31 | |
| 32 | // clang-format off |
| 33 | |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 34 | VKAPI_ATTR VkResult checkedBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos) { |
| 35 | if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) { |
| 36 | return BindImageMemory2(device, bindInfoCount, pBindInfos); |
| 37 | } else { |
| 38 | Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkBindImageMemory2 not executed."); |
| 39 | return VK_SUCCESS; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | VKAPI_ATTR void checkedGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue) { |
| 44 | if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) { |
| 45 | GetDeviceQueue2(device, pQueueInfo, pQueue); |
| 46 | } else { |
| 47 | Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkGetDeviceQueue2 not executed."); |
| 48 | } |
| 49 | } |
| 50 | |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 51 | VKAPI_ATTR VkResult checkedCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) { |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 52 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 53 | return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); |
| 54 | } else { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 55 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkCreateSwapchainKHR not executed."); |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 56 | return VK_SUCCESS; |
| 57 | } |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | VKAPI_ATTR void checkedDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator) { |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 61 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 62 | DestroySwapchainKHR(device, swapchain, pAllocator); |
| 63 | } else { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 64 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkDestroySwapchainKHR not executed."); |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 65 | } |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | VKAPI_ATTR VkResult checkedGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) { |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 69 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 70 | return GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
| 71 | } else { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 72 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkGetSwapchainImagesKHR not executed."); |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 73 | return VK_SUCCESS; |
| 74 | } |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | VKAPI_ATTR VkResult checkedAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex) { |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 78 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 79 | return AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex); |
| 80 | } else { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 81 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkAcquireNextImageKHR not executed."); |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 82 | return VK_SUCCESS; |
| 83 | } |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | VKAPI_ATTR VkResult checkedQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo) { |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 87 | if (GetData(queue).hook_extensions[ProcHook::KHR_swapchain]) { |
| 88 | return QueuePresentKHR(queue, pPresentInfo); |
| 89 | } else { |
Chia-I Wu | 5beb2ac | 2016-05-04 16:37:23 +0800 | [diff] [blame] | 90 | Logger(queue).Err(queue, "VK_KHR_swapchain not enabled. vkQueuePresentKHR not executed."); |
Chia-I Wu | 36cc00a | 2016-04-13 16:52:06 +0800 | [diff] [blame] | 91 | return VK_SUCCESS; |
| 92 | } |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 93 | } |
| 94 | |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 95 | VKAPI_ATTR VkResult checkedGetDeviceGroupPresentCapabilitiesKHR(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities) { |
| 96 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 97 | return GetDeviceGroupPresentCapabilitiesKHR(device, pDeviceGroupPresentCapabilities); |
| 98 | } else { |
| 99 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkGetDeviceGroupPresentCapabilitiesKHR not executed."); |
| 100 | return VK_SUCCESS; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | VKAPI_ATTR VkResult checkedGetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR* pModes) { |
| 105 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 106 | return GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes); |
| 107 | } else { |
| 108 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkGetDeviceGroupSurfacePresentModesKHR not executed."); |
| 109 | return VK_SUCCESS; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | VKAPI_ATTR VkResult checkedAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR* pAcquireInfo, uint32_t* pImageIndex) { |
| 114 | if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { |
| 115 | return AcquireNextImage2KHR(device, pAcquireInfo, pImageIndex); |
| 116 | } else { |
| 117 | Logger(device).Err(device, "VK_KHR_swapchain not enabled. vkAcquireNextImage2KHR not executed."); |
| 118 | return VK_SUCCESS; |
| 119 | } |
| 120 | } |
| 121 | |
Ian Elliott | 4c8bb2a | 2016-12-29 11:07:26 -0700 | [diff] [blame] | 122 | VKAPI_ATTR VkResult checkedGetRefreshCycleDurationGOOGLE(VkDevice device, VkSwapchainKHR swapchain, VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties) { |
| 123 | if (GetData(device).hook_extensions[ProcHook::GOOGLE_display_timing]) { |
| 124 | return GetRefreshCycleDurationGOOGLE(device, swapchain, pDisplayTimingProperties); |
| 125 | } else { |
| 126 | Logger(device).Err(device, "VK_GOOGLE_display_timing not enabled. vkGetRefreshCycleDurationGOOGLE not executed."); |
| 127 | return VK_SUCCESS; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | VKAPI_ATTR VkResult checkedGetPastPresentationTimingGOOGLE(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pPresentationTimingCount, VkPastPresentationTimingGOOGLE* pPresentationTimings) { |
| 132 | if (GetData(device).hook_extensions[ProcHook::GOOGLE_display_timing]) { |
| 133 | return GetPastPresentationTimingGOOGLE(device, swapchain, pPresentationTimingCount, pPresentationTimings); |
| 134 | } else { |
| 135 | Logger(device).Err(device, "VK_GOOGLE_display_timing not enabled. vkGetPastPresentationTimingGOOGLE not executed."); |
| 136 | return VK_SUCCESS; |
| 137 | } |
| 138 | } |
| 139 | |
Jesse Hall | 889cd9a | 2017-02-25 22:12:23 -0800 | [diff] [blame] | 140 | VKAPI_ATTR void checkedSetHdrMetadataEXT(VkDevice device, uint32_t swapchainCount, const VkSwapchainKHR* pSwapchains, const VkHdrMetadataEXT* pMetadata) { |
| 141 | if (GetData(device).hook_extensions[ProcHook::EXT_hdr_metadata]) { |
| 142 | SetHdrMetadataEXT(device, swapchainCount, pSwapchains, pMetadata); |
| 143 | } else { |
| 144 | Logger(device).Err(device, "VK_EXT_hdr_metadata not enabled. vkSetHdrMetadataEXT not executed."); |
| 145 | } |
| 146 | } |
| 147 | |
Chris Forbes | 0f2ac2e | 2017-01-18 13:33:53 +1300 | [diff] [blame] | 148 | VKAPI_ATTR VkResult checkedGetSwapchainStatusKHR(VkDevice device, VkSwapchainKHR swapchain) { |
Chris Forbes | 1d5f68c | 2017-01-31 10:17:01 +1300 | [diff] [blame] | 149 | if (GetData(device).hook_extensions[ProcHook::KHR_shared_presentable_image]) { |
Chris Forbes | 0f2ac2e | 2017-01-18 13:33:53 +1300 | [diff] [blame] | 150 | return GetSwapchainStatusKHR(device, swapchain); |
| 151 | } else { |
Chris Forbes | 1d5f68c | 2017-01-31 10:17:01 +1300 | [diff] [blame] | 152 | Logger(device).Err(device, "VK_KHR_shared_presentable_image not enabled. vkGetSwapchainStatusKHR not executed."); |
Chris Forbes | 0f2ac2e | 2017-01-18 13:33:53 +1300 | [diff] [blame] | 153 | return VK_SUCCESS; |
| 154 | } |
| 155 | } |
| 156 | |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 157 | VKAPI_ATTR VkResult checkedBindImageMemory2KHR(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfoKHR* pBindInfos) { |
| 158 | if (GetData(device).hook_extensions[ProcHook::KHR_bind_memory2]) { |
| 159 | return BindImageMemory2KHR(device, bindInfoCount, pBindInfos); |
| 160 | } else { |
| 161 | Logger(device).Err(device, "VK_KHR_bind_memory2 not enabled. vkBindImageMemory2KHR not executed."); |
| 162 | return VK_SUCCESS; |
| 163 | } |
| 164 | } |
| 165 | |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 166 | // clang-format on |
| 167 | |
| 168 | const ProcHook g_proc_hooks[] = { |
| 169 | // clang-format off |
| 170 | { |
| 171 | "vkAcquireImageANDROID", |
| 172 | ProcHook::DEVICE, |
| 173 | ProcHook::ANDROID_native_buffer, |
| 174 | nullptr, |
| 175 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 176 | }, |
| 177 | { |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 178 | "vkAcquireNextImage2KHR", |
| 179 | ProcHook::DEVICE, |
| 180 | ProcHook::KHR_swapchain, |
| 181 | reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImage2KHR), |
| 182 | reinterpret_cast<PFN_vkVoidFunction>(checkedAcquireNextImage2KHR), |
| 183 | }, |
| 184 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 185 | "vkAcquireNextImageKHR", |
| 186 | ProcHook::DEVICE, |
| 187 | ProcHook::KHR_swapchain, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 188 | reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 189 | reinterpret_cast<PFN_vkVoidFunction>(checkedAcquireNextImageKHR), |
| 190 | }, |
| 191 | { |
| 192 | "vkAllocateCommandBuffers", |
| 193 | ProcHook::DEVICE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 194 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | 6a58a8a | 2016-03-24 16:29:51 +0800 | [diff] [blame] | 195 | reinterpret_cast<PFN_vkVoidFunction>(AllocateCommandBuffers), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 196 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 197 | }, |
| 198 | { |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 199 | "vkBindImageMemory2", |
| 200 | ProcHook::DEVICE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 201 | ProcHook::EXTENSION_CORE_1_1, |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 202 | reinterpret_cast<PFN_vkVoidFunction>(BindImageMemory2), |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 203 | reinterpret_cast<PFN_vkVoidFunction>(checkedBindImageMemory2), |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 204 | }, |
| 205 | { |
| 206 | "vkBindImageMemory2KHR", |
| 207 | ProcHook::DEVICE, |
| 208 | ProcHook::KHR_bind_memory2, |
| 209 | reinterpret_cast<PFN_vkVoidFunction>(BindImageMemory2KHR), |
| 210 | reinterpret_cast<PFN_vkVoidFunction>(checkedBindImageMemory2KHR), |
| 211 | }, |
| 212 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 213 | "vkCreateAndroidSurfaceKHR", |
| 214 | ProcHook::INSTANCE, |
| 215 | ProcHook::KHR_android_surface, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 216 | reinterpret_cast<PFN_vkVoidFunction>(CreateAndroidSurfaceKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 217 | nullptr, |
| 218 | }, |
| 219 | { |
| 220 | "vkCreateDebugReportCallbackEXT", |
| 221 | ProcHook::INSTANCE, |
| 222 | ProcHook::EXT_debug_report, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 223 | reinterpret_cast<PFN_vkVoidFunction>(CreateDebugReportCallbackEXT), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 224 | nullptr, |
| 225 | }, |
| 226 | { |
| 227 | "vkCreateDevice", |
| 228 | ProcHook::INSTANCE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 229 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | 4901db7 | 2016-03-24 16:38:58 +0800 | [diff] [blame] | 230 | reinterpret_cast<PFN_vkVoidFunction>(CreateDevice), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 231 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 232 | }, |
| 233 | { |
| 234 | "vkCreateInstance", |
| 235 | ProcHook::GLOBAL, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 236 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | ff4a6c7 | 2016-03-24 16:05:56 +0800 | [diff] [blame] | 237 | reinterpret_cast<PFN_vkVoidFunction>(CreateInstance), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 238 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 239 | }, |
| 240 | { |
| 241 | "vkCreateSwapchainKHR", |
| 242 | ProcHook::DEVICE, |
| 243 | ProcHook::KHR_swapchain, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 244 | reinterpret_cast<PFN_vkVoidFunction>(CreateSwapchainKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 245 | reinterpret_cast<PFN_vkVoidFunction>(checkedCreateSwapchainKHR), |
| 246 | }, |
| 247 | { |
| 248 | "vkDebugReportMessageEXT", |
| 249 | ProcHook::INSTANCE, |
| 250 | ProcHook::EXT_debug_report, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 251 | reinterpret_cast<PFN_vkVoidFunction>(DebugReportMessageEXT), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 252 | nullptr, |
| 253 | }, |
| 254 | { |
| 255 | "vkDestroyDebugReportCallbackEXT", |
| 256 | ProcHook::INSTANCE, |
| 257 | ProcHook::EXT_debug_report, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 258 | reinterpret_cast<PFN_vkVoidFunction>(DestroyDebugReportCallbackEXT), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 259 | nullptr, |
| 260 | }, |
| 261 | { |
| 262 | "vkDestroyDevice", |
| 263 | ProcHook::DEVICE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 264 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | 4901db7 | 2016-03-24 16:38:58 +0800 | [diff] [blame] | 265 | reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 266 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 267 | }, |
| 268 | { |
| 269 | "vkDestroyInstance", |
| 270 | ProcHook::INSTANCE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 271 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | ff4a6c7 | 2016-03-24 16:05:56 +0800 | [diff] [blame] | 272 | reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 273 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 274 | }, |
| 275 | { |
| 276 | "vkDestroySurfaceKHR", |
| 277 | ProcHook::INSTANCE, |
| 278 | ProcHook::KHR_surface, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 279 | reinterpret_cast<PFN_vkVoidFunction>(DestroySurfaceKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 280 | nullptr, |
| 281 | }, |
| 282 | { |
| 283 | "vkDestroySwapchainKHR", |
| 284 | ProcHook::DEVICE, |
| 285 | ProcHook::KHR_swapchain, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 286 | reinterpret_cast<PFN_vkVoidFunction>(DestroySwapchainKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 287 | reinterpret_cast<PFN_vkVoidFunction>(checkedDestroySwapchainKHR), |
| 288 | }, |
| 289 | { |
| 290 | "vkEnumerateDeviceExtensionProperties", |
| 291 | ProcHook::INSTANCE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 292 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | 01cf305 | 2016-03-24 16:16:21 +0800 | [diff] [blame] | 293 | reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 294 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 295 | }, |
| 296 | { |
| 297 | "vkEnumerateInstanceExtensionProperties", |
| 298 | ProcHook::GLOBAL, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 299 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 300 | reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties), |
| 301 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 302 | }, |
| 303 | { |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 304 | "vkEnumeratePhysicalDeviceGroups", |
| 305 | ProcHook::INSTANCE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 306 | ProcHook::EXTENSION_CORE_1_1, |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 307 | reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDeviceGroups), |
| 308 | nullptr, |
| 309 | }, |
| 310 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 311 | "vkEnumeratePhysicalDevices", |
| 312 | ProcHook::INSTANCE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 313 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | ff4a6c7 | 2016-03-24 16:05:56 +0800 | [diff] [blame] | 314 | reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 315 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 316 | }, |
| 317 | { |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 318 | "vkGetDeviceGroupPresentCapabilitiesKHR", |
| 319 | ProcHook::DEVICE, |
| 320 | ProcHook::KHR_swapchain, |
| 321 | reinterpret_cast<PFN_vkVoidFunction>(GetDeviceGroupPresentCapabilitiesKHR), |
| 322 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetDeviceGroupPresentCapabilitiesKHR), |
| 323 | }, |
| 324 | { |
| 325 | "vkGetDeviceGroupSurfacePresentModesKHR", |
| 326 | ProcHook::DEVICE, |
| 327 | ProcHook::KHR_swapchain, |
| 328 | reinterpret_cast<PFN_vkVoidFunction>(GetDeviceGroupSurfacePresentModesKHR), |
| 329 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetDeviceGroupSurfacePresentModesKHR), |
| 330 | }, |
| 331 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 332 | "vkGetDeviceProcAddr", |
| 333 | ProcHook::DEVICE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 334 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 335 | reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr), |
| 336 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 337 | }, |
| 338 | { |
| 339 | "vkGetDeviceQueue", |
| 340 | ProcHook::DEVICE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 341 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | ba0be41 | 2016-03-24 16:24:40 +0800 | [diff] [blame] | 342 | reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 343 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 344 | }, |
| 345 | { |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 346 | "vkGetDeviceQueue2", |
| 347 | ProcHook::DEVICE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 348 | ProcHook::EXTENSION_CORE_1_1, |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 349 | reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue2), |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 350 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetDeviceQueue2), |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 351 | }, |
| 352 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 353 | "vkGetInstanceProcAddr", |
| 354 | ProcHook::INSTANCE, |
Yiwei Zhang | ec6c505 | 2019-10-17 15:53:00 -0700 | [diff] [blame] | 355 | ProcHook::EXTENSION_CORE_1_0, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 356 | reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr), |
| 357 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 358 | }, |
| 359 | { |
Ian Elliott | 4c8bb2a | 2016-12-29 11:07:26 -0700 | [diff] [blame] | 360 | "vkGetPastPresentationTimingGOOGLE", |
| 361 | ProcHook::DEVICE, |
| 362 | ProcHook::GOOGLE_display_timing, |
| 363 | reinterpret_cast<PFN_vkVoidFunction>(GetPastPresentationTimingGOOGLE), |
| 364 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetPastPresentationTimingGOOGLE), |
| 365 | }, |
| 366 | { |
Daniel Koch | f25f5bb | 2017-10-05 00:26:58 -0400 | [diff] [blame] | 367 | "vkGetPhysicalDevicePresentRectanglesKHR", |
| 368 | ProcHook::INSTANCE, |
| 369 | ProcHook::KHR_swapchain, |
| 370 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDevicePresentRectanglesKHR), |
| 371 | nullptr, |
| 372 | }, |
| 373 | { |
Chris Forbes | 2452cf7 | 2017-03-16 16:30:17 +1300 | [diff] [blame] | 374 | "vkGetPhysicalDeviceSurfaceCapabilities2KHR", |
| 375 | ProcHook::INSTANCE, |
| 376 | ProcHook::KHR_get_surface_capabilities2, |
| 377 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceCapabilities2KHR), |
| 378 | nullptr, |
| 379 | }, |
| 380 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 381 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR", |
| 382 | ProcHook::INSTANCE, |
| 383 | ProcHook::KHR_surface, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 384 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceCapabilitiesKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 385 | nullptr, |
| 386 | }, |
| 387 | { |
Chris Forbes | 2452cf7 | 2017-03-16 16:30:17 +1300 | [diff] [blame] | 388 | "vkGetPhysicalDeviceSurfaceFormats2KHR", |
| 389 | ProcHook::INSTANCE, |
| 390 | ProcHook::KHR_get_surface_capabilities2, |
| 391 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceFormats2KHR), |
| 392 | nullptr, |
| 393 | }, |
| 394 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 395 | "vkGetPhysicalDeviceSurfaceFormatsKHR", |
| 396 | ProcHook::INSTANCE, |
| 397 | ProcHook::KHR_surface, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 398 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceFormatsKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 399 | nullptr, |
| 400 | }, |
| 401 | { |
| 402 | "vkGetPhysicalDeviceSurfacePresentModesKHR", |
| 403 | ProcHook::INSTANCE, |
| 404 | ProcHook::KHR_surface, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 405 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfacePresentModesKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 406 | nullptr, |
| 407 | }, |
| 408 | { |
| 409 | "vkGetPhysicalDeviceSurfaceSupportKHR", |
| 410 | ProcHook::INSTANCE, |
| 411 | ProcHook::KHR_surface, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 412 | reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceSupportKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 413 | nullptr, |
| 414 | }, |
| 415 | { |
Ian Elliott | 4c8bb2a | 2016-12-29 11:07:26 -0700 | [diff] [blame] | 416 | "vkGetRefreshCycleDurationGOOGLE", |
| 417 | ProcHook::DEVICE, |
| 418 | ProcHook::GOOGLE_display_timing, |
| 419 | reinterpret_cast<PFN_vkVoidFunction>(GetRefreshCycleDurationGOOGLE), |
| 420 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetRefreshCycleDurationGOOGLE), |
| 421 | }, |
| 422 | { |
Chris Forbes | 8e4438b | 2016-12-07 16:26:49 +1300 | [diff] [blame] | 423 | "vkGetSwapchainGrallocUsage2ANDROID", |
| 424 | ProcHook::DEVICE, |
| 425 | ProcHook::ANDROID_native_buffer, |
| 426 | nullptr, |
| 427 | nullptr, |
| 428 | }, |
| 429 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 430 | "vkGetSwapchainGrallocUsageANDROID", |
| 431 | ProcHook::DEVICE, |
| 432 | ProcHook::ANDROID_native_buffer, |
| 433 | nullptr, |
| 434 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 435 | }, |
| 436 | { |
| 437 | "vkGetSwapchainImagesKHR", |
| 438 | ProcHook::DEVICE, |
| 439 | ProcHook::KHR_swapchain, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 440 | reinterpret_cast<PFN_vkVoidFunction>(GetSwapchainImagesKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 441 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetSwapchainImagesKHR), |
| 442 | }, |
| 443 | { |
Chris Forbes | 0f2ac2e | 2017-01-18 13:33:53 +1300 | [diff] [blame] | 444 | "vkGetSwapchainStatusKHR", |
| 445 | ProcHook::DEVICE, |
Chris Forbes | 1d5f68c | 2017-01-31 10:17:01 +1300 | [diff] [blame] | 446 | ProcHook::KHR_shared_presentable_image, |
Chris Forbes | 0f2ac2e | 2017-01-18 13:33:53 +1300 | [diff] [blame] | 447 | reinterpret_cast<PFN_vkVoidFunction>(GetSwapchainStatusKHR), |
| 448 | reinterpret_cast<PFN_vkVoidFunction>(checkedGetSwapchainStatusKHR), |
| 449 | }, |
| 450 | { |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 451 | "vkQueuePresentKHR", |
| 452 | ProcHook::DEVICE, |
| 453 | ProcHook::KHR_swapchain, |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame] | 454 | reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR), |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 455 | reinterpret_cast<PFN_vkVoidFunction>(checkedQueuePresentKHR), |
| 456 | }, |
| 457 | { |
| 458 | "vkQueueSignalReleaseImageANDROID", |
| 459 | ProcHook::DEVICE, |
| 460 | ProcHook::ANDROID_native_buffer, |
| 461 | nullptr, |
| 462 | nullptr, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 463 | }, |
Courtney Goeltzenleuchter | d634c48 | 2017-01-05 15:55:31 -0700 | [diff] [blame] | 464 | { |
| 465 | "vkSetHdrMetadataEXT", |
| 466 | ProcHook::DEVICE, |
| 467 | ProcHook::EXT_hdr_metadata, |
| 468 | reinterpret_cast<PFN_vkVoidFunction>(SetHdrMetadataEXT), |
| 469 | reinterpret_cast<PFN_vkVoidFunction>(checkedSetHdrMetadataEXT), |
| 470 | }, |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 471 | // clang-format on |
| 472 | }; |
| 473 | |
Chris Forbes | e2d3ee1 | 2017-03-16 16:10:15 +1300 | [diff] [blame] | 474 | } // namespace |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 475 | |
| 476 | const ProcHook* GetProcHook(const char* name) { |
| 477 | const auto& begin = g_proc_hooks; |
| 478 | const auto& end = |
| 479 | g_proc_hooks + sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]); |
| 480 | const auto hook = std::lower_bound( |
| 481 | begin, end, name, |
| 482 | [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; }); |
| 483 | return (hook < end && strcmp(hook->name, name) == 0) ? hook : nullptr; |
| 484 | } |
| 485 | |
| 486 | ProcHook::Extension GetProcHookExtension(const char* name) { |
| 487 | // clang-format off |
| 488 | if (strcmp(name, "VK_ANDROID_native_buffer") == 0) return ProcHook::ANDROID_native_buffer; |
| 489 | if (strcmp(name, "VK_EXT_debug_report") == 0) return ProcHook::EXT_debug_report; |
Courtney Goeltzenleuchter | d634c48 | 2017-01-05 15:55:31 -0700 | [diff] [blame] | 490 | if (strcmp(name, "VK_EXT_hdr_metadata") == 0) return ProcHook::EXT_hdr_metadata; |
Courtney Goeltzenleuchter | e278daf | 2017-02-02 16:54:57 -0700 | [diff] [blame] | 491 | if (strcmp(name, "VK_EXT_swapchain_colorspace") == 0) return ProcHook::EXT_swapchain_colorspace; |
Courtney Goeltzenleuchter | d634c48 | 2017-01-05 15:55:31 -0700 | [diff] [blame] | 492 | if (strcmp(name, "VK_GOOGLE_display_timing") == 0) return ProcHook::GOOGLE_display_timing; |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 493 | if (strcmp(name, "VK_KHR_android_surface") == 0) return ProcHook::KHR_android_surface; |
Chris Forbes | 4885371 | 2017-01-12 14:09:33 +1300 | [diff] [blame] | 494 | if (strcmp(name, "VK_KHR_incremental_present") == 0) return ProcHook::KHR_incremental_present; |
Courtney Goeltzenleuchter | e278daf | 2017-02-02 16:54:57 -0700 | [diff] [blame] | 495 | if (strcmp(name, "VK_KHR_shared_presentable_image") == 0) return ProcHook::KHR_shared_presentable_image; |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 496 | if (strcmp(name, "VK_KHR_surface") == 0) return ProcHook::KHR_surface; |
| 497 | if (strcmp(name, "VK_KHR_swapchain") == 0) return ProcHook::KHR_swapchain; |
Chris Forbes | 2452cf7 | 2017-03-16 16:30:17 +1300 | [diff] [blame] | 498 | if (strcmp(name, "VK_KHR_get_surface_capabilities2") == 0) return ProcHook::KHR_get_surface_capabilities2; |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 499 | if (strcmp(name, "VK_KHR_get_physical_device_properties2") == 0) return ProcHook::KHR_get_physical_device_properties2; |
Jesse Hall | a8d367a | 2018-01-18 15:40:46 -0800 | [diff] [blame] | 500 | if (strcmp(name, "VK_ANDROID_external_memory_android_hardware_buffer") == 0) return ProcHook::ANDROID_external_memory_android_hardware_buffer; |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 501 | if (strcmp(name, "VK_KHR_bind_memory2") == 0) return ProcHook::KHR_bind_memory2; |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 502 | // clang-format on |
| 503 | return ProcHook::EXTENSION_UNKNOWN; |
| 504 | } |
| 505 | |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 506 | #define UNLIKELY(expr) __builtin_expect((expr), 0) |
| 507 | |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 508 | #define INIT_PROC(required, obj, proc) \ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 509 | do { \ |
| 510 | data.driver.proc = \ |
| 511 | reinterpret_cast<PFN_vk##proc>(get_proc(obj, "vk" #proc)); \ |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 512 | if (UNLIKELY(required && !data.driver.proc)) { \ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 513 | ALOGE("missing " #obj " proc: vk" #proc); \ |
| 514 | success = false; \ |
| 515 | } \ |
| 516 | } while (0) |
| 517 | |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 518 | #define INIT_PROC_EXT(ext, required, obj, proc) \ |
| 519 | do { \ |
| 520 | if (extensions[ProcHook::ext]) \ |
| 521 | INIT_PROC(required, obj, proc); \ |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 522 | } while (0) |
| 523 | |
Chia-I Wu | cbe07ef | 2016-04-13 15:01:00 +0800 | [diff] [blame] | 524 | bool InitDriverTable(VkInstance instance, |
| 525 | PFN_vkGetInstanceProcAddr get_proc, |
| 526 | const std::bitset<ProcHook::EXTENSION_COUNT>& extensions) { |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 527 | auto& data = GetData(instance); |
| 528 | bool success = true; |
| 529 | |
| 530 | // clang-format off |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 531 | INIT_PROC(true, instance, DestroyInstance); |
| 532 | INIT_PROC(true, instance, EnumeratePhysicalDevices); |
| 533 | INIT_PROC(true, instance, GetInstanceProcAddr); |
Jesse Hall | 85bb0c5 | 2017-02-09 22:13:02 -0800 | [diff] [blame] | 534 | INIT_PROC(true, instance, GetPhysicalDeviceProperties); |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 535 | INIT_PROC(true, instance, CreateDevice); |
| 536 | INIT_PROC(true, instance, EnumerateDeviceExtensionProperties); |
Ian Elliott | cd8ad33 | 2017-10-13 09:21:12 -0600 | [diff] [blame] | 537 | INIT_PROC(false, instance, EnumeratePhysicalDeviceGroups); |
Yiwei Zhang | 922b1e3 | 2018-03-13 17:12:11 -0700 | [diff] [blame] | 538 | INIT_PROC(false, instance, GetPhysicalDeviceProperties2); |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 539 | INIT_PROC_EXT(EXT_debug_report, true, instance, CreateDebugReportCallbackEXT); |
| 540 | INIT_PROC_EXT(EXT_debug_report, true, instance, DestroyDebugReportCallbackEXT); |
| 541 | INIT_PROC_EXT(EXT_debug_report, true, instance, DebugReportMessageEXT); |
Chris Forbes | 6aa30db | 2017-02-20 17:12:53 +1300 | [diff] [blame] | 542 | INIT_PROC_EXT(KHR_get_physical_device_properties2, true, instance, GetPhysicalDeviceProperties2KHR); |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 543 | // clang-format on |
| 544 | |
| 545 | return success; |
| 546 | } |
| 547 | |
Chia-I Wu | cbe07ef | 2016-04-13 15:01:00 +0800 | [diff] [blame] | 548 | bool InitDriverTable(VkDevice dev, |
| 549 | PFN_vkGetDeviceProcAddr get_proc, |
| 550 | const std::bitset<ProcHook::EXTENSION_COUNT>& extensions) { |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 551 | auto& data = GetData(dev); |
| 552 | bool success = true; |
| 553 | |
| 554 | // clang-format off |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 555 | INIT_PROC(true, dev, GetDeviceProcAddr); |
| 556 | INIT_PROC(true, dev, DestroyDevice); |
| 557 | INIT_PROC(true, dev, GetDeviceQueue); |
| 558 | INIT_PROC(true, dev, CreateImage); |
| 559 | INIT_PROC(true, dev, DestroyImage); |
| 560 | INIT_PROC(true, dev, AllocateCommandBuffers); |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 561 | INIT_PROC(false, dev, BindImageMemory2); |
Ian Elliott | cd8ad33 | 2017-10-13 09:21:12 -0600 | [diff] [blame] | 562 | INIT_PROC(false, dev, GetDeviceQueue2); |
Chris Forbes | d827791 | 2017-02-10 14:59:59 +1300 | [diff] [blame] | 563 | INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID); |
Chris Forbes | 5948b3e | 2016-12-23 13:49:53 +1300 | [diff] [blame] | 564 | INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID); |
| 565 | INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID); |
| 566 | INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID); |
Yiwei Zhang | 2314310 | 2019-04-10 18:24:05 -0700 | [diff] [blame] | 567 | INIT_PROC_EXT(KHR_bind_memory2, true, dev, BindImageMemory2KHR); |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 568 | // clang-format on |
| 569 | |
| 570 | return success; |
| 571 | } |
| 572 | |
Chia-I Wu | eb7db12 | 2016-03-24 09:11:06 +0800 | [diff] [blame] | 573 | } // namespace driver |
| 574 | } // namespace vulkan |
| 575 | |
| 576 | // clang-format on |