From 5279460a7db743946cb9bcc09d0b57919407d670 Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Tue, 18 Aug 2015 15:56:18 -0600 Subject: [PATCH] layers: release mutex in DrawState Release mutex when last instance is destroyed. --- layers/draw_state.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index a0780fda..10fa70cd 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -1251,11 +1251,7 @@ static void init_draw_state(layer_data *my_data) if (!globalLockInitialized) { - // TODO/TBD: Need to delete this mutex sometime. How??? One - // suggestion is to call this during vkCreateInstance(), and then we - // can clean it up during vkDestroyInstance(). However, that requires - // that the layer have per-instance locks. We need to come back and - // address this soon. + // This mutex may be deleted by vkDestroyInstance of last instance. loader_platform_thread_create_mutex(&globalLock); globalLockInitialized = 1; } @@ -1296,6 +1292,11 @@ VK_LAYER_EXPORT void VKAPI vkDestroyInstance(VkInstance instance) layer_data_map.erase(pTable); draw_state_instance_table_map.erase(key); + if (draw_state_instance_table_map.empty()) { + // Release mutex when destroying last instance. + loader_platform_thread_delete_mutex(&globalLock); + globalLockInitialized = 0; + } } static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) -- 2.34.1