anv/descriptor_set: Add a type field in debug builds
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 6 Jun 2016 16:12:50 +0000 (09:12 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 10 Jun 2016 16:42:59 +0000 (09:42 -0700)
This allows for some extra validation and makes it easier to see what's
going on when poking around in gdb.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
src/intel/vulkan/anv_descriptor_set.c
src/intel/vulkan/anv_private.h

index 3924d04310ef2696541a3f567cd75d919fa3e6ca..c977318a058b3e97990dcd4a958c69fa008ca112 100644 (file)
@@ -91,6 +91,9 @@ VkResult anv_CreateDescriptorSetLayout(
       uint32_t b = binding->binding;
 
       assert(binding->descriptorCount > 0);
+#ifndef NDEBUG
+      set_layout->binding[b].type = binding->descriptorType;
+#endif
       set_layout->binding[b].array_size = binding->descriptorCount;
       set_layout->binding[b].descriptor_index = set_layout->size;
       set_layout->size += binding->descriptorCount;
@@ -526,6 +529,8 @@ void anv_UpdateDescriptorSets(
          &set->descriptors[bind_layout->descriptor_index];
       desc += write->dstArrayElement;
 
+      assert(write->descriptorType == bind_layout->type);
+
       switch (write->descriptorType) {
       case VK_DESCRIPTOR_TYPE_SAMPLER:
          for (uint32_t j = 0; j < write->descriptorCount; j++) {
index 26ffbd65666cf0674a9a12d807aef5aa5497b80a..975cdfc33a117d87ac6795b42d60c7e748e907a6 100644 (file)
@@ -922,6 +922,11 @@ struct anv_vue_header {
 };
 
 struct anv_descriptor_set_binding_layout {
+#ifndef NDEBUG
+   /* The type of the descriptors in this binding */
+   VkDescriptorType type;
+#endif
+
    /* Number of array elements in this binding */
    uint16_t array_size;