aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--layers/buffer_validation.h1
-rw-r--r--layers/core_validation.cpp8
-rw-r--r--layers/core_validation_types.h2
3 files changed, 5 insertions, 6 deletions
diff --git a/layers/buffer_validation.h b/layers/buffer_validation.h
index dbc0127e..0bc7dabf 100644
--- a/layers/buffer_validation.h
+++ b/layers/buffer_validation.h
@@ -22,6 +22,7 @@
#include "core_validation_types.h"
#include "core_validation_error_enums.h"
+#include "descriptor_sets.h"
#include "vulkan/vk_layer.h"
#include <limits.h>
#include <memory>
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,
diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h
index c62fb40c..1d4209c7 100644
--- a/layers/core_validation_types.h
+++ b/layers/core_validation_types.h
@@ -622,7 +622,7 @@ struct LAST_BOUND_STATE {
// Track each set that has been bound
// Ordered bound set tracking where index is set# that given set is bound to
std::vector<cvdescriptorset::DescriptorSet *> boundDescriptorSets;
- std::vector<cvdescriptorset::DescriptorSet *> push_descriptors;
+ std::vector<std::unique_ptr<cvdescriptorset::DescriptorSet>> push_descriptors;
// one dynamic offset per dynamic descriptor bound to this CB
std::vector<std::vector<uint32_t>> dynamicOffsets;