From 5759ab668e5c23767fec3080251fb2740489c220 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 30 May 2023 11:04:53 -0400 Subject: [PATCH] vulkan/cmd_queue: allocate cmds based on the size of the cmd the base size of a vk_cmd_queue_entry is massive since there are a couple union entries that have a trillion params. by allocating conditionally using the union member size, memory can be reduced, which will affect some user-facing api properties Reviewed-by: Dave Airlie Part-of: --- src/vulkan/util/vk_cmd_queue_gen.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/vulkan/util/vk_cmd_queue_gen.py b/src/vulkan/util/vk_cmd_queue_gen.py index 9e4cae4..d0dbb40 100644 --- a/src/vulkan/util/vk_cmd_queue_gen.py +++ b/src/vulkan/util/vk_cmd_queue_gen.py @@ -115,6 +115,18 @@ struct ${to_struct_name(c.name)} { % endif % endfor +struct vk_cmd_queue_entry; + +/* this ordering must match vk_cmd_queue_entry */ +struct vk_cmd_queue_entry_base { + struct list_head cmd_link; + enum vk_cmd_type type; + void *driver_data; + void (*driver_free_cb)(struct vk_cmd_queue *queue, + struct vk_cmd_queue_entry *cmd); +}; + +/* this ordering must match vk_cmd_queue_entry_base */ struct vk_cmd_queue_entry { struct list_head cmd_link; enum vk_cmd_type type; @@ -247,7 +259,11 @@ VkResult vk_enqueue_${to_underscore(c.name)}(struct vk_cmd_queue *queue ) { struct vk_cmd_queue_entry *cmd = vk_zalloc(queue->alloc, - sizeof(*cmd), 8, + sizeof(struct vk_cmd_queue_entry_base) +% if len(c.params) > 1: + + sizeof(struct ${to_struct_name(c.name)}) +% endif + , 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!cmd) return VK_ERROR_OUT_OF_HOST_MEMORY; -- 2.7.4