vulkan/cmd_queue: Add a driver_free_cb hook

If a driver sets driver_data but not driver_free_cb, driver_data will
get freed along with the command.  If a driver sets driver_free_cb,
driver_data will not get automatically freed but the callback will get
called before the rest of the data structure is freed.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15329>
This commit is contained in:
Jason Ekstrand 2022-03-09 15:15:40 -06:00 committed by Marge Bot
parent 2106c3bab6
commit c1070556a0
1 changed files with 6 additions and 1 deletions

View File

@ -128,6 +128,8 @@ struct vk_cmd_queue_entry {
% endfor
} u;
void *driver_data;
void (*driver_free_cb)(struct vk_cmd_queue *queue,
struct vk_cmd_queue_entry *cmd);
};
% for c in commands:
@ -256,7 +258,10 @@ vk_free_queue(struct vk_cmd_queue *queue)
#ifdef ${c.guard}
% endif
case ${to_enum_name(c.name)}:
vk_free(queue->alloc, cmd->driver_data);
if (cmd->driver_free_cb)
cmd->driver_free_cb(queue, cmd);
else
vk_free(queue->alloc, cmd->driver_data);
% for p in c.params[1:]:
% if p.len:
vk_free(queue->alloc, (${remove_suffix(p.decl.replace("const", ""), p.name)})cmd->u.${to_struct_field_name(c.name)}.${to_field_name(p.name)});