layers: Add interface to get descriptor type from layout's global index

We match up dynamic descriptor offsets one at a time so added an interface
to get descriptor type from the global index in addition to the original
pBinding index. This allows us to iterate over all of the descriptors in a
set and easily grab their type.
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 1b6c9fe..8d4a387 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -7001,7 +7001,7 @@
                             // Validate Dynamic Offset Minimums
                             uint32_t cur_dyn_offset = totalDynamicDescriptors;
                             for (uint32_t d = 0; d < pSet->descriptorCount; d++) {
-                                if (pSet->p_layout->GetTypeFromIndex(d) == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
+                                if (pSet->p_layout->GetTypeFromGlobalIndex(d) == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
                                     if (vk_safe_modulo(
                                             pDynamicOffsets[cur_dyn_offset],
                                             dev_data->phys_dev_properties.properties.limits.minUniformBufferOffsetAlignment) != 0) {
@@ -7015,7 +7015,7 @@
                                             dev_data->phys_dev_properties.properties.limits.minUniformBufferOffsetAlignment);
                                     }
                                     cur_dyn_offset++;
-                                } else if (pSet->p_layout->GetTypeFromIndex(d) == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
+                                } else if (pSet->p_layout->GetTypeFromGlobalIndex(d) == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
                                     if (vk_safe_modulo(
                                             pDynamicOffsets[cur_dyn_offset],
                                             dev_data->phys_dev_properties.properties.limits.minStorageBufferOffsetAlignment) != 0) {
diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h
index 8911910..7f0fd4f 100644
--- a/layers/descriptor_sets.h
+++ b/layers/descriptor_sets.h
@@ -104,6 +104,7 @@
     uint32_t GetDescriptorCountFromIndex(const uint32_t);
     VkDescriptorType GetTypeFromBinding(const uint32_t);
     VkDescriptorType GetTypeFromIndex(const uint32_t);
+    VkDescriptorType GetTypeFromGlobalIndex(const uint32_t);
     VkShaderStageFlags GetStageFlagsFromBinding(const uint32_t);
     VkSampler const *GetImmutableSamplerPtrFromBinding(const uint32_t);
     // For a particular binding, get the global index
@@ -191,6 +192,17 @@
     assert(index < bindings_.size());
     return bindings_[index]->descriptorType;
 }
+// For the given global index, return descriptorType
+//  Currently just counting up through bindings_, may improve this in future
+VkDescriptorType DescriptorSetLayout::GetTypeFromGlobalIndex(const uint32_t index) {
+    auto global_offset = 0;
+    for (auto binding : bindings_) {
+        global_offset += binding->descriptorCount;
+        if (index < global_offset)
+            return binding->descriptorType;
+    }
+    assert(0); // requested global index is out of bounds
+}
 // For the given binding, return stageFlags
 VkShaderStageFlags DescriptorSetLayout::GetStageFlagsFromBinding(const uint32_t binding) {
     assert(binding_to_index_map_.count(binding));