mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
zink: add scaling factor for descriptor set bucket allocations
now descriptor sets allocate in increasingly large batches based on how many sets a program has allocated, multiplying by 10 any time the sets hit a power of 10, e.g., if 100 sets are allocated, we now allocate in batches of 100 Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9348>
This commit is contained in:
parent
bd78710d21
commit
840ea21fa1
1 changed files with 37 additions and 29 deletions
|
|
@ -674,6 +674,42 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct zink_descriptor_set *
|
||||
allocate_desc_set(struct zink_screen *screen, struct zink_program *pg, unsigned descs_used)
|
||||
{
|
||||
VkDescriptorSetAllocateInfo dsai;
|
||||
#define DESC_BUCKET_FACTOR 10
|
||||
unsigned bucket_size = DESC_BUCKET_FACTOR;
|
||||
for (unsigned desc_factor = DESC_BUCKET_FACTOR; desc_factor < descs_used; desc_factor *= DESC_BUCKET_FACTOR)
|
||||
bucket_size = desc_factor;
|
||||
VkDescriptorSetLayout layouts[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 = bucket_size;
|
||||
for (unsigned i = 0; i < bucket_size; i ++)
|
||||
layouts[i] = pg->dsl;
|
||||
dsai.pSetLayouts = layouts;
|
||||
|
||||
VkDescriptorSet desc_set[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;
|
||||
}
|
||||
|
||||
struct zink_descriptor_set *alloc = ralloc_array(pg, struct zink_descriptor_set, bucket_size);
|
||||
assert(alloc);
|
||||
for (unsigned i = 0; i < bucket_size; i ++) {
|
||||
struct zink_descriptor_set *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);
|
||||
}
|
||||
return alloc;
|
||||
}
|
||||
|
||||
struct zink_descriptor_set *
|
||||
zink_program_allocate_desc_set(struct zink_context *ctx,
|
||||
struct zink_batch *batch,
|
||||
|
|
@ -695,35 +731,7 @@ zink_program_allocate_desc_set(struct zink_context *ctx,
|
|||
return zink_program_allocate_desc_set(ctx, batch, pg);
|
||||
}
|
||||
|
||||
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 = DESC_BUCKET_SIZE;
|
||||
for (unsigned i = 0; i < DESC_BUCKET_SIZE; i ++)
|
||||
layouts[i] = pg->dsl;
|
||||
dsai.pSetLayouts = layouts;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
zds = allocate_desc_set(screen, pg, descs_used);
|
||||
out:
|
||||
if (zink_batch_add_desc_set(batch, pg, zds))
|
||||
batch->descs_used += pg->num_descriptors;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue