| From a1e91b1163c84b79a0dde87cb7286d5a96ed1866 Mon Sep 17 00:00:00 2001 |
| From: Yiwei Zhang <zzyiwei@chromium.org> |
| Date: Fri, 20 Aug 2021 18:53:04 +0000 |
| Subject: [PATCH 5/8] venus: descriptor pool to track pool state |
| |
| It also tracks whether async set allocation is enabled. |
| |
| 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 | 19 +++++++++++++++++++ |
| src/virtio/vulkan/vn_descriptor_set.h | 14 ++++++++++++++ |
| 2 files changed, 33 insertions(+) |
| |
| diff --git a/src/virtio/vulkan/vn_descriptor_set.c b/src/virtio/vulkan/vn_descriptor_set.c |
| index a892665b98f..4b104e1aaf4 100644 |
| --- a/src/virtio/vulkan/vn_descriptor_set.c |
| +++ b/src/virtio/vulkan/vn_descriptor_set.c |
| @@ -213,6 +213,25 @@ vn_CreateDescriptorPool(VkDevice device, |
| &dev->base); |
| |
| pool->allocator = *alloc; |
| + |
| + /* Without VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, the set |
| + * allocation must not fail due to a fragmented pool per spec. In this |
| + * case, set allocation can be asynchronous with pool resource tracking. |
| + */ |
| + pool->async_set_allocation = !( |
| + pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT); |
| + |
| + pool->max.set_count = pCreateInfo->maxSets; |
| + |
| + for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) { |
| + const VkDescriptorPoolSize *pool_size = &pCreateInfo->pPoolSizes[i]; |
| + |
| + assert(pool_size->type < VN_NUM_DESCRIPTOR_TYPES); |
| + |
| + pool->max.descriptor_counts[pool_size->type] += |
| + pool_size->descriptorCount; |
| + } |
| + |
| list_inithead(&pool->descriptor_sets); |
| |
| VkDescriptorPool pool_handle = vn_descriptor_pool_to_handle(pool); |
| diff --git a/src/virtio/vulkan/vn_descriptor_set.h b/src/virtio/vulkan/vn_descriptor_set.h |
| index 85e7d2108b3..31611f74116 100644 |
| --- a/src/virtio/vulkan/vn_descriptor_set.h |
| +++ b/src/virtio/vulkan/vn_descriptor_set.h |
| @@ -13,6 +13,12 @@ |
| |
| #include "vn_common.h" |
| |
| +/* TODO accommodate new discrete type enums by: |
| + * 1. increase the number of types here |
| + * 2. add a helper to map to continuous array index |
| + */ |
| +#define VN_NUM_DESCRIPTOR_TYPES (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1) |
| + |
| struct vn_descriptor_set_layout_binding { |
| VkDescriptorType type; |
| uint32_t count; |
| @@ -33,10 +39,18 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set_layout, |
| VkDescriptorSetLayout, |
| VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) |
| |
| +struct vn_descriptor_pool_state { |
| + uint32_t set_count; |
| + uint32_t descriptor_counts[VN_NUM_DESCRIPTOR_TYPES]; |
| +}; |
| + |
| struct vn_descriptor_pool { |
| struct vn_object_base base; |
| |
| VkAllocationCallbacks allocator; |
| + bool async_set_allocation; |
| + struct vn_descriptor_pool_state max; |
| + |
| struct list_head descriptor_sets; |
| }; |
| VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_pool, |
| -- |
| 2.33.0.259.gc128427fd7-goog |
| |