From f57cf525e45f3a65e25c2691464d65e29a79ba77 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Fri, 26 Aug 2016 17:09:24 -0600 Subject: [PATCH] layers: Improve map cleanup on object deletion If object deletion is skipped due to validation error, don't remove object from map. --- layers/core_validation.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index e3e921e..87eb690 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5289,11 +5289,12 @@ VKAPI_ATTR void VKAPI_CALL DestroyEvent(VkDevice device, VkEvent event, const Vk skip |= ValidateObjectNotInUse(dev_data, event_node, obj_struct); // Any bound cmd buffers are now invalid invalidateCommandBuffers(event_node->cb_bindings, obj_struct); - dev_data->eventMap.erase(event); } - lock.unlock(); - if (!skip) + if (!skip) { + dev_data->eventMap.erase(event); + lock.unlock(); dev_data->device_dispatch_table->DestroyEvent(device, event, pAllocator); + } } VKAPI_ATTR void VKAPI_CALL @@ -5307,11 +5308,12 @@ DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallb skip |= ValidateObjectNotInUse(dev_data, qp_node, obj_struct); // Any bound cmd buffers are now invalid invalidateCommandBuffers(qp_node->cb_bindings, obj_struct); - dev_data->queryPoolMap.erase(queryPool); } - lock.unlock(); - if (!skip) + if (!skip) { + dev_data->queryPoolMap.erase(queryPool); + lock.unlock(); dev_data->device_dispatch_table->DestroyQueryPool(device, queryPool, pAllocator); + } } VKAPI_ATTR VkResult VKAPI_CALL GetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, @@ -5745,11 +5747,12 @@ DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallback skip |= ValidateObjectNotInUse(dev_data, pipe_node, obj_struct); // Any bound cmd buffers are now invalid invalidateCommandBuffers(pipe_node->cb_bindings, obj_struct); - dev_data->pipelineMap.erase(pipeline); } - lock.unlock(); - if (!skip) + if (!skip) { + dev_data->pipelineMap.erase(pipeline); + lock.unlock(); dev_data->device_dispatch_table->DestroyPipeline(device, pipeline, pAllocator); + } } VKAPI_ATTR void VKAPI_CALL @@ -5773,11 +5776,12 @@ DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks * skip |= ValidateObjectNotInUse(dev_data, sampler_node, obj_struct); // Any bound cmd buffers are now invalid invalidateCommandBuffers(sampler_node->cb_bindings, obj_struct); - dev_data->samplerMap.erase(sampler); } - lock.unlock(); - if (!skip) + if (!skip) { + dev_data->samplerMap.erase(sampler); + lock.unlock(); dev_data->device_dispatch_table->DestroySampler(device, sampler, pAllocator); + } } VKAPI_ATTR void VKAPI_CALL -- 2.7.4