mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
v3dv: use common code for descriptor update template
Use the common code and structs for this. Depends on !14780 Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18625>
This commit is contained in:
parent
9ca5a81a6e
commit
a8caf451cb
2 changed files with 3 additions and 104 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include <vulkan/vk_icd.h>
|
||||
#include <vk_enum_to_str.h>
|
||||
|
||||
#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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue