mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
zink: add bucket allocating for descriptor sets
now instead of allocating a single descriptorset at a time, we allocate a defined count of descriptorsets (currently 10) at once and keep a separate array of allocated-and-unused sets that we can pop sets off of Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9348>
This commit is contained in:
parent
4461a871b8
commit
bd78710d21
1 changed files with 20 additions and 9 deletions
|
|
@ -696,23 +696,34 @@ zink_program_allocate_desc_set(struct zink_context *ctx,
|
|||
}
|
||||
|
||||
VkDescriptorSetAllocateInfo dsai;
|
||||
#define DESC_BUCKET_SIZE 10
|
||||
VkDescriptorSetLayout layouts[DESC_BUCKET_SIZE];
|
||||
memset((void *)&dsai, 0, sizeof(dsai));
|
||||
dsai.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
dsai.pNext = NULL;
|
||||
dsai.descriptorPool = pg->descpool;
|
||||
dsai.descriptorSetCount = 1;
|
||||
dsai.pSetLayouts = &pg->dsl;
|
||||
dsai.descriptorSetCount = DESC_BUCKET_SIZE;
|
||||
for (unsigned i = 0; i < DESC_BUCKET_SIZE; i ++)
|
||||
layouts[i] = pg->dsl;
|
||||
dsai.pSetLayouts = layouts;
|
||||
|
||||
VkDescriptorSet desc_set;
|
||||
if (vkAllocateDescriptorSets(screen->dev, &dsai, &desc_set) != VK_SUCCESS) {
|
||||
VkDescriptorSet desc_set[DESC_BUCKET_SIZE] = {};
|
||||
if (vkAllocateDescriptorSets(screen->dev, &dsai, desc_set) != VK_SUCCESS) {
|
||||
debug_printf("ZINK: %p failed to allocate descriptor set :/\n", pg);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
zds = ralloc_size(NULL, sizeof(struct zink_descriptor_set));
|
||||
assert(zds);
|
||||
pipe_reference_init(&zds->reference, 1);
|
||||
zds->desc_set = desc_set;
|
||||
pg->descs_used++;
|
||||
|
||||
struct zink_descriptor_set *alloc = ralloc_array(pg, struct zink_descriptor_set, DESC_BUCKET_SIZE);
|
||||
assert(alloc);
|
||||
for (unsigned i = 0; i < DESC_BUCKET_SIZE; i ++) {
|
||||
zds = &alloc[i];
|
||||
pipe_reference_init(&zds->reference, 1);
|
||||
zds->desc_set = desc_set[i];
|
||||
if (i > 0)
|
||||
util_dynarray_append(&pg->alloc_desc_sets, struct zink_descriptor_set *, zds);
|
||||
}
|
||||
pg->descs_used += DESC_BUCKET_SIZE;
|
||||
zds = alloc;
|
||||
out:
|
||||
if (zink_batch_add_desc_set(batch, pg, zds))
|
||||
batch->descs_used += pg->num_descriptors;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue