Module: Mesa
Branch: main
Commit: 3ec428bb325e79d888ada8eb7e96add0f240eced
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ec428bb325e79d888ada8eb7e96add0f240eced

Author: Dave Airlie <[email protected]>
Date:   Wed Jan 11 16:19:04 2023 +1000

vk_cmd_queue: add a callback to free push descriptors set khr

This should clean this up properly.

Fixes: eb7eccc76f0a ("lavapipe: Use generated command queue code")
Reviewed-by: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20630>

---

 .../frontends/lavapipe/ci/lvp-asan-fails.txt       | 15 -----------
 src/vulkan/runtime/vk_cmd_enqueue.c                | 31 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/ci/lvp-asan-fails.txt 
b/src/gallium/frontends/lavapipe/ci/lvp-asan-fails.txt
index b2f048082ab..1fbe6b00a49 100644
--- a/src/gallium/frontends/lavapipe/ci/lvp-asan-fails.txt
+++ b/src/gallium/frontends/lavapipe/ci/lvp-asan-fails.txt
@@ -139,21 +139,6 @@ 
dEQP-VK.transform_feedback.primitives_generated_query.get.queue_reset.pgq_32bit_
 #     #2 0x7fcd0242f0c0 in vk_zalloc ../src/vulkan/util/vk_alloc.h:56
 #     #3 0x7fcd0242f0c0 in lvp_CreateDescriptorSetLayout 
../src/gallium/frontends/lavapipe/lvp_descriptor_set.c:65
 #     #4 0x55cd57134f28  
(/deqp/external/vulkancts/modules/vulkan/deqp-vk+0x226bf28)
-dEQP-VK.pipeline.monolithic.bind_point.graphics_compute.push_write.setup_cp_gs_cs_gp.cmd_draw_dispatch,Fail
-dEQP-VK.robustness.image_robustness.push.notemplate.r32f.unroll.nonvolatile.sampled_image.no_fmt_qual.img.samples_1.2d_array.comp,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.r32f.dontunroll.volatile.storage_buffer.readonly.no_fmt_qual.len_256.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.r32f.unroll.volatile.storage_texel_buffer.fmt_qual.len_32.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.r32i.unroll.nonvolatile.storage_image.fmt_qual.null_descriptor.samples_1.cube_array.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.r32ui.dontunroll.nonvolatile.sampled_image.no_fmt_qual.null_descriptor.samples_4.2d_array.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.r32ui.unroll.volatile.storage_buffer.readwrite.no_fmt_qual.len_36.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rg32f.dontunroll.volatile.storage_texel_buffer.fmt_qual.null_descriptor.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rg32i.unroll.nonvolatile.uniform_buffer.no_fmt_qual.len_33.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rg32ui.unroll.nonvolatile.sampled_image.no_fmt_qual.null_descriptor.samples_1.cube_array.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rgba32f.unroll.nonvolatile.storage_texel_buffer.fmt_qual.len_32.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rgba32i.dontunroll.nonvolatile.uniform_buffer.no_fmt_qual.len_33.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rgba32ui.dontunroll.volatile.storage_buffer.readwrite.no_fmt_qual.len_256.samples_1.1d.vert,Fail
-dEQP-VK.robustness.robustness2.push.notemplate.rgba32ui.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d.vert,Fail
-dEQP-VK.synchronization2.timeline_semaphore.one_to_n.write_copy_buffer_to_image_read_image_fragment.image_128x128_r16_uint,Fail
 
dEQP-VK.transform_feedback.primitives_generated_query.copy.host_reset.pgq_32bit_xfb_64bit.geom.xfb.rast.point_list.pgq_0_xfb_1.single_draw,Fail
 
dEQP-VK.transform_feedback.primitives_generated_query.copy.queue_reset.pgq_32bit_xfb_64bit.geom.xfb.no_rast.line_strip.pgq_default_xfb_0.single_draw,Fail
 
dEQP-VK.transform_feedback.primitives_generated_query.get.host_reset.64bit.geom.xfb.rast.triangle_fan.pgq_default_xfb_1.single_draw,Fail
diff --git a/src/vulkan/runtime/vk_cmd_enqueue.c 
b/src/vulkan/runtime/vk_cmd_enqueue.c
index f40c3a6693e..a56a1621abc 100644
--- a/src/vulkan/runtime/vk_cmd_enqueue.c
+++ b/src/vulkan/runtime/vk_cmd_enqueue.c
@@ -118,6 +118,36 @@ vk_cmd_enqueue_CmdDrawMultiIndexedEXT(VkCommandBuffer 
commandBuffer,
    }
 }
 
+static void
+push_descriptors_set_free(struct vk_cmd_queue *queue,
+                          struct vk_cmd_queue_entry *cmd)
+{
+  struct vk_cmd_push_descriptor_set_khr *pds = &cmd->u.push_descriptor_set_khr;
+  for (unsigned i = 0; i < pds->descriptor_write_count; i++) {
+    VkWriteDescriptorSet *entry = &pds->descriptor_writes[i];
+    switch (entry->descriptorType) {
+    case VK_DESCRIPTOR_TYPE_SAMPLER:
+    case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
+    case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
+    case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
+    case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
+       vk_free(queue->alloc, (void *)entry->pImageInfo);
+       break;
+    case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
+    case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
+       vk_free(queue->alloc, (void *)entry->pTexelBufferView);
+       break;
+    case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
+    case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
+    case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
+    case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
+    default:
+       vk_free(queue->alloc, (void *)entry->pBufferInfo);
+       break;
+    }
+  }
+}
+
 VKAPI_ATTR void VKAPI_CALL
 vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
                                        VkPipelineBindPoint pipelineBindPoint,
@@ -138,6 +168,7 @@ vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer 
commandBuffer,
    pds = &cmd->u.push_descriptor_set_khr;
 
    cmd->type = VK_CMD_PUSH_DESCRIPTOR_SET_KHR;
+   cmd->driver_free_cb = push_descriptors_set_free;
    list_addtail(&cmd->cmd_link, &cmd_buffer->cmd_queue.cmds);
 
    pds->pipeline_bind_point = pipelineBindPoint;

Reply via email to