Module: Mesa
Branch: main
Commit: d2b1a7c2bb324a8ccf7390da4166488aa1077866
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2b1a7c2bb324a8ccf7390da4166488aa1077866

Author: Yiwei Zhang <[email protected]>
Date:   Tue Aug 24 20:57:23 2021 +0000

venus: layout to track variable descriptor count binding info

Signed-off-by: Yiwei Zhang <[email protected]>
Reviewed-by: Chia-I Wu <[email protected]>
Reviewed-by: Ryan Neph <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>

---

 src/virtio/vulkan/vn_descriptor_set.c | 33 +++++++++++++++++++++++++++++++++
 src/virtio/vulkan/vn_descriptor_set.h |  1 +
 2 files changed, 34 insertions(+)

diff --git a/src/virtio/vulkan/vn_descriptor_set.c 
b/src/virtio/vulkan/vn_descriptor_set.c
index 6ca51d3f2ed..a892665b98f 100644
--- a/src/virtio/vulkan/vn_descriptor_set.c
+++ b/src/virtio/vulkan/vn_descriptor_set.c
@@ -42,6 +42,18 @@ vn_descriptor_set_layout_init(
    VkDevice dev_handle = vn_device_to_handle(dev);
    VkDescriptorSetLayout layout_handle =
       vn_descriptor_set_layout_to_handle(layout);
+   const VkDescriptorSetLayoutBindingFlagsCreateInfo *binding_flags =
+      vk_find_struct_const(create_info->pNext,
+                           DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO);
+
+   /* 14.2.1. Descriptor Set Layout
+    *
+    * If bindingCount is zero or if this structure is not included in
+    * the pNext chain, the VkDescriptorBindingFlags for each descriptor
+    * set layout binding is considered to be zero.
+    */
+   if (binding_flags && !binding_flags->bindingCount)
+      binding_flags = NULL;
 
    layout->last_binding = last_binding;
 
@@ -51,6 +63,27 @@ vn_descriptor_set_layout_init(
       struct vn_descriptor_set_layout_binding *binding =
          &layout->bindings[binding_info->binding];
 
+      if (binding_info->binding == last_binding) {
+         /* 14.2.1. Descriptor Set Layout
+          *
+          * VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT must only be
+          * used for the last binding in the descriptor set layout (i.e. the
+          * binding with the largest value of binding).
+          *
+          * 41. Features
+          *
+          * descriptorBindingVariableDescriptorCount indicates whether the
+          * implementation supports descriptor sets with a variable-sized last
+          * binding. If this feature is not enabled,
+          * VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT must not be
+          * used.
+          */
+         layout->has_variable_descriptor_count =
+            binding_flags &&
+            (binding_flags->pBindingFlags[i] &
+             VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT);
+      }
+
       binding->type = binding_info->descriptorType;
       binding->count = binding_info->descriptorCount;
 
diff --git a/src/virtio/vulkan/vn_descriptor_set.h 
b/src/virtio/vulkan/vn_descriptor_set.h
index 0eb53519e26..85e7d2108b3 100644
--- a/src/virtio/vulkan/vn_descriptor_set.h
+++ b/src/virtio/vulkan/vn_descriptor_set.h
@@ -23,6 +23,7 @@ struct vn_descriptor_set_layout {
    struct vn_object_base base;
 
    uint32_t last_binding;
+   bool has_variable_descriptor_count;
 
    /* bindings must be the last field in the layout */
    struct vn_descriptor_set_layout_binding bindings[];

Reply via email to