From a8023fac7d5f20451f97357c56d2ada49f0ebd9d Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Wed, 13 Jul 2016 11:07:27 -0600 Subject: layers: threading with cmd buffer handle reuse A driver may reuse a command buffer handle in another thread. The threading layer needs to remove command buffer information before calling FreeCommandBuffers. This addresses part of github issue #719. --- layers/threading.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'layers/threading.cpp') diff --git a/layers/threading.cpp b/layers/threading.cpp index ed7663a5..2228d908 100644 --- a/layers/threading.cpp +++ b/layers/threading.cpp @@ -374,17 +374,19 @@ VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool com for (uint32_t index = 0; index < commandBufferCount; index++) { startWriteObject(my_data, pCommandBuffers[index], lockCommandPool); } + // The driver may immediately reuse command buffers in another thread. + // These updates need to be done before calling down to the driver. + for (uint32_t index = 0; index < commandBufferCount; index++) { + finishWriteObject(my_data, pCommandBuffers[index], lockCommandPool); + std::lock_guard lock(command_pool_lock); + command_pool_map.erase(pCommandBuffers[index]); + } } pTable->FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); if (threadChecks) { finishReadObject(my_data, device); finishWriteObject(my_data, commandPool); - for (uint32_t index = 0; index < commandBufferCount; index++) { - finishWriteObject(my_data, pCommandBuffers[index], lockCommandPool); - std::lock_guard lock(command_pool_lock); - command_pool_map.erase(pCommandBuffers[index]); - } } else { finishMultiThread(); } -- cgit v1.2.3