blob: c91fb0ba340fdd54a9826c72966b327f54693744 [file] [log] [blame]
From d2b1a7c2bb324a8ccf7390da4166488aa1077866 Mon Sep 17 00:00:00 2001
From: Yiwei Zhang <zzyiwei@chromium.org>
Date: Tue, 24 Aug 2021 20:57:23 +0000
Subject: [PATCH 4/8] venus: layout to track variable descriptor count binding
info
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
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[];
--
2.33.0.259.gc128427fd7-goog