From ed562ea5f59571db947be0f543385679b66e0149 Mon Sep 17 00:00:00 2001 From: Jeremy Hayes Date: Tue, 12 Apr 2016 13:48:52 -0600 Subject: layers: threading - use std mutex Change-Id: I773ea148807e5b634ad021ea58b001cd3d1bad87 --- layers/threading.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'layers/threading.cpp') diff --git a/layers/threading.cpp b/layers/threading.cpp index 51381848..d23c9ff3 100644 --- a/layers/threading.cpp +++ b/layers/threading.cpp @@ -48,12 +48,6 @@ static void initThreading(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "google_threading"); - - if (!threadingLockInitialized) { - loader_platform_thread_create_mutex(&threadingLock); - loader_platform_thread_init_cond(&threadingCond); - threadingLockInitialized = 1; - } } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL @@ -102,12 +96,6 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance layer_debug_report_destroy_instance(my_data->report_data); delete my_data->instance_dispatch_table; layer_data_map.erase(key); - - if (layer_data_map.empty()) { - // Release mutex when destroying last instance. - loader_platform_thread_delete_mutex(&threadingLock); - threadingLockInitialized = 0; - } } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, @@ -311,9 +299,8 @@ vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAl // Record mapping from command buffer to command pool if (VK_SUCCESS == result) { for (uint32_t index = 0; index < pAllocateInfo->commandBufferCount; index++) { - loader_platform_thread_lock_mutex(&threadingLock); + std::lock_guard lock(global_lock); command_pool_map[pCommandBuffers[index]] = pAllocateInfo->commandPool; - loader_platform_thread_unlock_mutex(&threadingLock); } } @@ -337,8 +324,7 @@ void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, finishWriteObject(my_data, commandPool); for (uint32_t index = 0; index < commandBufferCount; index++) { finishWriteObject(my_data, pCommandBuffers[index], lockCommandPool); - loader_platform_thread_lock_mutex(&threadingLock); + std::lock_guard lock(global_lock); command_pool_map.erase(pCommandBuffers[index]); - loader_platform_thread_unlock_mutex(&threadingLock); } } -- cgit v1.2.3