From 79c709c11f20aa817527d629ae01d4856651623f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 28 Apr 2016 15:16:59 +0800 Subject: [PATCH] image: improve GetInstanceProcAddr Handle device commands as well. Move handling of interface functions to v0's vkGetInstanceProcAddr. --- layers/image.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/layers/image.cpp b/layers/image.cpp index ded6f17..312bb53 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -1281,18 +1281,17 @@ 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) return proc; - if (instance == NULL) { - return NULL; - } - + assert(instance); layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); - PFN_vkVoidFunction fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); - if (fptr) - return fptr; + proc = debug_report_get_instance_proc_addr(my_data->report_data, funcName); + if (proc) + return proc; VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; if (pTable->GetInstanceProcAddr == NULL) @@ -1310,13 +1309,15 @@ intercept_core_instance_command(const char *name) { { "vkCreateInstance", reinterpret_cast(CreateInstance) }, { "vkDestroyInstance", reinterpret_cast(DestroyInstance) }, { "vkCreateDevice", reinterpret_cast(CreateDevice) }, - { "vkEnumerateInstanceLayerProperties", reinterpret_cast(vkEnumerateInstanceLayerProperties) }, - { "vkEnumerateInstanceExtensionProperties", reinterpret_cast(vkEnumerateInstanceExtensionProperties) }, - { "vkEnumerateDeviceLayerProperties", reinterpret_cast(vkEnumerateDeviceLayerProperties) }, { "vkEnumerateDeviceExtensionProperties", reinterpret_cast(EnumerateDeviceExtensionProperties) }, { "vkGetPhysicalDeviceProperties", reinterpret_cast(GetPhysicalDeviceProperties) }, }; + // 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; @@ -1409,5 +1410,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, "vkEnumerateInstanceExtensionProperties")) + return reinterpret_cast(vkEnumerateInstanceExtensionProperties); + if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) + return reinterpret_cast(vkEnumerateDeviceLayerProperties); + if (!strcmp(funcName, "vkGetInstanceProcAddr")) + return reinterpret_cast(vkGetInstanceProcAddr); + return image::GetInstanceProcAddr(instance, funcName); } -- 2.7.4