mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 05:38:16 +02:00
venus: simplify push descriptor update with template
No need to track is_push_descriptor in templ. No need to conditionally decide to use set or NULL handle since we pass NULL handle from the cmd side. Also fixed the arg type mismatch in the template helper. Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28686>
This commit is contained in:
parent
4c6b9e2fbe
commit
498f1d7eb1
3 changed files with 17 additions and 22 deletions
|
|
@ -2237,7 +2237,7 @@ vn_CmdPushDescriptorSetWithTemplateKHR(
|
|||
vn_update_descriptor_set_with_template_locked(templ, VK_NULL_HANDLE,
|
||||
pData);
|
||||
VN_CMD_ENQUEUE(vkCmdPushDescriptorSetKHR, commandBuffer,
|
||||
templ->pipeline_bind_point, layout, set,
|
||||
templ->push.pipeline_bind_point, layout, set,
|
||||
update->write_count, update->writes);
|
||||
|
||||
mtx_unlock(&templ->mutex);
|
||||
|
|
|
|||
|
|
@ -1040,13 +1040,12 @@ vn_CreateDescriptorUpdateTemplate(
|
|||
return vn_error(dev->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
templ->is_push_descriptor =
|
||||
pCreateInfo->templateType ==
|
||||
VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR;
|
||||
if (templ->is_push_descriptor) {
|
||||
templ->pipeline_bind_point = pCreateInfo->pipelineBindPoint;
|
||||
templ->pipeline_layout =
|
||||
if (pCreateInfo->templateType ==
|
||||
VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR) {
|
||||
struct vn_pipeline_layout *pipeline_layout =
|
||||
vn_pipeline_layout_from_handle(pCreateInfo->pipelineLayout);
|
||||
templ->push.pipeline_bind_point = pCreateInfo->pipelineBindPoint;
|
||||
templ->push.set_layout = pipeline_layout->push_descriptor_set_layout;
|
||||
}
|
||||
|
||||
mtx_init(&templ->mutex, mtx_plain);
|
||||
|
|
@ -1086,27 +1085,23 @@ vn_DestroyDescriptorUpdateTemplate(
|
|||
struct vn_update_descriptor_sets *
|
||||
vn_update_descriptor_set_with_template_locked(
|
||||
struct vn_descriptor_update_template *templ,
|
||||
struct vn_descriptor_set *set,
|
||||
VkDescriptorSet set_handle,
|
||||
const void *data)
|
||||
{
|
||||
struct vn_update_descriptor_sets *update = templ->update;
|
||||
struct vn_descriptor_set *set = vn_descriptor_set_from_handle(set_handle);
|
||||
|
||||
for (uint32_t i = 0; i < update->write_count; i++) {
|
||||
const struct vn_descriptor_update_template_entry *entry =
|
||||
&templ->entries[i];
|
||||
|
||||
const struct vn_descriptor_set_layout *set_layout =
|
||||
templ->is_push_descriptor
|
||||
? templ->pipeline_layout->push_descriptor_set_layout
|
||||
: set->layout;
|
||||
templ->push.set_layout ? templ->push.set_layout : set->layout;
|
||||
const struct vn_descriptor_set_layout_binding *binding =
|
||||
&set_layout->bindings[update->writes[i].dstBinding];
|
||||
|
||||
VkWriteDescriptorSet *write = &update->writes[i];
|
||||
|
||||
write->dstSet = templ->is_push_descriptor
|
||||
? VK_NULL_HANDLE
|
||||
: vn_descriptor_set_to_handle(set);
|
||||
write->dstSet = set_handle;
|
||||
|
||||
switch (write->descriptorType) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
|
|
@ -1179,12 +1174,11 @@ vn_UpdateDescriptorSetWithTemplate(
|
|||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
struct vn_descriptor_update_template *templ =
|
||||
vn_descriptor_update_template_from_handle(descriptorUpdateTemplate);
|
||||
struct vn_descriptor_set *set =
|
||||
vn_descriptor_set_from_handle(descriptorSet);
|
||||
mtx_lock(&templ->mutex);
|
||||
|
||||
struct vn_update_descriptor_sets *update =
|
||||
vn_update_descriptor_set_with_template_locked(templ, set, pData);
|
||||
vn_update_descriptor_set_with_template_locked(templ, descriptorSet,
|
||||
pData);
|
||||
|
||||
vn_async_vkUpdateDescriptorSets(dev->primary_ring, device,
|
||||
update->write_count, update->writes, 0,
|
||||
|
|
|
|||
|
|
@ -116,9 +116,10 @@ struct vn_descriptor_update_template_entry {
|
|||
struct vn_descriptor_update_template {
|
||||
struct vn_object_base base;
|
||||
|
||||
bool is_push_descriptor;
|
||||
VkPipelineBindPoint pipeline_bind_point;
|
||||
struct vn_pipeline_layout *pipeline_layout;
|
||||
struct {
|
||||
VkPipelineBindPoint pipeline_bind_point;
|
||||
struct vn_descriptor_set_layout *set_layout;
|
||||
} push;
|
||||
|
||||
mtx_t mutex;
|
||||
struct vn_update_descriptor_sets *update;
|
||||
|
|
@ -148,7 +149,7 @@ vn_descriptor_set_get_writes(uint32_t write_count,
|
|||
struct vn_update_descriptor_sets *
|
||||
vn_update_descriptor_set_with_template_locked(
|
||||
struct vn_descriptor_update_template *templ,
|
||||
struct vn_descriptor_set *set,
|
||||
VkDescriptorSet set_handle,
|
||||
const void *data);
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue