vulkan: Allocate render ops differently

Allocate the memory up front instead of passing the Op into it.

This way, we can split ops into their own source file and use
init/finish style to use them.
This commit is contained in:
Benjamin Otte 2023-06-24 04:09:56 +02:00
parent 32e123fa67
commit 8d928ad340

View File

@ -293,6 +293,23 @@ gsk_vulkan_render_pass_free (GskVulkanRenderPass *self)
g_free (self);
}
static gpointer
gsk_vulkan_render_pass_alloc_op (GskVulkanRenderPass *self,
gsize size)
{
gsize pos;
pos = gsk_vulkan_render_ops_get_size (&self->render_ops);
gsk_vulkan_render_ops_splice (&self->render_ops,
pos,
0, FALSE,
NULL,
size);
return gsk_vulkan_render_ops_index (&self->render_ops, pos);
}
static void
gsk_vulkan_render_pass_add_op (GskVulkanRenderPass *self,
GskVulkanOp *op);
@ -2536,12 +2553,11 @@ static void
gsk_vulkan_render_pass_add_op (GskVulkanRenderPass *self,
GskVulkanOp *op)
{
op->op_class = &GSK_VULKAN_OP_ALL_CLASS;
GskVulkanOpAll *alloc;
gsk_vulkan_render_ops_splice (&self->render_ops,
gsk_vulkan_render_ops_get_size (&self->render_ops),
0, FALSE,
(guchar *) op,
sizeof (GskVulkanOpAll));
alloc = gsk_vulkan_render_pass_alloc_op (self, GSK_VULKAN_OP_ALL_CLASS.size);
op->op_class = &GSK_VULKAN_OP_ALL_CLASS;
*alloc = *(GskVulkanOpAll *) op;
}