From 25542f12d764f7fd6d5ade4da760d09d0d93cf43 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 10 Mar 2022 18:22:59 +0100 Subject: [PATCH] vulkan/cmd_queue: Fix the allocation scope VK_SYSTEM_ALLOCATION_SCOPE_COMMAND is used for transient allocations that are not expected to live outside the vkXxx(). Use VK_SYSTEM_ALLOCATION_SCOPE_OBJECT for cmd_entry allocations. v2 (Jason Ekstrand): - Also fix the manually typed entrypoints in vk_cmd_enqueue.c Signed-off-by: Boris Brezillon Reviewed-by: Jason Ekstrand Part-of: --- src/vulkan/runtime/vk_cmd_enqueue.c | 26 +++++++++++++------------- src/vulkan/util/vk_cmd_queue_gen.py | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/vulkan/runtime/vk_cmd_enqueue.c b/src/vulkan/runtime/vk_cmd_enqueue.c index 1cb91e1..ce3b530 100644 --- a/src/vulkan/runtime/vk_cmd_enqueue.c +++ b/src/vulkan/runtime/vk_cmd_enqueue.c @@ -40,7 +40,7 @@ vk_cmd_enqueue_CmdDrawMultiEXT(VkCommandBuffer commandBuffer, struct vk_cmd_queue_entry *cmd = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!cmd) return; @@ -53,7 +53,7 @@ vk_cmd_enqueue_CmdDrawMultiEXT(VkCommandBuffer commandBuffer, cmd->u.draw_multi_ext.vertex_info = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd->u.draw_multi_ext.vertex_info) * drawCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); vk_foreach_multi_draw(draw, i, pVertexInfo, drawCount, stride) { memcpy(&cmd->u.draw_multi_ext.vertex_info[i], draw, @@ -78,7 +78,7 @@ vk_cmd_enqueue_CmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, struct vk_cmd_queue_entry *cmd = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!cmd) return; @@ -92,7 +92,7 @@ vk_cmd_enqueue_CmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, cmd->u.draw_multi_indexed_ext.index_info = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd->u.draw_multi_indexed_ext.index_info) * drawCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); vk_foreach_multi_draw_indexed(draw, i, pIndexInfo, drawCount, stride) { cmd->u.draw_multi_indexed_ext.index_info[i].firstIndex = draw->firstIndex; @@ -110,7 +110,7 @@ vk_cmd_enqueue_CmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, cmd->u.draw_multi_indexed_ext.vertex_offset = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd->u.draw_multi_indexed_ext.vertex_offset), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy(cmd->u.draw_multi_indexed_ext.vertex_offset, pVertexOffset, sizeof(*cmd->u.draw_multi_indexed_ext.vertex_offset)); @@ -130,7 +130,7 @@ vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, struct vk_cmd_queue_entry *cmd = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!cmd) return; @@ -148,7 +148,7 @@ vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, pds->descriptor_writes = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*pds->descriptor_writes) * descriptorWriteCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy(pds->descriptor_writes, pDescriptorWrites, sizeof(*pds->descriptor_writes) * descriptorWriteCount); @@ -163,7 +163,7 @@ vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, pds->descriptor_writes[i].pImageInfo = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(VkDescriptorImageInfo) * pds->descriptor_writes[i].descriptorCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy((VkDescriptorImageInfo *)pds->descriptor_writes[i].pImageInfo, pDescriptorWrites[i].pImageInfo, sizeof(VkDescriptorImageInfo) * pds->descriptor_writes[i].descriptorCount); @@ -173,7 +173,7 @@ vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, pds->descriptor_writes[i].pTexelBufferView = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(VkBufferView) * pds->descriptor_writes[i].descriptorCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy((VkBufferView *)pds->descriptor_writes[i].pTexelBufferView, pDescriptorWrites[i].pTexelBufferView, sizeof(VkBufferView) * pds->descriptor_writes[i].descriptorCount); @@ -186,7 +186,7 @@ vk_cmd_enqueue_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, pds->descriptor_writes[i].pBufferInfo = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(VkDescriptorBufferInfo) * pds->descriptor_writes[i].descriptorCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy((VkDescriptorBufferInfo *)pds->descriptor_writes[i].pBufferInfo, pDescriptorWrites[i].pBufferInfo, sizeof(VkDescriptorBufferInfo) * pds->descriptor_writes[i].descriptorCount); @@ -224,7 +224,7 @@ vk_cmd_enqueue_CmdBindDescriptorSets(VkCommandBuffer commandBuffer, struct vk_cmd_queue_entry *cmd = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!cmd) return; @@ -246,7 +246,7 @@ vk_cmd_enqueue_CmdBindDescriptorSets(VkCommandBuffer commandBuffer, cmd->u.bind_descriptor_sets.descriptor_sets = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd->u.bind_descriptor_sets.descriptor_sets) * descriptorSetCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy(cmd->u.bind_descriptor_sets.descriptor_sets, pDescriptorSets, sizeof(*cmd->u.bind_descriptor_sets.descriptor_sets) * descriptorSetCount); @@ -256,7 +256,7 @@ vk_cmd_enqueue_CmdBindDescriptorSets(VkCommandBuffer commandBuffer, cmd->u.bind_descriptor_sets.dynamic_offsets = vk_zalloc(cmd_buffer->cmd_queue.alloc, sizeof(*cmd->u.bind_descriptor_sets.dynamic_offsets) * dynamicOffsetCount, 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); memcpy(cmd->u.bind_descriptor_sets.dynamic_offsets, pDynamicOffsets, sizeof(*cmd->u.bind_descriptor_sets.dynamic_offsets) * dynamicOffsetCount); diff --git a/src/vulkan/util/vk_cmd_queue_gen.py b/src/vulkan/util/vk_cmd_queue_gen.py index 02e75a5..540c2be 100644 --- a/src/vulkan/util/vk_cmd_queue_gen.py +++ b/src/vulkan/util/vk_cmd_queue_gen.py @@ -247,7 +247,7 @@ void vk_enqueue_${to_underscore(c.name)}(struct vk_cmd_queue *queue struct vk_cmd_queue_entry *cmd = vk_zalloc(queue->alloc, sizeof(*cmd), 8, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!cmd) goto err; cmd->type = ${to_enum_name(c.name)}; @@ -422,7 +422,7 @@ def get_array_copy(command, param): field_size = "1" else: field_size = "sizeof(*%s)" % field_name - allocation = "%s = vk_zalloc(queue->alloc, %s * %s, 8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);\n if (%s == NULL) goto err;\n" % (field_name, field_size, param.len, field_name) + allocation = "%s = vk_zalloc(queue->alloc, %s * %s, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);\n if (%s == NULL) goto err;\n" % (field_name, field_size, param.len, field_name) const_cast = remove_suffix(param.decl.replace("const", ""), param.name) copy = "memcpy((%s)%s, %s, %s * %s);" % (const_cast, field_name, param.name, field_size, param.len) return "%s\n %s" % (allocation, copy) @@ -433,7 +433,7 @@ def get_array_member_copy(struct, src_name, member): field_size = "sizeof(*%s)" % (field_name) else: field_size = "sizeof(*%s) * %s->%s" % (field_name, struct, member.len) - allocation = "%s = vk_zalloc(queue->alloc, %s, 8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);\n if (%s == NULL) goto err;\n" % (field_name, field_size, field_name) + allocation = "%s = vk_zalloc(queue->alloc, %s, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);\n if (%s == NULL) goto err;\n" % (field_name, field_size, field_name) const_cast = remove_suffix(member.decl.replace("const", ""), member.name) copy = "memcpy((%s)%s, %s->%s, %s);" % (const_cast, field_name, src_name, member.name, field_size) return "if (%s->%s) {\n %s\n %s\n}\n" % (src_name, member.name, allocation, copy) @@ -463,7 +463,7 @@ def get_struct_copy(dst, src_name, src_type, size, types, level=0): global tmp_dst_idx global tmp_src_idx - allocation = "%s = vk_zalloc(queue->alloc, %s, 8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);\n if (%s == NULL) goto err;\n" % (dst, size, dst) + allocation = "%s = vk_zalloc(queue->alloc, %s, 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);\n if (%s == NULL) goto err;\n" % (dst, size, dst) copy = "memcpy((void*)%s, %s, %s);" % (dst, src_name, size) level += 1 -- 2.7.4