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