From 0042d3a860140b5dd5f9eda3e440e24aca02e528 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 12 Oct 2016 14:34:12 -0600 Subject: [PATCH] layers:Add pool member to DescriptorSet class When creating a DescriptorSet instance, record the pool that the set is allocated from in a private pool_ variable. Then, when binding a set to a cmd buffer, also create a binding between the command buffer and the pool. This allows us to catch the in-use case when sets are implicitly freed by calling vkDestroyDescriptorPool(). --- layers/descriptor_sets.cpp | 10 ++++++---- layers/descriptor_sets.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index de9f2f1..dc647e2 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -265,9 +265,9 @@ bool cvdescriptorset::DescriptorSetLayout::VerifyUpdateConsistency(uint32_t curr cvdescriptorset::AllocateDescriptorSetsData::AllocateDescriptorSetsData(uint32_t count) : required_descriptors_by_type{}, layout_nodes(count, nullptr) {} -cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const DescriptorSetLayout *layout, - const core_validation::layer_data *dev_data) - : some_update_(false), set_(set), p_layout_(layout), device_data_(dev_data) { +cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const VkDescriptorPool pool, + const DescriptorSetLayout *layout, const core_validation::layer_data *dev_data) + : some_update_(false), set_(set), pool_(pool), p_layout_(layout), device_data_(dev_data) { // Foreach binding, create default descriptors of given type for (uint32_t i = 0; i < p_layout_->GetBindingCount(); ++i) { auto type = p_layout_->GetTypeFromIndex(i); @@ -648,6 +648,7 @@ void cvdescriptorset::DescriptorSet::BindCommandBuffer(GLOBAL_CB_NODE *cb_node, cb_bindings.insert(cb_node); // Add bindings for descriptor set and individual objects in the set cb_node->object_bindings.insert({reinterpret_cast(set_), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT}); + cb_node->object_bindings.insert({reinterpret_cast(pool_), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT}); // For the active slots, use set# to look up descriptorSet from boundDescriptorSets, and bind all of that descriptor set's // resources for (auto binding : bindings) { @@ -1537,7 +1538,8 @@ void cvdescriptorset::PerformAllocateDescriptorSets(const VkDescriptorSetAllocat * global map and the pool's set. */ for (uint32_t i = 0; i < p_alloc_info->descriptorSetCount; i++) { - auto new_ds = new cvdescriptorset::DescriptorSet(descriptor_sets[i], ds_data->layout_nodes[i], dev_data); + auto new_ds = new cvdescriptorset::DescriptorSet(descriptor_sets[i], p_alloc_info->descriptorPool, ds_data->layout_nodes[i], + dev_data); pool_state->sets.insert(new_ds); new_ds->in_use.store(0); diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h index 11ba9a3..bc58082 100644 --- a/layers/descriptor_sets.h +++ b/layers/descriptor_sets.h @@ -297,7 +297,7 @@ void PerformAllocateDescriptorSets(const VkDescriptorSetAllocateInfo *, const Vk */ class DescriptorSet : public BASE_NODE { public: - DescriptorSet(const VkDescriptorSet, const DescriptorSetLayout *, const core_validation::layer_data *); + DescriptorSet(const VkDescriptorSet, const VkDescriptorPool, const DescriptorSetLayout *, const core_validation::layer_data *); ~DescriptorSet(); // A number of common Get* functions that return data based on layout from which this set was created uint32_t GetTotalDescriptorCount() const { return p_layout_ ? p_layout_->GetTotalDescriptorCount() : 0; }; @@ -374,6 +374,7 @@ class DescriptorSet : public BASE_NODE { void InvalidateBoundCmdBuffers(); bool some_update_; // has any part of the set ever been updated? VkDescriptorSet set_; + VkDescriptorPool pool_; const DescriptorSetLayout *p_layout_; std::vector> descriptors_; // Ptr to device data used for various data look-ups -- 2.7.4