[Mesa-dev] [PATCH 2/5] anv/descriptor_set: Add a type field in debug builds

Jason Ekstrand jason at jlekstrand.net
Mon Jun 6 18:26:29 UTC 2016


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 at jlekstrand.net>
Cc: Kristian Høgsberg Kristensen <krh at bitplanet.net>
---
 src/intel/vulkan/anv_descriptor_set.c | 5 +++++
 src/intel/vulkan/anv_private.h        | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 3924d04..c977318 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -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++) {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 26ffbd6..975cdfc 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -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;
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list