From 9b4a2f3e28a9f5c575767c820a82d6baf912f5a2 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Thu, 15 Dec 2016 07:51:20 -0700 Subject: layers:Refactor consecutive descriptor count Refactor GetConsecutiveDescriptorCountFromBinding() to use the fact that bindings are now stored in-order. No longer need to chase binding order through the map, just get current binding index and then parse rest of the binding array in-order. --- layers/descriptor_sets.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'layers/descriptor_sets.cpp') diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 4b748381..f7baeb0a 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -97,18 +97,6 @@ bool cvdescriptorset::DescriptorSetLayout::ValidateCreateInfo(debug_report_data return skip; } -// Return the number of descriptors for the given binding and all successive bindings -uint32_t cvdescriptorset::DescriptorSetLayout::GetConsecutiveDescriptorCountFromBinding(uint32_t binding) const { - // If binding is invalid we'll return 0 - uint32_t binding_count = 0; - auto bi_itr = binding_to_index_map_.find(binding); - while (bi_itr != binding_to_index_map_.end()) { - binding_count += bindings_[bi_itr->second].descriptorCount; - bi_itr++; - } - return binding_count; -} - // put all bindings into the given set void cvdescriptorset::DescriptorSetLayout::FillBindingSet(std::unordered_set *binding_set) const { for (auto binding_index_pair : binding_to_index_map_) @@ -1215,12 +1203,11 @@ bool cvdescriptorset::DescriptorSet::ValidateWriteUpdate(const debug_report_data *error_msg = error_str.str(); return false; } - if (update->descriptorCount > - (p_layout_->GetConsecutiveDescriptorCountFromBinding(update->dstBinding) - update->dstArrayElement)) { + if (update->descriptorCount > (descriptors_.size() - start_idx)) { *error_code = VALIDATION_ERROR_00938; std::stringstream error_str; error_str << "Attempting write update to descriptor set " << set_ << " binding #" << update->dstBinding << " with " - << p_layout_->GetConsecutiveDescriptorCountFromBinding(update->dstBinding) + << descriptors_.size() - start_idx << " descriptors in that binding and all successive bindings of the set, but update of " << update->descriptorCount << " descriptors combined with update array element offset of " << update->dstArrayElement << " oversteps the available number of consecutive descriptors"; -- cgit v1.2.3