From 8d928ad3402d0498d011f8e8a605c1b952207a5c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 24 Jun 2023 04:09:56 +0200 Subject: [PATCH] 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. --- gsk/vulkan/gskvulkanrenderpass.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index f0ffc0dea0..12322fd893 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -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; } -- 2.30.2