From 900135556fce1ecf6793267d4db4b423d7f009c1 Mon Sep 17 00:00:00 2001 From: Gabríel Arthúr Pétursson Date: Sat, 3 Jun 2017 23:27:59 +0000 Subject: layers: Free per-device and -instance data on destroy Instance and device data are allocated by the first call to GetLayerDataPtr in the corresponding vkCreate call. We need to delete them when we're done with them. Introduce a FreeLayerDataPtr helper function that assists with this task. Deletes for dispatch tables were missing in a few places too. Add them. --- layers/core_validation.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 3b5795f6..008b49e3 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3440,7 +3440,7 @@ VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocati } layer_debug_report_destroy_instance(instance_data->report_data); - layer_data_map.erase(key); + FreeLayerDataPtr(key, instance_layer_data_map); } static bool ValidatePhysicalDeviceQueueFamily(instance_layer_data *instance_data, const PHYSICAL_DEVICE_STATE *pd_state, @@ -3633,7 +3633,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDevice // prototype VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { // TODOSC : Shouldn't need any customization here - bool skip = false; dispatch_key key = get_dispatch_key(device); layer_data *dev_data = GetLayerDataPtr(key, layer_data_map); // Free all the memory @@ -3667,10 +3666,9 @@ VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCall #if DISPATCH_MAP_DEBUG fprintf(stderr, "Device: 0x%p, key: 0x%p\n", device, key); #endif - if (!skip) { - dev_data->dispatch_table.DestroyDevice(device, pAllocator); - layer_data_map.erase(key); - } + + dev_data->dispatch_table.DestroyDevice(device, pAllocator); + FreeLayerDataPtr(key, layer_data_map); } static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}}; -- cgit v1.2.3