diff options
| author | Chris Forbes <chrisforbes@google.com> | 2016-06-21 13:24:04 +1200 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-06-23 14:55:21 -0600 |
| commit | d22a29a08da5e25fc43ba3478f221f128a7ed904 (patch) | |
| tree | 2d656da7bad5f4b6c208fa4ee788cca6636f1b25 /layers/core_validation.cpp | |
| parent | 81793ac943559aa9c6d503ac2fe500dd56b5d1e5 (diff) | |
| download | usermoji-d22a29a08da5e25fc43ba3478f221f128a7ed904.tar.xz | |
layers: Untangle check & update in FreeCommandBuffers
Fixes crash later in new test case
Signed-off-by: Chris Forbes <chrisforbes@google.com>
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index b856c6d4..0e073a2f 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5361,14 +5361,29 @@ static void clearCommandBuffersInFlight(layer_data *dev_data, COMMAND_POOL_NODE VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - bool skip_call = false; std::unique_lock<std::mutex> lock(global_lock); + for (uint32_t i = 0; i < commandBufferCount; i++) { auto cb_pair = dev_data->commandBufferMap.find(pCommandBuffers[i]); // Delete CB information structure, and remove from commandBufferMap if (cb_pair != dev_data->commandBufferMap.end()) { skip_call |= checkCommandBufferInFlight(dev_data, cb_pair->second, "free"); + } + } + lock.unlock(); + + if (skip_call) + return; + + dev_data->device_dispatch_table->FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); + + lock.lock(); + auto pPool = getCommandPoolNode(dev_data, commandPool); + for (uint32_t i = 0; i < commandBufferCount; i++) { + auto cb_pair = dev_data->commandBufferMap.find(pCommandBuffers[i]); + // Delete CB information structure, and remove from commandBufferMap + if (cb_pair != dev_data->commandBufferMap.end()) { dev_data->globalInFlightCmdBuffers.erase(cb_pair->first); // reset prior to delete for data clean-up resetCB(dev_data, (*cb_pair).second->commandBuffer); @@ -5377,13 +5392,10 @@ FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandB } // Remove commandBuffer reference from commandPoolMap - dev_data->commandPoolMap[commandPool].commandBuffers.remove(pCommandBuffers[i]); + pPool->commandBuffers.remove(pCommandBuffers[i]); } printCBList(dev_data); lock.unlock(); - - if (!skip_call) - dev_data->device_dispatch_table->FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); } VKAPI_ATTR VkResult VKAPI_CALL CreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, |
