aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2017-09-01 17:03:21 -0700
committerChris Forbes <chrisf@ijw.co.nz>2017-09-05 12:15:43 -0700
commit34861ad9f10066f2fae77ee023ce4318c46360f2 (patch)
treee3e4f1ac3b4962e1d3456d011779f04871ac731a /layers/core_validation.cpp
parentdacf0c23f75d8cd36f85b450dc3c692cfdc9ff3d (diff)
downloadusermoji-34861ad9f10066f2fae77ee023ce4318c46360f2.tar.xz
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.
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp8
1 files changed, 3 insertions, 5 deletions
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<cvdescriptorset::DescriptorSetLayout>(&layout_create_info, desc_set_layout);
- auto new_desc = new cvdescriptorset::DescriptorSet(0, 0, shared_ds_layout, device_data);
+ std::unique_ptr<cvdescriptorset::DescriptorSet> 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,