From 66e2cb5a22db4bf65a3f109c5a0391383b632694 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 6 May 2016 11:51:11 +0800 Subject: [PATCH] core_validation: add intercept_khr_swapchain_command It returns the function pointers for all intercepted VK_KHR_swapchain commands. Call intercept_khr_swapchain_command from GetDeviceProcAddr. --- layers/core_validation.cpp | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 473efeb..ae5edf5 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -9755,6 +9755,9 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevi static PFN_vkVoidFunction intercept_core_device_command(const char *name); +static PFN_vkVoidFunction +intercept_khr_swapchain_command(const char *name, VkDevice dev); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice dev, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_device_command(funcName); if (proc) @@ -9762,22 +9765,13 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice dev, const c assert(dev); + proc = intercept_khr_swapchain_command(funcName, dev); + if (proc) + return proc; + layer_data *dev_data; dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); - if (dev_data->device_extensions.wsi_enabled) { - if (!strcmp(funcName, "vkCreateSwapchainKHR")) - return (PFN_vkVoidFunction)CreateSwapchainKHR; - if (!strcmp(funcName, "vkDestroySwapchainKHR")) - return (PFN_vkVoidFunction)DestroySwapchainKHR; - if (!strcmp(funcName, "vkGetSwapchainImagesKHR")) - return (PFN_vkVoidFunction)GetSwapchainImagesKHR; - if (!strcmp(funcName, "vkAcquireNextImageKHR")) - return (PFN_vkVoidFunction)AcquireNextImageKHR; - if (!strcmp(funcName, "vkQueuePresentKHR")) - return (PFN_vkVoidFunction)QueuePresentKHR; - } - VkLayerDispatchTable *pTable = dev_data->device_dispatch_table; { if (pTable->GetDeviceProcAddr == NULL) @@ -9958,6 +9952,31 @@ intercept_core_device_command(const char *name) { return nullptr; } +static PFN_vkVoidFunction +intercept_khr_swapchain_command(const char *name, VkDevice dev) { + static const struct { + const char *name; + PFN_vkVoidFunction proc; + } khr_swapchain_commands[] = { + { "vkCreateSwapchainKHR", reinterpret_cast(CreateSwapchainKHR) }, + { "vkDestroySwapchainKHR", reinterpret_cast(DestroySwapchainKHR) }, + { "vkGetSwapchainImagesKHR", reinterpret_cast(GetSwapchainImagesKHR) }, + { "vkAcquireNextImageKHR", reinterpret_cast(AcquireNextImageKHR) }, + { "vkQueuePresentKHR", reinterpret_cast(QueuePresentKHR) }, + }; + + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); + if (!dev_data->device_extensions.wsi_enabled) + return nullptr; + + for (size_t i = 0; i < ARRAY_SIZE(khr_swapchain_commands); i++) { + if (!strcmp(khr_swapchain_commands[i].name, name)) + return khr_swapchain_commands[i].proc; + } + + return nullptr; +} + } // namespace core_validation // vk_layer_logging.h expects these to be defined -- 2.7.4