From 34861ad9f10066f2fae77ee023ce4318c46360f2 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 1 Sep 2017 17:03:21 -0700 Subject: layers: Fix leaking backing sets for push descriptors We'd previously leak any temporary descriptor set left bound to the pipeline at the end of the command buffer. Rearrange things so we can use unique_ptr and assure it's always cleaned up correctly. --- layers/core_validation.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index a56cbe36..3c63430e 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5378,7 +5378,6 @@ static void PreCallRecordCmdBindDescriptorSets(layer_data *device_data, GLOBAL_C if ((last_bound->boundDescriptorSets[set_idx + firstSet] != nullptr) && last_bound->boundDescriptorSets[set_idx + firstSet]->IsPushDescriptor()) { - delete last_bound->push_descriptors[set_idx + firstSet]; last_bound->push_descriptors[set_idx + firstSet] = nullptr; last_bound->boundDescriptorSets[set_idx + firstSet] = nullptr; } @@ -5561,7 +5560,6 @@ static void PreCallRecordCmdPushDescriptorSetKHR(layer_data *device_data, VkComm "vkCmdPushDescriptorSet called multiple times for set %d in pipeline layout 0x%" PRIxLEAST64 ".", set, HandleToUint64(layout)); if (cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[set]->IsPushDescriptor()) { - delete cb_state->lastBound[pipelineBindPoint].push_descriptors[set]; cb_state->lastBound[pipelineBindPoint].push_descriptors[set] = nullptr; } } @@ -5581,10 +5579,10 @@ static void PreCallRecordCmdPushDescriptorSetKHR(layer_data *device_data, VkComm const VkDescriptorSetLayout desc_set_layout = 0; auto const shared_ds_layout = std::make_shared(&layout_create_info, desc_set_layout); - auto new_desc = new cvdescriptorset::DescriptorSet(0, 0, shared_ds_layout, device_data); + std::unique_ptr new_desc{new cvdescriptorset::DescriptorSet(0, 0, shared_ds_layout, device_data)}; new_desc->SetPushDescriptor(); - cb_state->lastBound[pipelineBindPoint].push_descriptors[set] = new_desc; - cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[set] = new_desc; + cb_state->lastBound[pipelineBindPoint].boundDescriptorSets[set] = new_desc.get(); + cb_state->lastBound[pipelineBindPoint].push_descriptors[set] = std::move(new_desc); } VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, -- cgit v1.2.3