From 453507b43fd2949984cbb07935a760b62f2af8c0 Mon Sep 17 00:00:00 2001 From: Mike Schuchardt Date: Fri, 10 Mar 2017 14:59:10 -0700 Subject: layers: swapchain post call record refactor Change-Id: Id4063c82d9e592f982c59fb12c6d9f06a9e7b35a --- layers/swapchain.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 112a3333..15a8e4b0 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -249,33 +249,38 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati layer_data_map.erase(key); } -VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, - uint32_t *pQueueFamilyPropertyCount, - VkQueueFamilyProperties *pQueueFamilyProperties) { - layer_data *my_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); - - // Call down the call chain: - my_data->instance_dispatch_table->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, - pQueueFamilyProperties); - +static void PostCallRecordGetPhysicalDeviceQueueFamilyProperties(layer_data *dev_data, VkPhysicalDevice physical_device, + uint32_t *qfp_count, VkQueueFamilyProperties *qfp) { // Record the result of this query: std::lock_guard lock(global_lock); - SwpPhysicalDevice *pPhysicalDevice = NULL; + SwpPhysicalDevice *phy_data = NULL; { - auto it = my_data->physicalDeviceMap.find(physicalDevice); - pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; + auto it = dev_data->physicalDeviceMap.find(physical_device); + phy_data = (it == dev_data->physicalDeviceMap.end()) ? NULL : &it->second; } // Note: for poorly-written applications (e.g. that don't call this command // twice, the first time with pQueueFamilyProperties set to NULL, and the // second time with a non-NULL pQueueFamilyProperties and with the same // count as returned the first time), record the count when - // pQueueFamilyProperties is non-NULL: - if (pPhysicalDevice && pQueueFamilyPropertyCount && pQueueFamilyProperties) { - pPhysicalDevice->gotQueueFamilyPropertyCount = true; - pPhysicalDevice->numOfQueueFamilies = *pQueueFamilyPropertyCount; + // queue family property data pointer is non-NULL: + if (phy_data && qfp && qfp_count) { + phy_data->gotQueueFamilyPropertyCount = true; + phy_data->numOfQueueFamilies = *qfp_count; } } +VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, + uint32_t *pQueueFamilyPropertyCount, + VkQueueFamilyProperties *pQueueFamilyProperties) { + layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); + + // Call down the call chain: + dev_data->instance_dispatch_table->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, + pQueueFamilyProperties); + PostCallRecordGetPhysicalDeviceQueueFamilyProperties(dev_data, physicalDevice, pQueueFamilyPropertyCount, + pQueueFamilyProperties); +} + #ifdef VK_USE_PLATFORM_ANDROID_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { -- cgit v1.2.3