| From d8e89b4e3304d601a516bbecb94af83ff03e70eb Mon Sep 17 00:00:00 2001 |
| From: Yiwei Zhang <zzyiwei@chromium.org> |
| Date: Fri, 20 Aug 2021 18:57:43 +0000 |
| Subject: [PATCH 3/8] venus: descriptor layout to track more binding infos |
| |
| Rename existing max_binding to last_binding to be consistent. |
| |
| 1. layout to track last binding index |
| 2. binding to track descriptor type |
| 3. binding to track descriptor count |
| |
| 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 | 16 +++++++++++----- |
| src/virtio/vulkan/vn_descriptor_set.h | 6 ++++++ |
| 2 files changed, 17 insertions(+), 5 deletions(-) |
| |
| diff --git a/src/virtio/vulkan/vn_descriptor_set.c b/src/virtio/vulkan/vn_descriptor_set.c |
| index 86bbd228635..6ca51d3f2ed 100644 |
| --- a/src/virtio/vulkan/vn_descriptor_set.c |
| +++ b/src/virtio/vulkan/vn_descriptor_set.c |
| @@ -36,18 +36,24 @@ static void |
| vn_descriptor_set_layout_init( |
| struct vn_device *dev, |
| const VkDescriptorSetLayoutCreateInfo *create_info, |
| + uint32_t last_binding, |
| struct vn_descriptor_set_layout *layout) |
| { |
| VkDevice dev_handle = vn_device_to_handle(dev); |
| VkDescriptorSetLayout layout_handle = |
| vn_descriptor_set_layout_to_handle(layout); |
| |
| + layout->last_binding = last_binding; |
| + |
| for (uint32_t i = 0; i < create_info->bindingCount; i++) { |
| const VkDescriptorSetLayoutBinding *binding_info = |
| &create_info->pBindings[i]; |
| struct vn_descriptor_set_layout_binding *binding = |
| &layout->bindings[binding_info->binding]; |
| |
| + binding->type = binding_info->descriptorType; |
| + binding->count = binding_info->descriptorCount; |
| + |
| switch (binding_info->descriptorType) { |
| case VK_DESCRIPTOR_TYPE_SAMPLER: |
| case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| @@ -73,7 +79,7 @@ vn_CreateDescriptorSetLayout( |
| const VkAllocationCallbacks *alloc = |
| pAllocator ? pAllocator : &dev->base.base.alloc; |
| |
| - uint32_t max_binding = 0; |
| + uint32_t last_binding = 0; |
| VkDescriptorSetLayoutBinding *local_bindings = NULL; |
| VkDescriptorSetLayoutCreateInfo local_create_info; |
| if (pCreateInfo->bindingCount) { |
| @@ -91,8 +97,8 @@ vn_CreateDescriptorSetLayout( |
| for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) { |
| VkDescriptorSetLayoutBinding *binding = &local_bindings[i]; |
| |
| - if (max_binding < binding->binding) |
| - max_binding = binding->binding; |
| + if (last_binding < binding->binding) |
| + last_binding = binding->binding; |
| |
| switch (binding->descriptorType) { |
| case VK_DESCRIPTOR_TYPE_SAMPLER: |
| @@ -110,7 +116,7 @@ vn_CreateDescriptorSetLayout( |
| } |
| |
| const size_t layout_size = |
| - offsetof(struct vn_descriptor_set_layout, bindings[max_binding + 1]); |
| + offsetof(struct vn_descriptor_set_layout, bindings[last_binding + 1]); |
| struct vn_descriptor_set_layout *layout = |
| vk_zalloc(alloc, layout_size, VN_DEFAULT_ALIGN, |
| VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
| @@ -122,7 +128,7 @@ vn_CreateDescriptorSetLayout( |
| vn_object_base_init(&layout->base, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, |
| &dev->base); |
| |
| - vn_descriptor_set_layout_init(dev, pCreateInfo, layout); |
| + vn_descriptor_set_layout_init(dev, pCreateInfo, last_binding, layout); |
| |
| vk_free(alloc, local_bindings); |
| |
| diff --git a/src/virtio/vulkan/vn_descriptor_set.h b/src/virtio/vulkan/vn_descriptor_set.h |
| index 923a3cf1a3a..0eb53519e26 100644 |
| --- a/src/virtio/vulkan/vn_descriptor_set.h |
| +++ b/src/virtio/vulkan/vn_descriptor_set.h |
| @@ -14,11 +14,17 @@ |
| #include "vn_common.h" |
| |
| struct vn_descriptor_set_layout_binding { |
| + VkDescriptorType type; |
| + uint32_t count; |
| bool has_immutable_samplers; |
| }; |
| |
| struct vn_descriptor_set_layout { |
| struct vn_object_base base; |
| + |
| + uint32_t last_binding; |
| + |
| + /* bindings must be the last field in the layout */ |
| struct vn_descriptor_set_layout_binding bindings[]; |
| }; |
| VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set_layout, |
| -- |
| 2.33.0.259.gc128427fd7-goog |
| |