From e4c92d5ab6ea4b6a36f4d142698da5cabaee154b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 17 May 2016 18:47:09 +1200 Subject: [PATCH] layers: Simplify command buffer pool cleanup We don't need to carefully pick through the pool's buffers, removing them. We're about to throw away the whole container. Signed-off-by: Chris Forbes --- layers/core_validation.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 4e58449..6e05d48 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5386,15 +5386,13 @@ DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocatio // Verify that command buffers in pool are complete (not in-flight) VkBool32 result = checkAndClearCommandBuffersInFlight(dev_data, commandPool, "destroy command pool with"); // Must remove cmdpool from cmdpoolmap, after removing all cmdbuffers in its list from the commandPoolMap - if (dev_data->commandPoolMap.find(commandPool) != dev_data->commandPoolMap.end()) { - for (auto poolCb = dev_data->commandPoolMap[commandPool].commandBuffers.begin(); - poolCb != dev_data->commandPoolMap[commandPool].commandBuffers.end();) { - clear_cmd_buf_and_mem_references(dev_data, *poolCb); - auto del_cb = dev_data->commandBufferMap.find(*poolCb); - delete (*del_cb).second; // delete CB info structure + auto pool_it = dev_data->commandPoolMap.find(commandPool); + if (pool_it != dev_data->commandPoolMap.end()) { + for (auto cb : pool_it->second.commandBuffers) { + clear_cmd_buf_and_mem_references(dev_data, cb); + auto del_cb = dev_data->commandBufferMap.find(cb); + delete del_cb->second; // delete CB info structure dev_data->commandBufferMap.erase(del_cb); // Remove this command buffer - poolCb = dev_data->commandPoolMap[commandPool].commandBuffers.erase( - poolCb); // Remove CB reference from commandPoolMap's list } } dev_data->commandPoolMap.erase(commandPool); -- 2.7.4