aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-10-25 22:00:47 -0600
committerTobin Ehlis <tobine@google.com>2016-10-25 22:00:47 -0600
commit47705d01140c9f1492885e6efc5fa262e7e1c6a0 (patch)
tree3839b301217eab775f671e98bc42c6208de734f9
parent94165f5005d1fa37801d49067fe7751789b89d27 (diff)
downloadvulkan-validation-layers-47705d01140c9f1492885e6efc5fa262e7e1c6a0.tar.gz
layers:Refactor PostCallRecordFreeMemory()
Simplify the code based on review feedback. Don't need loop guard and don't need to clear the set of struct that's about to be freed.
-rw-r--r--layers/core_validation.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 89babdda6..b4b080a65 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -5108,31 +5108,27 @@ static bool PreCallValidateFreeMemory(layer_data *dev_data, VkDeviceMemory mem,
static void PostCallRecordFreeMemory(layer_data *dev_data, VkDeviceMemory mem, DEVICE_MEM_INFO *mem_info, VK_OBJECT obj_struct) {
// Clear mem binding for any bound objects
- if (mem_info->obj_bindings.size() > 0) {
- for (auto obj : mem_info->obj_bindings) {
- log_msg(dev_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, obj.type, obj.handle, __LINE__,
- MEMTRACK_FREED_MEM_REF, "MEM", "VK Object 0x%" PRIxLEAST64 " still has a reference to mem obj 0x%" PRIxLEAST64,
- obj.handle, (uint64_t)mem_info->mem);
- switch (obj.type) {
- case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: {
- auto image_state = getImageState(dev_data, reinterpret_cast<VkImage &>(obj.handle));
- assert(image_state); // Any destroyed images should already be removed from bindings
- image_state->binding.mem = MEMORY_UNBOUND;
- break;
- }
- case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: {
- auto buff_node = getBufferNode(dev_data, reinterpret_cast<VkBuffer &>(obj.handle));
- assert(buff_node); // Any destroyed buffers should already be removed from bindings
- buff_node->binding.mem = MEMORY_UNBOUND;
- break;
- }
- default:
- // Should only have buffer or image objects bound to memory
- assert(0);
- }
+ for (auto obj : mem_info->obj_bindings) {
+ log_msg(dev_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, obj.type, obj.handle, __LINE__, MEMTRACK_FREED_MEM_REF,
+ "MEM", "VK Object 0x%" PRIxLEAST64 " still has a reference to mem obj 0x%" PRIxLEAST64, obj.handle,
+ (uint64_t)mem_info->mem);
+ switch (obj.type) {
+ case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: {
+ auto image_state = getImageState(dev_data, reinterpret_cast<VkImage &>(obj.handle));
+ assert(image_state); // Any destroyed images should already be removed from bindings
+ image_state->binding.mem = MEMORY_UNBOUND;
+ break;
+ }
+ case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: {
+ auto buff_node = getBufferNode(dev_data, reinterpret_cast<VkBuffer &>(obj.handle));
+ assert(buff_node); // Any destroyed buffers should already be removed from bindings
+ buff_node->binding.mem = MEMORY_UNBOUND;
+ break;
+ }
+ default:
+ // Should only have buffer or image objects bound to memory
+ assert(0);
}
- // Clear the list of hanging references
- mem_info->obj_bindings.clear();
}
// Any bound cmd buffers are now invalid
invalidateCommandBuffers(mem_info->cb_bindings, obj_struct);