From a8caf451cb3fdd2d0cd773125bd9311d73591e56 Mon Sep 17 00:00:00 2001 From: "Thomas H.P. Andersen" Date: Fri, 16 Sep 2022 00:50:04 +0200 Subject: [PATCH] v3dv: use common code for descriptor update template MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use the common code and structs for this. Depends on !14780 Reviewed-by: Alejandro Piñeiro Part-of: --- src/broadcom/vulkan/v3dv_descriptor_set.c | 64 +------------------------------ src/broadcom/vulkan/v3dv_private.h | 43 +-------------------- 2 files changed, 3 insertions(+), 104 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_descriptor_set.c b/src/broadcom/vulkan/v3dv_descriptor_set.c index c53e93d..beead08 100644 --- a/src/broadcom/vulkan/v3dv_descriptor_set.c +++ b/src/broadcom/vulkan/v3dv_descriptor_set.c @@ -1385,66 +1385,6 @@ v3dv_GetDescriptorSetLayoutSupport( pSupport->supported = supported; } -VkResult -v3dv_CreateDescriptorUpdateTemplate( - VkDevice _device, - const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate) -{ - V3DV_FROM_HANDLE(v3dv_device, device, _device); - struct v3dv_descriptor_update_template *template; - - size_t size = sizeof(*template) + - pCreateInfo->descriptorUpdateEntryCount * sizeof(template->entries[0]); - template = vk_object_alloc(&device->vk, pAllocator, size, - VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE); - if (template == NULL) - return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - - template->bind_point = pCreateInfo->pipelineBindPoint; - - assert(pCreateInfo->templateType == - 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++) { - const VkDescriptorUpdateTemplateEntry *pEntry = - &pCreateInfo->pDescriptorUpdateEntries[i]; - - template->entries[i] = (struct v3dv_descriptor_template_entry) { - .type = pEntry->descriptorType, - .binding = pEntry->dstBinding, - .array_element = pEntry->dstArrayElement, - .array_count = pEntry->descriptorCount, - .offset = pEntry->offset, - .stride = pEntry->stride, - }; - } - - *pDescriptorUpdateTemplate = - v3dv_descriptor_update_template_to_handle(template); - - return VK_SUCCESS; -} - -void -v3dv_DestroyDescriptorUpdateTemplate( - VkDevice _device, - VkDescriptorUpdateTemplate descriptorUpdateTemplate, - const VkAllocationCallbacks *pAllocator) -{ - V3DV_FROM_HANDLE(v3dv_device, device, _device); - V3DV_FROM_HANDLE(v3dv_descriptor_update_template, template, - descriptorUpdateTemplate); - - if (!template) - return; - - vk_object_free(&device->vk, pAllocator, template); -} - void v3dv_UpdateDescriptorSetWithTemplate( VkDevice _device, @@ -1454,11 +1394,11 @@ v3dv_UpdateDescriptorSetWithTemplate( { V3DV_FROM_HANDLE(v3dv_device, device, _device); V3DV_FROM_HANDLE(v3dv_descriptor_set, set, descriptorSet); - V3DV_FROM_HANDLE(v3dv_descriptor_update_template, template, + V3DV_FROM_HANDLE(vk_descriptor_update_template, template, descriptorUpdateTemplate); for (int i = 0; i < template->entry_count; i++) { - const struct v3dv_descriptor_template_entry *entry = + const struct vk_descriptor_template_entry *entry = &template->entries[i]; const struct v3dv_descriptor_set_binding_layout *binding_layout = diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index 0f39565..624f11e 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -36,6 +36,7 @@ #include #include +#include "vk_descriptor_update_template.h" #include "vk_device.h" #include "vk_format.h" #include "vk_instance.h" @@ -2131,45 +2132,6 @@ struct v3dv_sampler { uint8_t sampler_state[V3DV_SAMPLER_STATE_LENGTH]; }; -struct v3dv_descriptor_template_entry { - /* The type of descriptor in this entry */ - VkDescriptorType type; - - /* Binding in the descriptor set */ - uint32_t binding; - - /* Offset at which to write into the descriptor set binding */ - uint32_t array_element; - - /* Number of elements to write into the descriptor set binding */ - uint32_t array_count; - - /* Offset into the user provided data */ - size_t offset; - - /* Stride between elements into the user provided data */ - size_t stride; -}; - -struct v3dv_descriptor_update_template { - struct vk_object_base base; - - VkPipelineBindPoint bind_point; - - /* The descriptor set this template corresponds to. This value is only - * valid if the template was created with the templateType - * VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET. - */ - uint8_t set; - - /* Number of entries in this template */ - uint32_t entry_count; - - /* Entries of the template */ - struct v3dv_descriptor_template_entry entries[0]; -}; - - /* We keep two special values for the sampler idx that represents exactly when a * sampler is not needed/provided. The main use is that even if we don't have * sampler, we still need to do the output unpacking (through @@ -2559,9 +2521,6 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_set, base, VkDescriptorSet, VK_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_set_layout, base, VkDescriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) -VK_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_update_template, base, - VkDescriptorUpdateTemplate, - VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE) VK_DEFINE_NONDISP_HANDLE_CASTS(v3dv_event, base, VkEvent, VK_OBJECT_TYPE_EVENT) VK_DEFINE_NONDISP_HANDLE_CASTS(v3dv_framebuffer, base, VkFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER) -- 2.7.4