aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stroyan <stroyan@google.com>2016-07-13 11:07:27 -0600
committerMike Stroyan <stroyan@google.com>2016-07-15 08:44:50 -0600
commita8023fac7d5f20451f97357c56d2ada49f0ebd9d (patch)
treeff53ba568616ee513c3b9f03c0e4675676bac8ee
parent823c0dfa6498a36cf6fc28b7cb6694220c4abc45 (diff)
downloadusermoji-a8023fac7d5f20451f97357c56d2ada49f0ebd9d.tar.xz
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.
-rw-r--r--layers/threading.cpp12
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();
}