mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
vulkan/runtime: Compact descriptor update templates
Get rid of any zero-sized entries so drivers never even have to think about this case when using templates. Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Acked-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14780>
This commit is contained in:
parent
74cebc5d5d
commit
c63cb7f4d2
1 changed files with 15 additions and 5 deletions
|
|
@ -37,8 +37,13 @@ vk_common_CreateDescriptorUpdateTemplate(VkDevice _device,
|
|||
VK_FROM_HANDLE(vk_device, device, _device);
|
||||
struct vk_descriptor_update_template *template;
|
||||
|
||||
size_t size = sizeof(*template) +
|
||||
pCreateInfo->descriptorUpdateEntryCount * sizeof(template->entries[0]);
|
||||
uint32_t entry_count = 0;
|
||||
for (uint32_t i = 0; i < pCreateInfo->descriptorUpdateEntryCount; i++) {
|
||||
if (pCreateInfo->pDescriptorUpdateEntries[i].descriptorCount > 0)
|
||||
entry_count++;
|
||||
}
|
||||
|
||||
size_t size = sizeof(*template) + entry_count * sizeof(template->entries[0]);
|
||||
template = vk_object_alloc(device, pAllocator, size,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE);
|
||||
if (template == NULL)
|
||||
|
|
@ -50,12 +55,16 @@ vk_common_CreateDescriptorUpdateTemplate(VkDevice _device,
|
|||
if (template->type == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)
|
||||
template->set = pCreateInfo->set;
|
||||
|
||||
template->entry_count = pCreateInfo->descriptorUpdateEntryCount;
|
||||
for (uint32_t i = 0; i < template->entry_count; i++) {
|
||||
uint32_t entry_idx = 0;
|
||||
template->entry_count = entry_count;
|
||||
for (uint32_t i = 0; i < pCreateInfo->descriptorUpdateEntryCount; i++) {
|
||||
const VkDescriptorUpdateTemplateEntry *pEntry =
|
||||
&pCreateInfo->pDescriptorUpdateEntries[i];
|
||||
|
||||
template->entries[i] = (struct vk_descriptor_template_entry) {
|
||||
if (pEntry->descriptorCount == 0)
|
||||
continue;
|
||||
|
||||
template->entries[entry_idx++] = (struct vk_descriptor_template_entry) {
|
||||
.type = pEntry->descriptorType,
|
||||
.binding = pEntry->dstBinding,
|
||||
.array_element = pEntry->dstArrayElement,
|
||||
|
|
@ -64,6 +73,7 @@ vk_common_CreateDescriptorUpdateTemplate(VkDevice _device,
|
|||
.stride = pEntry->stride,
|
||||
};
|
||||
}
|
||||
assert(entry_idx == entry_count);
|
||||
|
||||
*pDescriptorUpdateTemplate =
|
||||
vk_descriptor_update_template_to_handle(template);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue