From 4953006673c8a85e5f257864f83c586e49a66229 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 28 Apr 2016 15:16:59 +0800 Subject: [PATCH] swapchain: improve GetInstanceProcAddr Handle device commands as well. Move handling of interface functions to v0's vkGetInstanceProcAddr. --- layers/swapchain.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index b7dfad1..2da7b62 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -2168,24 +2168,22 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); + if (!proc) + proc = intercept_core_device_command(funcName); + if (!proc) + proc = intercept_khr_swapchain_command(funcName, VK_NULL_HANDLE); if (proc) return proc; - if (instance == VK_NULL_HANDLE) { - return NULL; - } - - PFN_vkVoidFunction addr; + assert(instance); layer_data *my_data; my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; - addr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); - if (addr) { - return addr; - } - proc = intercept_khr_surface_command(funcName, instance); + proc = debug_report_get_instance_proc_addr(my_data->report_data, funcName); + if (!proc) + proc = intercept_khr_surface_command(funcName, instance); if (proc) return proc; @@ -2205,13 +2203,15 @@ intercept_core_instance_command(const char *name) { { "vkDestroyInstance", reinterpret_cast(DestroyInstance) }, { "vkCreateDevice", reinterpret_cast(CreateDevice) }, { "vkEnumeratePhysicalDevices", reinterpret_cast(EnumeratePhysicalDevices) }, - { "vkEnumerateInstanceLayerProperties", reinterpret_cast(vkEnumerateInstanceLayerProperties) }, - { "vkEnumerateDeviceLayerProperties", reinterpret_cast(vkEnumerateDeviceLayerProperties) }, - { "vkEnumerateInstanceExtensionProperties", reinterpret_cast(vkEnumerateInstanceExtensionProperties) }, { "vkEnumerateDeviceExtensionProperties", reinterpret_cast(EnumerateDeviceExtensionProperties) }, { "vkGetPhysicalDeviceQueueFamilyProperties", reinterpret_cast(GetPhysicalDeviceQueueFamilyProperties) }, }; + // we should never be queried for these commands + assert(strcmp(name, "vkEnumerateInstanceLayerProperties") && + strcmp(name, "vkEnumerateInstanceExtensionProperties") && + strcmp(name, "vkEnumerateDeviceLayerProperties")); + for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { if (!strcmp(core_instance_commands[i].name, name)) return core_instance_commands[i].proc; @@ -2359,5 +2359,14 @@ VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkD } VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { + if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) + return reinterpret_cast(vkEnumerateInstanceLayerProperties); + if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) + return reinterpret_cast(vkEnumerateDeviceLayerProperties); + if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) + return reinterpret_cast(vkEnumerateInstanceExtensionProperties); + if (!strcmp(funcName, "vkGetInstanceProcAddr")) + return reinterpret_cast(vkGetInstanceProcAddr); + return swapchain::GetInstanceProcAddr(instance, funcName); } -- 2.7.4