diff options
Diffstat (limited to 'layers/threading.cpp')
| -rw-r--r-- | layers/threading.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
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<std::mutex> 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<std::mutex> lock(command_pool_lock); - command_pool_map.erase(pCommandBuffers[index]); - } } else { finishMultiThread(); } |
