static void *
vn_cmd_get_tmp_data(struct vn_command_buffer *cmd, size_t size)
{
+ struct vn_command_pool *pool = cmd->pool;
/* avoid shrinking in case of non efficient reallocation implementation */
- if (size > cmd->builder.tmp.size) {
+ if (size > pool->tmp.size) {
void *data =
- vk_realloc(&cmd->pool->allocator, cmd->builder.tmp.data, size,
- VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ vk_realloc(&pool->allocator, pool->tmp.data, size, VN_DEFAULT_ALIGN,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!data)
return NULL;
- cmd->builder.tmp.data = data;
- cmd->builder.tmp.size = size;
+ pool->tmp.data = data;
+ pool->tmp.size = size;
}
- return cmd->builder.tmp.data;
+ return pool->tmp.data;
}
static inline VkImageMemoryBarrier *
if (cmd->builder.present_src_images)
vk_free(alloc, cmd->builder.present_src_images);
- if (cmd->builder.tmp.data)
- vk_free(alloc, cmd->builder.tmp.data);
-
list_for_each_entry_safe(struct vn_command_buffer_query_batch, batch,
&cmd->query_batches, head)
vk_free(alloc, batch);
&pool->free_query_batches, head)
vk_free(alloc, batch);
+ if (pool->tmp.data)
+ vk_free(alloc, pool->tmp.data);
+
vn_object_base_fini(&pool->base);
vk_free(alloc, pool);
}
if (!cmd)
continue;
- if (cmd->builder.tmp.data)
- vk_free(alloc, cmd->builder.tmp.data);
-
if (cmd->builder.present_src_images)
vk_free(alloc, cmd->builder.present_src_images);
struct list_head command_buffers;
struct list_head free_query_batches;
+
+ /* Temporary storage for scrubbing VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. The
+ * storage's lifetime is the command pool's lifetime. We increase the
+ * storage as needed, but never shrink it. Upon used by the cmd buffer, the
+ * storage must fit within command scope to avoid locking or suballocation.
+ */
+ struct {
+ void *data;
+ size_t size;
+ } tmp;
};
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_command_pool,
base.base,
};
struct vn_command_buffer_builder {
- /* Temporary storage for scrubbing VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. The
- * storage's lifetime is the command buffer's lifetime. We increase the
- * storage as needed, but never shrink it.
- */
- struct {
- void *data;
- size_t size;
- } tmp;
-
const struct vn_render_pass *render_pass;
const struct vn_framebuffer *framebuffer;
const struct vn_image **present_src_images;