layers: Add GetNextValidBinding function to CV
authorMark Lobodzinski <mark@lunarg.com>
Fri, 10 Mar 2017 16:14:00 +0000 (09:14 -0700)
committerMark Lobodzinski <mark@lunarg.com>
Mon, 13 Mar 2017 14:53:38 +0000 (08:53 -0600)
Change-Id: Ifaa7aea1c7569ffaf5d417a1cd5caadaa38c96b0

layers/descriptor_sets.cpp
layers/descriptor_sets.h

index 469eb4d281ccea8811c7d82d71ea54923fddbac2..b697e01a1319c914f1d9ae5891670248da3e8a9f 100644 (file)
@@ -193,6 +193,14 @@ VkSampler const *cvdescriptorset::DescriptorSetLayout::GetImmutableSamplerPtrFro
     }
     return nullptr;
 }
+// Move to next valid binding having a non-zero binding count
+uint32_t cvdescriptorset::DescriptorSetLayout::GetNextValidBinding(const uint32_t binding) const {
+    uint32_t new_binding = binding;
+    do {
+        new_binding++;
+    } while (GetDescriptorCountFromBinding(new_binding) == 0);
+    return new_binding;
+}
 // For given index, return ptr to ImmutableSampler array
 VkSampler const *cvdescriptorset::DescriptorSetLayout::GetImmutableSamplerPtrFromIndex(const uint32_t index) const {
     assert(index < bindings_.size());
@@ -1162,11 +1170,7 @@ void cvdescriptorset::PerformUpdateDescriptorSetsWithTemplateKHR(layer_data *dev
 
             if (dst_array_element >= binding_count) {
                 dst_array_element = 0;
-                // Move to next binding having a non-zero binding count
-                do {
-                    binding_being_updated++;
-                    binding_count = layout_obj->GetDescriptorCountFromBinding(binding_being_updated);
-                } while (binding_count == 0);
+                binding_being_updated = layout_obj->GetNextValidBinding(binding_being_updated);
             }
 
             write_entry.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
index 9d9a15dfb582db179a9ef261857055820a54e6fd..c842aed21ff56ad8a8be5adea8983283bed6a4bc 100644 (file)
@@ -137,6 +137,8 @@ class DescriptorSetLayout {
     //  These calls should be guarded by a call to "HasBinding(binding)" to verify that the given binding exists
     uint32_t GetGlobalStartIndexFromBinding(const uint32_t) const;
     uint32_t GetGlobalEndIndexFromBinding(const uint32_t) const;
+    // Helper function to get the next valid binding for a descriptor
+    uint32_t GetNextValidBinding(const uint32_t) const;
     // For a particular binding starting at offset and having update_count descriptors
     //  updated, verify that for any binding boundaries crossed, the update is consistent
     bool VerifyUpdateConsistency(uint32_t, uint32_t, uint32_t, const char *, const VkDescriptorSet, std::string *) const;