mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 13:00:09 +01:00
radv: use a linked-list for storing descriptor pool sets
Only when pool entries aren't freed yet. This will make the new allocation strategy much simpler. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37976>
This commit is contained in:
parent
4d33d3f507
commit
9b6d89f4ca
4 changed files with 20 additions and 15 deletions
|
|
@ -24,9 +24,10 @@ radv_destroy_descriptor_pool_entries(struct radv_device *device, struct radv_des
|
|||
radv_descriptor_set_destroy(device, pool, pool->entries[i].set, false);
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < pool->entry_count; ++i) {
|
||||
vk_descriptor_set_layout_unref(&device->vk, &pool->sets[i]->header.layout->vk);
|
||||
vk_object_base_finish(&pool->sets[i]->header.base);
|
||||
list_for_each_entry_safe (struct radv_descriptor_set, set, &pool->sets, link) {
|
||||
list_del(&set->link);
|
||||
vk_descriptor_set_layout_unref(&device->vk, &set->header.layout->vk);
|
||||
vk_object_base_finish(&set->header.base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,15 +142,10 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
|
|||
bo_size += 16 * MIN2(num_16byte_descriptors, pCreateInfo->maxSets);
|
||||
}
|
||||
|
||||
uint64_t sets_size = 0;
|
||||
|
||||
if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
|
||||
size += pCreateInfo->maxSets * sizeof(struct radv_descriptor_set);
|
||||
size += sizeof(struct radeon_winsys_bo *) * bo_count;
|
||||
size += sizeof(struct radv_descriptor_range) * range_count;
|
||||
|
||||
sets_size = sizeof(struct radv_descriptor_set *) * pCreateInfo->maxSets;
|
||||
size += sets_size;
|
||||
} else {
|
||||
size += sizeof(struct radv_descriptor_pool_entry) * pCreateInfo->maxSets;
|
||||
}
|
||||
|
|
@ -160,8 +156,10 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
|
|||
|
||||
vk_object_base_init(&device->vk, &pool->base, VK_OBJECT_TYPE_DESCRIPTOR_POOL);
|
||||
|
||||
list_inithead(&pool->sets);
|
||||
|
||||
if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
|
||||
pool->host_memory_base = (uint8_t *)pool + sizeof(struct radv_descriptor_pool) + sets_size;
|
||||
pool->host_memory_base = (uint8_t *)pool + sizeof(struct radv_descriptor_pool);
|
||||
pool->host_memory_ptr = pool->host_memory_base;
|
||||
pool->host_memory_end = (uint8_t *)pool + size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "util/list.h"
|
||||
|
||||
struct radv_descriptor_set;
|
||||
|
||||
struct radv_descriptor_pool_entry {
|
||||
|
|
@ -31,13 +33,12 @@ struct radv_descriptor_pool {
|
|||
uint8_t *host_memory_ptr;
|
||||
uint8_t *host_memory_end;
|
||||
|
||||
struct list_head sets;
|
||||
|
||||
uint32_t entry_count;
|
||||
uint32_t max_entry_count;
|
||||
|
||||
union {
|
||||
struct radv_descriptor_set *sets[0];
|
||||
struct radv_descriptor_pool_entry entries[0];
|
||||
};
|
||||
struct radv_descriptor_pool_entry entries[0];
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_pool, base, VkDescriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL)
|
||||
|
|
|
|||
|
|
@ -409,8 +409,9 @@ radv_alloc_descriptor_pool_entry(struct radv_device *device, struct radv_descrip
|
|||
if (current_offset + set->header.size > pool->size)
|
||||
return VK_ERROR_OUT_OF_POOL_MEMORY;
|
||||
|
||||
pool->sets[entry_index] = set;
|
||||
pool->current_offset += set->header.size;
|
||||
|
||||
list_addtail(&set->link, &pool->sets);
|
||||
}
|
||||
|
||||
set->header.bo = pool->bo;
|
||||
|
|
@ -438,7 +439,8 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
|
|||
unsigned stride = radv_descriptor_type_buffer_count(layout->binding[layout->binding_count - 1].type);
|
||||
buffer_count = layout->binding[layout->binding_count - 1].buffer_offset + variable_count * stride;
|
||||
}
|
||||
unsigned range_offset = sizeof(struct radv_descriptor_set_header) + sizeof(struct radeon_winsys_bo *) * buffer_count;
|
||||
unsigned range_offset = sizeof(struct radv_descriptor_set_header) + sizeof(struct list_head) +
|
||||
sizeof(struct radeon_winsys_bo *) * buffer_count;
|
||||
const unsigned dynamic_offset_count = layout->dynamic_offset_count;
|
||||
unsigned mem_size = range_offset + sizeof(struct radv_descriptor_range) * dynamic_offset_count;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef RADV_DESCRIPTOR_SET_H
|
||||
#define RADV_DESCRIPTOR_SET_H
|
||||
|
||||
#include "util/list.h"
|
||||
#include "util/mesa-blake3.h"
|
||||
|
||||
#include "radv_constants.h"
|
||||
|
|
@ -101,6 +102,9 @@ struct radv_descriptor_set_header {
|
|||
struct radv_descriptor_set {
|
||||
struct radv_descriptor_set_header header;
|
||||
|
||||
/* Link in radv_descriptor_pool::sets */
|
||||
struct list_head link;
|
||||
|
||||
struct radeon_winsys_bo *descriptors[];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue