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>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user