From: Chris Forbes Date: Thu, 31 Mar 2016 03:13:36 +0000 (+1300) Subject: layers: Fix remaining leak in vkDestroyFramebuffers X-Git-Tag: upstream/1.1.92~3456 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=216d93076d9ccf4e0f7e78e4cb90d5b55d3aee56;p=platform%2Fupstream%2FVulkan-Tools.git layers: Fix remaining leak in vkDestroyFramebuffers Also simplify & fix the thread safety of this function. DestroyFramebuffers should not be in anybody's hot path -- and we absolutely /must/ hold the mutex to touch these maps, so throw away all the weird unlocking & relocking; just do it the simple way. Signed-off-by: Chris Forbes --- diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index d9a4144..7b97451 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -6315,6 +6315,7 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, ui VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + loader_platform_thread_lock_mutex(&globalLock); auto fbNode = dev_data->frameBufferMap.find(framebuffer); if (fbNode != dev_data->frameBufferMap.end()) { for (auto cb : fbNode->second.referencingCmdBuffers) { @@ -6322,15 +6323,13 @@ vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocat if (cbNode != dev_data->commandBufferMap.end()) { // Set CB as invalid and record destroyed framebuffer cbNode->second->state = CB_INVALID; - loader_platform_thread_lock_mutex(&globalLock); cbNode->second->destroyedFramebuffers.insert(framebuffer); - loader_platform_thread_unlock_mutex(&globalLock); } } - loader_platform_thread_lock_mutex(&globalLock); - dev_data->frameBufferMap.erase(framebuffer); - loader_platform_thread_unlock_mutex(&globalLock); + delete [] fbNode->second.createInfo.pAttachments; + dev_data->frameBufferMap.erase(fbNode); } + loader_platform_thread_unlock_mutex(&globalLock); dev_data->device_dispatch_table->DestroyFramebuffer(device, framebuffer, pAllocator); }