vulkan: fix vkGet*ProcAddr for un-enabled extensions
vulkan::api::InitDispatchTable no longer queries for non-enabled WSI
functions. We could now return NULL instead of ProcHook::disabled_proc.
This also matches what the spec says.
Bug: 28173232
Change-Id: I05c45303025d25e49f75c18a912fc4cc2b13979f
diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp
index 59f3200..5bd2159 100644
--- a/vulkan/libvulkan/driver_gen.cpp
+++ b/vulkan/libvulkan/driver_gen.cpp
@@ -29,90 +29,48 @@
// clang-format off
-VKAPI_ATTR void disabledDestroySurfaceKHR(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks*) {
- ALOGE("VK_KHR_surface not enabled. vkDestroySurfaceKHR not executed.");
-}
-
-VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice, uint32_t, VkSurfaceKHR, VkBool32*) {
- ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfaceSupportKHR not executed.");
- return VK_SUCCESS;
-}
-
-VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice, VkSurfaceKHR, VkSurfaceCapabilitiesKHR*) {
- ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed.");
- return VK_SUCCESS;
-}
-
-VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice, VkSurfaceKHR, uint32_t*, VkSurfaceFormatKHR*) {
- ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfaceFormatsKHR not executed.");
- return VK_SUCCESS;
-}
-
-VKAPI_ATTR VkResult disabledGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice, VkSurfaceKHR, uint32_t*, VkPresentModeKHR*) {
- ALOGE("VK_KHR_surface not enabled. vkGetPhysicalDeviceSurfacePresentModesKHR not executed.");
- return VK_SUCCESS;
-}
-
-VKAPI_ATTR VkResult disabledCreateSwapchainKHR(VkDevice, const VkSwapchainCreateInfoKHR*, const VkAllocationCallbacks*, VkSwapchainKHR*) {
- ALOGE("VK_KHR_swapchain not enabled. vkCreateSwapchainKHR not executed.");
- return VK_SUCCESS;
-}
-
VKAPI_ATTR VkResult checkedCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) {
- return (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) ? CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain) : disabledCreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
-}
-
-VKAPI_ATTR void disabledDestroySwapchainKHR(VkDevice, VkSwapchainKHR, const VkAllocationCallbacks*) {
- ALOGE("VK_KHR_swapchain not enabled. vkDestroySwapchainKHR not executed.");
+ if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
+ return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
+ } else {
+ ALOGE("VK_KHR_swapchain not enabled. vkCreateSwapchainKHR not executed.");
+ return VK_SUCCESS;
+ }
}
VKAPI_ATTR void checkedDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator) {
- (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) ? DestroySwapchainKHR(device, swapchain, pAllocator) : disabledDestroySwapchainKHR(device, swapchain, pAllocator);
-}
-
-VKAPI_ATTR VkResult disabledGetSwapchainImagesKHR(VkDevice, VkSwapchainKHR, uint32_t*, VkImage*) {
- ALOGE("VK_KHR_swapchain not enabled. vkGetSwapchainImagesKHR not executed.");
- return VK_SUCCESS;
+ if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
+ DestroySwapchainKHR(device, swapchain, pAllocator);
+ } else {
+ ALOGE("VK_KHR_swapchain not enabled. vkDestroySwapchainKHR not executed.");
+ }
}
VKAPI_ATTR VkResult checkedGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) {
- return (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) ? GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages) : disabledGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
-}
-
-VKAPI_ATTR VkResult disabledAcquireNextImageKHR(VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence, uint32_t*) {
- ALOGE("VK_KHR_swapchain not enabled. vkAcquireNextImageKHR not executed.");
- return VK_SUCCESS;
+ if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
+ return GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
+ } else {
+ ALOGE("VK_KHR_swapchain not enabled. vkGetSwapchainImagesKHR not executed.");
+ return VK_SUCCESS;
+ }
}
VKAPI_ATTR VkResult checkedAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex) {
- return (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) ? AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex) : disabledAcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex);
-}
-
-VKAPI_ATTR VkResult disabledQueuePresentKHR(VkQueue, const VkPresentInfoKHR*) {
- ALOGE("VK_KHR_swapchain not enabled. vkQueuePresentKHR not executed.");
- return VK_SUCCESS;
+ if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
+ return AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex);
+ } else {
+ ALOGE("VK_KHR_swapchain not enabled. vkAcquireNextImageKHR not executed.");
+ return VK_SUCCESS;
+ }
}
VKAPI_ATTR VkResult checkedQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo) {
- return (GetData(queue).hook_extensions[ProcHook::KHR_swapchain]) ? QueuePresentKHR(queue, pPresentInfo) : disabledQueuePresentKHR(queue, pPresentInfo);
-}
-
-VKAPI_ATTR VkResult disabledCreateAndroidSurfaceKHR(VkInstance, const VkAndroidSurfaceCreateInfoKHR*, const VkAllocationCallbacks*, VkSurfaceKHR*) {
- ALOGE("VK_KHR_android_surface not enabled. vkCreateAndroidSurfaceKHR not executed.");
- return VK_SUCCESS;
-}
-
-VKAPI_ATTR VkResult disabledCreateDebugReportCallbackEXT(VkInstance, const VkDebugReportCallbackCreateInfoEXT*, const VkAllocationCallbacks*, VkDebugReportCallbackEXT*) {
- ALOGE("VK_EXT_debug_report not enabled. vkCreateDebugReportCallbackEXT not executed.");
- return VK_SUCCESS;
-}
-
-VKAPI_ATTR void disabledDestroyDebugReportCallbackEXT(VkInstance, VkDebugReportCallbackEXT, const VkAllocationCallbacks*) {
- ALOGE("VK_EXT_debug_report not enabled. vkDestroyDebugReportCallbackEXT not executed.");
-}
-
-VKAPI_ATTR void disabledDebugReportMessageEXT(VkInstance, VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char*, const char*) {
- ALOGE("VK_EXT_debug_report not enabled. vkDebugReportMessageEXT not executed.");
+ if (GetData(queue).hook_extensions[ProcHook::KHR_swapchain]) {
+ return QueuePresentKHR(queue, pPresentInfo);
+ } else {
+ ALOGE("VK_KHR_swapchain not enabled. vkQueuePresentKHR not executed.");
+ return VK_SUCCESS;
+ }
}
// clang-format on
@@ -125,14 +83,12 @@
ProcHook::ANDROID_native_buffer,
nullptr,
nullptr,
- nullptr,
},
{
"vkAcquireNextImageKHR",
ProcHook::DEVICE,
ProcHook::KHR_swapchain,
reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledAcquireNextImageKHR),
reinterpret_cast<PFN_vkVoidFunction>(checkedAcquireNextImageKHR),
},
{
@@ -141,14 +97,12 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(AllocateCommandBuffers),
nullptr,
- nullptr,
},
{
"vkCreateAndroidSurfaceKHR",
ProcHook::INSTANCE,
ProcHook::KHR_android_surface,
reinterpret_cast<PFN_vkVoidFunction>(CreateAndroidSurfaceKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledCreateAndroidSurfaceKHR),
nullptr,
},
{
@@ -156,7 +110,6 @@
ProcHook::INSTANCE,
ProcHook::EXT_debug_report,
reinterpret_cast<PFN_vkVoidFunction>(CreateDebugReportCallbackEXT),
- reinterpret_cast<PFN_vkVoidFunction>(disabledCreateDebugReportCallbackEXT),
nullptr,
},
{
@@ -165,7 +118,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(CreateDevice),
nullptr,
- nullptr,
},
{
"vkCreateInstance",
@@ -173,14 +125,12 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(CreateInstance),
nullptr,
- nullptr,
},
{
"vkCreateSwapchainKHR",
ProcHook::DEVICE,
ProcHook::KHR_swapchain,
reinterpret_cast<PFN_vkVoidFunction>(CreateSwapchainKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledCreateSwapchainKHR),
reinterpret_cast<PFN_vkVoidFunction>(checkedCreateSwapchainKHR),
},
{
@@ -188,7 +138,6 @@
ProcHook::INSTANCE,
ProcHook::EXT_debug_report,
reinterpret_cast<PFN_vkVoidFunction>(DebugReportMessageEXT),
- reinterpret_cast<PFN_vkVoidFunction>(disabledDebugReportMessageEXT),
nullptr,
},
{
@@ -196,7 +145,6 @@
ProcHook::INSTANCE,
ProcHook::EXT_debug_report,
reinterpret_cast<PFN_vkVoidFunction>(DestroyDebugReportCallbackEXT),
- reinterpret_cast<PFN_vkVoidFunction>(disabledDestroyDebugReportCallbackEXT),
nullptr,
},
{
@@ -205,7 +153,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice),
nullptr,
- nullptr,
},
{
"vkDestroyInstance",
@@ -213,14 +160,12 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance),
nullptr,
- nullptr,
},
{
"vkDestroySurfaceKHR",
ProcHook::INSTANCE,
ProcHook::KHR_surface,
reinterpret_cast<PFN_vkVoidFunction>(DestroySurfaceKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledDestroySurfaceKHR),
nullptr,
},
{
@@ -228,7 +173,6 @@
ProcHook::DEVICE,
ProcHook::KHR_swapchain,
reinterpret_cast<PFN_vkVoidFunction>(DestroySwapchainKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledDestroySwapchainKHR),
reinterpret_cast<PFN_vkVoidFunction>(checkedDestroySwapchainKHR),
},
{
@@ -237,7 +181,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties),
nullptr,
- nullptr,
},
{
"vkEnumerateInstanceExtensionProperties",
@@ -245,7 +188,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties),
nullptr,
- nullptr,
},
{
"vkEnumeratePhysicalDevices",
@@ -253,7 +195,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices),
nullptr,
- nullptr,
},
{
"vkGetDeviceProcAddr",
@@ -261,7 +202,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr),
nullptr,
- nullptr,
},
{
"vkGetDeviceQueue",
@@ -269,7 +209,6 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue),
nullptr,
- nullptr,
},
{
"vkGetInstanceProcAddr",
@@ -277,14 +216,12 @@
ProcHook::EXTENSION_CORE,
reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr),
nullptr,
- nullptr,
},
{
"vkGetPhysicalDeviceSurfaceCapabilitiesKHR",
ProcHook::INSTANCE,
ProcHook::KHR_surface,
reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceCapabilitiesKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledGetPhysicalDeviceSurfaceCapabilitiesKHR),
nullptr,
},
{
@@ -292,7 +229,6 @@
ProcHook::INSTANCE,
ProcHook::KHR_surface,
reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceFormatsKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledGetPhysicalDeviceSurfaceFormatsKHR),
nullptr,
},
{
@@ -300,7 +236,6 @@
ProcHook::INSTANCE,
ProcHook::KHR_surface,
reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfacePresentModesKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledGetPhysicalDeviceSurfacePresentModesKHR),
nullptr,
},
{
@@ -308,7 +243,6 @@
ProcHook::INSTANCE,
ProcHook::KHR_surface,
reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceSurfaceSupportKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledGetPhysicalDeviceSurfaceSupportKHR),
nullptr,
},
{
@@ -317,14 +251,12 @@
ProcHook::ANDROID_native_buffer,
nullptr,
nullptr,
- nullptr,
},
{
"vkGetSwapchainImagesKHR",
ProcHook::DEVICE,
ProcHook::KHR_swapchain,
reinterpret_cast<PFN_vkVoidFunction>(GetSwapchainImagesKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledGetSwapchainImagesKHR),
reinterpret_cast<PFN_vkVoidFunction>(checkedGetSwapchainImagesKHR),
},
{
@@ -332,7 +264,6 @@
ProcHook::DEVICE,
ProcHook::KHR_swapchain,
reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR),
- reinterpret_cast<PFN_vkVoidFunction>(disabledQueuePresentKHR),
reinterpret_cast<PFN_vkVoidFunction>(checkedQueuePresentKHR),
},
{
@@ -341,7 +272,6 @@
ProcHook::ANDROID_native_buffer,
nullptr,
nullptr,
- nullptr,
},
// clang-format on
};