aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2017-06-20 08:30:39 -0600
committerTobin Ehlis <tobine@google.com>2017-06-20 16:53:12 -0600
commitc5366f2743146b95dc23c26d7acba9e7fbe393b3 (patch)
treedc5c182be454de5c418e548f9fd0c3378c948071
parent5e47f04e53b6ef65e6f3d064218ae2d1232ca318 (diff)
downloadusermoji-c5366f2743146b95dc23c26d7acba9e7fbe393b3.tar.xz
layers:Migrate DSLayout to shared_ptr
Update Descriptor Set Layout copy in Descriptor Set, as well as various ptr references to use shared_ptr. This fixes some potential memory leaks and makes Descriptor Set class lighter weight.
-rw-r--r--layers/core_validation.cpp5
-rw-r--r--layers/core_validation_types.h4
-rw-r--r--layers/descriptor_sets.cpp77
-rw-r--r--layers/descriptor_sets.h47
4 files changed, 64 insertions, 69 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index ebc9d8d9..72b8bcd5 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -709,12 +709,13 @@ FRAMEBUFFER_STATE *GetFramebufferState(const layer_data *dev_data, VkFramebuffer
return it->second.get();
}
-cvdescriptorset::DescriptorSetLayout const *GetDescriptorSetLayout(layer_data const *dev_data, VkDescriptorSetLayout dsLayout) {
+std::shared_ptr<cvdescriptorset::DescriptorSetLayout> const GetDescriptorSetLayout(layer_data const *dev_data,
+ VkDescriptorSetLayout dsLayout) {
auto it = dev_data->descriptorSetLayoutMap.find(dsLayout);
if (it == dev_data->descriptorSetLayoutMap.end()) {
return nullptr;
}
- return it->second.get();
+ return it->second;
}
static PIPELINE_LAYOUT_NODE const *getPipelineLayout(layer_data const *dev_data, VkPipelineLayout pipeLayout) {
diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h
index 4bab8ffd..785c1593 100644
--- a/layers/core_validation_types.h
+++ b/layers/core_validation_types.h
@@ -526,7 +526,7 @@ struct hash<ImageSubresourcePair> {
// Store layouts and pushconstants for PipelineLayout
struct PIPELINE_LAYOUT_NODE {
VkPipelineLayout layout;
- std::vector<cvdescriptorset::DescriptorSetLayout const *> set_layouts;
+ std::vector<std::shared_ptr<cvdescriptorset::DescriptorSetLayout>> set_layouts;
std::vector<VkPushConstantRange> push_constant_ranges;
PIPELINE_LAYOUT_NODE() : layout(VK_NULL_HANDLE), set_layouts{}, push_constant_ranges{} {}
@@ -765,7 +765,7 @@ struct DeviceExtensions;
namespace core_validation {
struct layer_data;
cvdescriptorset::DescriptorSet *GetSetNode(const layer_data *, VkDescriptorSet);
-cvdescriptorset::DescriptorSetLayout const *GetDescriptorSetLayout(layer_data const *, VkDescriptorSetLayout);
+std::shared_ptr<cvdescriptorset::DescriptorSetLayout> const GetDescriptorSetLayout(layer_data const *, VkDescriptorSetLayout);
DESCRIPTOR_POOL_STATE *GetDescriptorPoolState(const layer_data *, const VkDescriptorPool);
BUFFER_STATE *GetBufferState(const layer_data *, VkBuffer);
IMAGE_STATE *GetImageState(const layer_data *, VkImage);
diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp
index 877d0d65..f4ce7a47 100644
--- a/layers/descriptor_sets.cpp
+++ b/layers/descriptor_sets.cpp
@@ -209,7 +209,8 @@ VkSampler const *cvdescriptorset::DescriptorSetLayout::GetImmutableSamplerPtrFro
}
// If our layout is compatible with rh_ds_layout, return true,
// else return false and fill in error_msg will description of what causes incompatibility
-bool cvdescriptorset::DescriptorSetLayout::IsCompatible(const DescriptorSetLayout *rh_ds_layout, std::string *error_msg) const {
+bool cvdescriptorset::DescriptorSetLayout::IsCompatible(std::shared_ptr<DescriptorSetLayout> const rh_ds_layout,
+ std::string *error_msg) const {
// Trivial case
if (layout_ == rh_ds_layout->GetDescriptorSetLayout()) return true;
if (descriptor_count_ != rh_ds_layout->descriptor_count_) {
@@ -312,21 +313,21 @@ cvdescriptorset::AllocateDescriptorSetsData::AllocateDescriptorSetsData(uint32_t
: required_descriptors_by_type{}, layout_nodes(count, nullptr) {}
cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const VkDescriptorPool pool,
- const DescriptorSetLayout *layout, const layer_data *dev_data)
+ std::shared_ptr<DescriptorSetLayout> layout, const layer_data *dev_data)
: some_update_(false),
set_(set),
pool_state_(nullptr),
- p_layout_(*layout),
+ p_layout_(layout),
device_data_(dev_data),
limits_(GetPhysDevProperties(dev_data)->properties.limits) {
pool_state_ = GetDescriptorPoolState(dev_data, pool);
// Foreach binding, create default descriptors of given type
- for (uint32_t i = 0; i < p_layout_.GetBindingCount(); ++i) {
- auto type = p_layout_.GetTypeFromIndex(i);
+ for (uint32_t i = 0; i < p_layout_->GetBindingCount(); ++i) {
+ auto type = p_layout_->GetTypeFromIndex(i);
switch (type) {
case VK_DESCRIPTOR_TYPE_SAMPLER: {
- auto immut_sampler = p_layout_.GetImmutableSamplerPtrFromIndex(i);
- for (uint32_t di = 0; di < p_layout_.GetDescriptorCountFromIndex(i); ++di) {
+ auto immut_sampler = p_layout_->GetImmutableSamplerPtrFromIndex(i);
+ for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) {
if (immut_sampler) {
descriptors_.emplace_back(new SamplerDescriptor(immut_sampler + di));
some_update_ = true; // Immutable samplers are updated at creation
@@ -336,8 +337,8 @@ cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const V
break;
}
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: {
- auto immut = p_layout_.GetImmutableSamplerPtrFromIndex(i);
- for (uint32_t di = 0; di < p_layout_.GetDescriptorCountFromIndex(i); ++di) {
+ auto immut = p_layout_->GetImmutableSamplerPtrFromIndex(i);
+ for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di) {
if (immut) {
descriptors_.emplace_back(new ImageSamplerDescriptor(immut + di));
some_update_ = true; // Immutable samplers are updated at creation
@@ -350,19 +351,19 @@ cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const V
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
- for (uint32_t di = 0; di < p_layout_.GetDescriptorCountFromIndex(i); ++di)
+ for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di)
descriptors_.emplace_back(new ImageDescriptor(type));
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
- for (uint32_t di = 0; di < p_layout_.GetDescriptorCountFromIndex(i); ++di)
+ for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di)
descriptors_.emplace_back(new TexelDescriptor(type));
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
- for (uint32_t di = 0; di < p_layout_.GetDescriptorCountFromIndex(i); ++di)
+ for (uint32_t di = 0; di < p_layout_->GetDescriptorCountFromIndex(i); ++di)
descriptors_.emplace_back(new BufferDescriptor(type));
break;
default:
@@ -389,8 +390,8 @@ static std::string string_descriptor_req_view_type(descriptor_req req) {
}
// Is this sets underlying layout compatible with passed in layout according to "Pipeline Layout Compatibility" in spec?
-bool cvdescriptorset::DescriptorSet::IsCompatible(const DescriptorSetLayout *layout, std::string *error) const {
- return layout->IsCompatible(&p_layout_, error);
+bool cvdescriptorset::DescriptorSet::IsCompatible(std::shared_ptr<DescriptorSetLayout> const layout, std::string *error) const {
+ return layout->IsCompatible(p_layout_, error);
}
// Validate that the state of this set is appropriate for the given bindings and dynamic_offsets at Draw time
@@ -402,15 +403,15 @@ bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::map<uint32_t,
const char *caller, std::string *error) const {
for (auto binding_pair : bindings) {
auto binding = binding_pair.first;
- if (!p_layout_.HasBinding(binding)) {
+ if (!p_layout_->HasBinding(binding)) {
std::stringstream error_str;
error_str << "Attempting to validate DrawState for binding #" << binding
<< " which is an invalid binding for this descriptor set.";
*error = error_str.str();
return false;
}
- auto start_idx = p_layout_.GetGlobalStartIndexFromBinding(binding);
- auto end_idx = p_layout_.GetGlobalEndIndexFromBinding(binding);
+ auto start_idx = p_layout_->GetGlobalStartIndexFromBinding(binding);
+ auto end_idx = p_layout_->GetGlobalEndIndexFromBinding(binding);
auto array_idx = 0; // Track array idx if we're dealing with array descriptors
for (uint32_t i = start_idx; i <= end_idx; ++i, ++array_idx) {
if (!descriptors_[i]->updated) {
@@ -552,20 +553,20 @@ uint32_t cvdescriptorset::DescriptorSet::GetStorageUpdates(const std::map<uint32
for (auto binding_pair : bindings) {
auto binding = binding_pair.first;
// If a binding doesn't exist, skip it
- if (!p_layout_.HasBinding(binding)) {
+ if (!p_layout_->HasBinding(binding)) {
continue;
}
- auto start_idx = p_layout_.GetGlobalStartIndexFromBinding(binding);
+ auto start_idx = p_layout_->GetGlobalStartIndexFromBinding(binding);
if (descriptors_[start_idx]->IsStorage()) {
if (Image == descriptors_[start_idx]->descriptor_class) {
- for (uint32_t i = 0; i < p_layout_.GetDescriptorCountFromBinding(binding); ++i) {
+ for (uint32_t i = 0; i < p_layout_->GetDescriptorCountFromBinding(binding); ++i) {
if (descriptors_[start_idx + i]->updated) {
image_set->insert(static_cast<ImageDescriptor *>(descriptors_[start_idx + i].get())->GetImageView());
num_updates++;
}
}
} else if (TexelBuffer == descriptors_[start_idx]->descriptor_class) {
- for (uint32_t i = 0; i < p_layout_.GetDescriptorCountFromBinding(binding); ++i) {
+ for (uint32_t i = 0; i < p_layout_->GetDescriptorCountFromBinding(binding); ++i) {
if (descriptors_[start_idx + i]->updated) {
auto bufferview = static_cast<TexelDescriptor *>(descriptors_[start_idx + i].get())->GetBufferView();
auto bv_state = GetBufferViewState(device_data_, bufferview);
@@ -576,7 +577,7 @@ uint32_t cvdescriptorset::DescriptorSet::GetStorageUpdates(const std::map<uint32
}
}
} else if (GeneralBuffer == descriptors_[start_idx]->descriptor_class) {
- for (uint32_t i = 0; i < p_layout_.GetDescriptorCountFromBinding(binding); ++i) {
+ for (uint32_t i = 0; i < p_layout_->GetDescriptorCountFromBinding(binding); ++i) {
if (descriptors_[start_idx + i]->updated) {
buffer_set->insert(static_cast<BufferDescriptor *>(descriptors_[start_idx + i].get())->GetBuffer());
num_updates++;
@@ -599,7 +600,7 @@ void cvdescriptorset::DescriptorSet::PerformWriteUpdate(const VkWriteDescriptorS
auto offset = update->dstArrayElement;
while (descriptors_remaining) {
uint32_t update_count = std::min(descriptors_remaining, GetDescriptorCountFromBinding(binding_being_updated));
- auto global_idx = p_layout_.GetGlobalStartIndexFromBinding(binding_being_updated) + offset;
+ auto global_idx = p_layout_->GetGlobalStartIndexFromBinding(binding_being_updated) + offset;
// Loop over the updates for a single binding at a time
for (uint32_t di = 0; di < update_count; ++di) {
descriptors_[global_idx + di]->WriteUpdate(update, di);
@@ -627,7 +628,7 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data
*error_msg = error_str.str();
return false;
}
- if (!p_layout_.HasBinding(update->dstBinding)) {
+ if (!p_layout_->HasBinding(update->dstBinding)) {
*error_code = VALIDATION_ERROR_032002b6;
std::stringstream error_str;
error_str << "DescriptorSet " << set_ << " does not have copy update dest binding of " << update->dstBinding;
@@ -655,15 +656,15 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data
*error_msg = error_str.str();
return false;
}
- auto dst_start_idx = p_layout_.GetGlobalStartIndexFromBinding(update->dstBinding) + update->dstArrayElement;
- if ((dst_start_idx + update->descriptorCount) > p_layout_.GetTotalDescriptorCount()) {
+ auto dst_start_idx = p_layout_->GetGlobalStartIndexFromBinding(update->dstBinding) + update->dstArrayElement;
+ if ((dst_start_idx + update->descriptorCount) > p_layout_->GetTotalDescriptorCount()) {
// DST update out of bounds
*error_code = VALIDATION_ERROR_032002b8;
std::stringstream error_str;
error_str << "Attempting copy update to descriptorSet " << set_ << " binding#" << update->dstBinding
- << " with offset index of " << p_layout_.GetGlobalStartIndexFromBinding(update->dstBinding)
+ << " with offset index of " << p_layout_->GetGlobalStartIndexFromBinding(update->dstBinding)
<< " plus update array offset of " << update->dstArrayElement << " and update of " << update->descriptorCount
- << " descriptors oversteps total number of descriptors in set: " << p_layout_.GetTotalDescriptorCount();
+ << " descriptors oversteps total number of descriptors in set: " << p_layout_->GetTotalDescriptorCount();
*error_msg = error_str.str();
return false;
}
@@ -672,7 +673,7 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data
// fine-grained error codes
*error_code = VALIDATION_ERROR_032002ba;
auto src_type = src_set->GetTypeFromBinding(update->srcBinding);
- auto dst_type = p_layout_.GetTypeFromBinding(update->dstBinding);
+ auto dst_type = p_layout_->GetTypeFromBinding(update->dstBinding);
if (src_type != dst_type) {
std::stringstream error_str;
error_str << "Attempting copy update to descriptorSet " << set_ << " binding #" << update->dstBinding << " with type "
@@ -684,7 +685,7 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data
// Verify consistency of src & dst bindings if update crosses binding boundaries
if ((!src_set->GetLayout()->VerifyUpdateConsistency(update->srcBinding, update->srcArrayElement, update->descriptorCount,
"copy update from", src_set->GetSet(), error_msg)) ||
- (!p_layout_.VerifyUpdateConsistency(update->dstBinding, update->dstArrayElement, update->descriptorCount, "copy update to",
+ (!p_layout_->VerifyUpdateConsistency(update->dstBinding, update->dstArrayElement, update->descriptorCount, "copy update to",
set_, error_msg))) {
return false;
}
@@ -707,7 +708,7 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data
// Perform Copy update
void cvdescriptorset::DescriptorSet::PerformCopyUpdate(const VkCopyDescriptorSet *update, const DescriptorSet *src_set) {
auto src_start_idx = src_set->GetGlobalStartIndexFromBinding(update->srcBinding) + update->srcArrayElement;
- auto dst_start_idx = p_layout_.GetGlobalStartIndexFromBinding(update->dstBinding) + update->dstArrayElement;
+ auto dst_start_idx = p_layout_->GetGlobalStartIndexFromBinding(update->dstBinding) + update->dstArrayElement;
// Update parameters all look good so perform update
for (uint32_t di = 0; di < update->descriptorCount; ++di) {
descriptors_[dst_start_idx + di]->CopyUpdate(src_set->descriptors_[src_start_idx + di].get());
@@ -732,8 +733,8 @@ void cvdescriptorset::DescriptorSet::BindCommandBuffer(GLOBAL_CB_NODE *cb_node,
// resources
for (auto binding_req_pair : binding_req_map) {
auto binding = binding_req_pair.first;
- auto start_idx = p_layout_.GetGlobalStartIndexFromBinding(binding);
- auto end_idx = p_layout_.GetGlobalEndIndexFromBinding(binding);
+ auto start_idx = p_layout_->GetGlobalStartIndexFromBinding(binding);
+ auto end_idx = p_layout_->GetGlobalEndIndexFromBinding(binding);
for (uint32_t i = start_idx; i <= end_idx; ++i) {
descriptors_[i]->BindCommandBuffer(device_data_, cb_node);
}
@@ -1242,7 +1243,7 @@ bool cvdescriptorset::DescriptorSet::ValidateWriteUpdate(const debug_report_data
return false;
}
// Verify dst binding exists
- if (!p_layout_.HasBinding(update->dstBinding)) {
+ if (!p_layout_->HasBinding(update->dstBinding)) {
*error_code = VALIDATION_ERROR_15c00276;
std::stringstream error_str;
error_str << "DescriptorSet " << set_ << " does not have binding " << update->dstBinding;
@@ -1250,7 +1251,7 @@ bool cvdescriptorset::DescriptorSet::ValidateWriteUpdate(const debug_report_data
return false;
} else {
// Make sure binding isn't empty
- if (0 == p_layout_.GetDescriptorCountFromBinding(update->dstBinding)) {
+ if (0 == p_layout_->GetDescriptorCountFromBinding(update->dstBinding)) {
*error_code = VALIDATION_ERROR_15c00278;
std::stringstream error_str;
error_str << "DescriptorSet " << set_ << " cannot updated binding " << update->dstBinding << " that has 0 descriptors";
@@ -1259,8 +1260,8 @@ bool cvdescriptorset::DescriptorSet::ValidateWriteUpdate(const debug_report_data
}
}
// We know that binding is valid, verify update and do update on each descriptor
- auto start_idx = p_layout_.GetGlobalStartIndexFromBinding(update->dstBinding) + update->dstArrayElement;
- auto type = p_layout_.GetTypeFromBinding(update->dstBinding);
+ auto start_idx = p_layout_->GetGlobalStartIndexFromBinding(update->dstBinding) + update->dstArrayElement;
+ auto type = p_layout_->GetTypeFromBinding(update->dstBinding);
if (type != update->descriptorType) {
*error_code = VALIDATION_ERROR_15c0027e;
std::stringstream error_str;
@@ -1281,7 +1282,7 @@ bool cvdescriptorset::DescriptorSet::ValidateWriteUpdate(const debug_report_data
return false;
}
// Verify consecutive bindings match (if needed)
- if (!p_layout_.VerifyUpdateConsistency(update->dstBinding, update->dstArrayElement, update->descriptorCount, "write update to",
+ if (!p_layout_->VerifyUpdateConsistency(update->dstBinding, update->dstArrayElement, update->descriptorCount, "write update to",
set_, error_msg)) {
// TODO : Should break out "consecutive binding updates" language into valid usage statements
*error_code = VALIDATION_ERROR_15c00282;
diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h
index 00fa830f..975026d6 100644
--- a/layers/descriptor_sets.h
+++ b/layers/descriptor_sets.h
@@ -110,7 +110,7 @@ class DescriptorSetLayout {
bool HasBinding(const uint32_t binding) const { return binding_to_index_map_.count(binding) > 0; };
// Return true if this layout is compatible with passed in layout,
// else return false and update error_msg with description of incompatibility
- bool IsCompatible(const DescriptorSetLayout *, std::string *) const;
+ bool IsCompatible(std::shared_ptr<DescriptorSetLayout> const, std::string *) const;
// Return true if binding 1 beyond given exists and has same type, stageFlags & immutable sampler use
bool IsNextBindingConsistent(const uint32_t) const;
// Various Get functions that can either be passed a binding#, which will
@@ -276,7 +276,7 @@ class BufferDescriptor : public Descriptor {
// Structs to contain common elements that need to be shared between Validate* and Perform* calls below
struct AllocateDescriptorSetsData {
uint32_t required_descriptors_by_type[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
- std::vector<cvdescriptorset::DescriptorSetLayout const *> layout_nodes;
+ std::vector<std::shared_ptr<DescriptorSetLayout>> layout_nodes;
AllocateDescriptorSetsData(uint32_t);
};
// Helper functions for descriptor set functions that cross multiple sets
@@ -321,35 +321,28 @@ void PerformAllocateDescriptorSets(const VkDescriptorSetAllocateInfo *, const Vk
*/
class DescriptorSet : public BASE_NODE {
public:
- DescriptorSet(const VkDescriptorSet, const VkDescriptorPool, const DescriptorSetLayout *, const core_validation::layer_data *);
+ DescriptorSet(const VkDescriptorSet, const VkDescriptorPool, const std::shared_ptr<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_.GetTotalDescriptorCount(); };
- uint32_t GetDynamicDescriptorCount() const { return p_layout_.GetDynamicDescriptorCount(); };
- uint32_t GetBindingCount() const { return p_layout_.GetBindingCount(); };
- VkDescriptorType GetTypeFromIndex(const uint32_t index) const {
- return p_layout_.GetTypeFromIndex(index);
- };
- VkDescriptorType GetTypeFromGlobalIndex(const uint32_t index) const {
- return p_layout_.GetTypeFromGlobalIndex(index);
- };
- VkDescriptorType GetTypeFromBinding(const uint32_t binding) const {
- return p_layout_.GetTypeFromBinding(binding);
- };
- uint32_t GetDescriptorCountFromIndex(const uint32_t index) const {
- return p_layout_.GetDescriptorCountFromIndex(index);
- };
+ uint32_t GetTotalDescriptorCount() const { return p_layout_->GetTotalDescriptorCount(); };
+ uint32_t GetDynamicDescriptorCount() const { return p_layout_->GetDynamicDescriptorCount(); };
+ uint32_t GetBindingCount() const { return p_layout_->GetBindingCount(); };
+ VkDescriptorType GetTypeFromIndex(const uint32_t index) const { return p_layout_->GetTypeFromIndex(index); };
+ VkDescriptorType GetTypeFromGlobalIndex(const uint32_t index) const { return p_layout_->GetTypeFromGlobalIndex(index); };
+ VkDescriptorType GetTypeFromBinding(const uint32_t binding) const { return p_layout_->GetTypeFromBinding(binding); };
+ uint32_t GetDescriptorCountFromIndex(const uint32_t index) const { return p_layout_->GetDescriptorCountFromIndex(index); };
uint32_t GetDescriptorCountFromBinding(const uint32_t binding) const {
- return p_layout_.GetDescriptorCountFromBinding(binding);
+ return p_layout_->GetDescriptorCountFromBinding(binding);
};
// Return index into dynamic offset array for given binding
int32_t GetDynamicOffsetIndexFromBinding(uint32_t binding) const {
- return p_layout_.GetDynamicOffsetIndexFromBinding(binding);
+ return p_layout_->GetDynamicOffsetIndexFromBinding(binding);
}
// Return true if given binding is present in this set
- bool HasBinding(const uint32_t binding) const { return p_layout_.HasBinding(binding); };
+ bool HasBinding(const uint32_t binding) const { return p_layout_->HasBinding(binding); };
// Is this set compatible with the given layout?
- bool IsCompatible(const DescriptorSetLayout *, std::string *) const;
+ bool IsCompatible(std::shared_ptr<DescriptorSetLayout> const, std::string *) const;
// For given bindings validate state at time of draw is correct, returning false on error and writing error details into string*
bool ValidateDrawState(const std::map<uint32_t, descriptor_req> &, const std::vector<uint32_t> &, const GLOBAL_CB_NODE *,
const char *caller, std::string *) const;
@@ -370,7 +363,7 @@ class DescriptorSet : public BASE_NODE {
// Perform a CopyUpdate whose contents were just validated using ValidateCopyUpdate
void PerformCopyUpdate(const VkCopyDescriptorSet *, const DescriptorSet *);
- const DescriptorSetLayout *GetLayout() const { return &p_layout_; };
+ std::shared_ptr<DescriptorSetLayout> const GetLayout() const { return p_layout_; };
VkDescriptorSet GetSet() const { return set_; };
// Return unordered_set of all command buffers that this set is bound to
std::unordered_set<GLOBAL_CB_NODE *> GetBoundCmdBuffers() const { return cb_bindings; }
@@ -379,14 +372,14 @@ class DescriptorSet : public BASE_NODE {
// If given cmd_buffer is in the cb_bindings set, remove it
void RemoveBoundCommandBuffer(GLOBAL_CB_NODE *cb_node) { cb_bindings.erase(cb_node); }
VkSampler const *GetImmutableSamplerPtrFromBinding(const uint32_t index) const {
- return p_layout_.GetImmutableSamplerPtrFromBinding(index);
+ return p_layout_->GetImmutableSamplerPtrFromBinding(index);
};
// For a particular binding, get the global index
uint32_t GetGlobalStartIndexFromBinding(const uint32_t binding) const {
- return p_layout_.GetGlobalStartIndexFromBinding(binding);
+ return p_layout_->GetGlobalStartIndexFromBinding(binding);
};
uint32_t GetGlobalEndIndexFromBinding(const uint32_t binding) const {
- return p_layout_.GetGlobalEndIndexFromBinding(binding);
+ return p_layout_->GetGlobalEndIndexFromBinding(binding);
};
// Return true if any part of set has ever been updated
bool IsUpdated() const { return some_update_; };
@@ -404,7 +397,7 @@ class DescriptorSet : public BASE_NODE {
bool some_update_; // has any part of the set ever been updated?
VkDescriptorSet set_;
DESCRIPTOR_POOL_STATE *pool_state_;
- const DescriptorSetLayout p_layout_;
+ const std::shared_ptr<DescriptorSetLayout> p_layout_;
std::vector<std::unique_ptr<Descriptor>> descriptors_;
// Ptr to device data used for various data look-ups
const core_validation::layer_data *device_data_;