From c0b185bee9ba52ee94238e529166c6784bfaa884 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 9 Jul 2023 15:56:30 +0200 Subject: [PATCH] vulkan: Make Op->command() return the next op This way, ops can batch themselves. They don't dothat yet, but you know where this is going... --- gsk/vulkan/gskvulkanblendmodeop.c | 4 +++- gsk/vulkan/gskvulkanblurop.c | 4 +++- gsk/vulkan/gskvulkanborderop.c | 4 +++- gsk/vulkan/gskvulkancolormatrixop.c | 4 +++- gsk/vulkan/gskvulkancolorop.c | 4 +++- gsk/vulkan/gskvulkancrossfadeop.c | 4 +++- gsk/vulkan/gskvulkanglyphop.c | 4 +++- gsk/vulkan/gskvulkaninsetshadowop.c | 4 +++- gsk/vulkan/gskvulkanlineargradientop.c | 4 +++- gsk/vulkan/gskvulkanmaskop.c | 4 +++- gsk/vulkan/gskvulkanoffscreenop.c | 7 +++++-- gsk/vulkan/gskvulkanop.c | 4 ++-- gsk/vulkan/gskvulkanopprivate.h | 4 ++-- gsk/vulkan/gskvulkanoutsetshadowop.c | 4 +++- gsk/vulkan/gskvulkanpushconstantsop.c | 4 +++- gsk/vulkan/gskvulkanrenderpass.c | 5 +++-- gsk/vulkan/gskvulkanscissorop.c | 4 +++- gsk/vulkan/gskvulkantextureop.c | 4 +++- gsk/vulkan/gskvulkanuploadcairoop.c | 3 ++- gsk/vulkan/gskvulkanuploadop.c | 3 ++- 20 files changed, 58 insertions(+), 24 deletions(-) diff --git a/gsk/vulkan/gskvulkanblendmodeop.c b/gsk/vulkan/gskvulkanblendmodeop.c index fa2922eeb2..8201e72770 100644 --- a/gsk/vulkan/gskvulkanblendmodeop.c +++ b/gsk/vulkan/gskvulkanblendmodeop.c @@ -105,7 +105,7 @@ gsk_vulkan_blend_mode_op_reserve_descriptor_sets (GskVulkanOp *op, GSK_VULKAN_SAMPLER_DEFAULT); } -static void +static GskVulkanOp * gsk_vulkan_blend_mode_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -116,6 +116,8 @@ gsk_vulkan_blend_mode_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_blend_mode_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanShaderOpClass GSK_VULKAN_BLEND_MODE_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanblurop.c b/gsk/vulkan/gskvulkanblurop.c index 1cf3efdefb..31bf6dc3f4 100644 --- a/gsk/vulkan/gskvulkanblurop.c +++ b/gsk/vulkan/gskvulkanblurop.c @@ -93,7 +93,7 @@ gsk_vulkan_blur_op_reserve_descriptor_sets (GskVulkanOp *op, GSK_VULKAN_SAMPLER_DEFAULT); } -static void +static GskVulkanOp * gsk_vulkan_blur_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -104,6 +104,8 @@ gsk_vulkan_blur_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_blur_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_BLUR_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanborderop.c b/gsk/vulkan/gskvulkanborderop.c index 71fc9411b4..18ffc5d0f5 100644 --- a/gsk/vulkan/gskvulkanborderop.c +++ b/gsk/vulkan/gskvulkanborderop.c @@ -101,7 +101,7 @@ gsk_vulkan_border_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_border_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -112,6 +112,8 @@ gsk_vulkan_border_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6 * 8, 1, 0, self->vertex_offset / gsk_vulkan_border_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_BORDER_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkancolormatrixop.c b/gsk/vulkan/gskvulkancolormatrixop.c index d8de455979..a8b9750a4b 100644 --- a/gsk/vulkan/gskvulkancolormatrixop.c +++ b/gsk/vulkan/gskvulkancolormatrixop.c @@ -100,7 +100,7 @@ gsk_vulkan_color_matrix_op_reserve_descriptor_sets (GskVulkanOp *op, GSK_VULKAN_SAMPLER_DEFAULT); } -static void +static GskVulkanOp * gsk_vulkan_color_matrix_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -111,6 +111,8 @@ gsk_vulkan_color_matrix_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_color_matrix_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_COLOR_MATRIX_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkancolorop.c b/gsk/vulkan/gskvulkancolorop.c index ee0c11cdb3..fc099d6cdf 100644 --- a/gsk/vulkan/gskvulkancolorop.c +++ b/gsk/vulkan/gskvulkancolorop.c @@ -86,7 +86,7 @@ gsk_vulkan_color_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_color_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -97,6 +97,8 @@ gsk_vulkan_color_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_color_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_COLOR_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkancrossfadeop.c b/gsk/vulkan/gskvulkancrossfadeop.c index 322a69ccaa..246042b7c6 100644 --- a/gsk/vulkan/gskvulkancrossfadeop.c +++ b/gsk/vulkan/gskvulkancrossfadeop.c @@ -105,7 +105,7 @@ gsk_vulkan_cross_fade_op_reserve_descriptor_sets (GskVulkanOp *op, GSK_VULKAN_SAMPLER_DEFAULT); } -static void +static GskVulkanOp * gsk_vulkan_cross_fade_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -116,6 +116,8 @@ gsk_vulkan_cross_fade_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_cross_fade_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_CROSS_FADE_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanglyphop.c b/gsk/vulkan/gskvulkanglyphop.c index b907ee193a..c5d1effae2 100644 --- a/gsk/vulkan/gskvulkanglyphop.c +++ b/gsk/vulkan/gskvulkanglyphop.c @@ -91,7 +91,7 @@ gsk_vulkan_glyph_op_reserve_descriptor_sets (GskVulkanOp *op, self->image_descriptor = gsk_vulkan_render_get_image_descriptor (render, self->image, GSK_VULKAN_SAMPLER_DEFAULT); } -static void +static GskVulkanOp * gsk_vulkan_glyph_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -102,6 +102,8 @@ gsk_vulkan_glyph_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_glyph_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_GLYPH_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkaninsetshadowop.c b/gsk/vulkan/gskvulkaninsetshadowop.c index 54a7845707..85601c2b46 100644 --- a/gsk/vulkan/gskvulkaninsetshadowop.c +++ b/gsk/vulkan/gskvulkaninsetshadowop.c @@ -88,7 +88,7 @@ gsk_vulkan_inset_shadow_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_inset_shadow_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -99,6 +99,8 @@ gsk_vulkan_inset_shadow_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_inset_shadow_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_INSET_SHADOW_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanlineargradientop.c b/gsk/vulkan/gskvulkanlineargradientop.c index 2ead08eb67..af6484ccc2 100644 --- a/gsk/vulkan/gskvulkanlineargradientop.c +++ b/gsk/vulkan/gskvulkanlineargradientop.c @@ -99,7 +99,7 @@ gsk_vulkan_linear_gradient_op_reserve_descriptor_sets (GskVulkanOp *op, memcpy (mem, self->stops, self->n_stops * sizeof (GskColorStop)); } -static void +static GskVulkanOp * gsk_vulkan_linear_gradient_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -110,6 +110,8 @@ gsk_vulkan_linear_gradient_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_linear_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_LINEAR_GRADIENT_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanmaskop.c b/gsk/vulkan/gskvulkanmaskop.c index dd13efa15a..2f40f9a3e7 100644 --- a/gsk/vulkan/gskvulkanmaskop.c +++ b/gsk/vulkan/gskvulkanmaskop.c @@ -116,7 +116,7 @@ gsk_vulkan_mask_op_reserve_descriptor_sets (GskVulkanOp *op, self->mask.image_descriptor = gsk_vulkan_render_get_image_descriptor (render, self->mask.image, GSK_VULKAN_SAMPLER_DEFAULT); } -static void +static GskVulkanOp * gsk_vulkan_mask_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -127,6 +127,8 @@ gsk_vulkan_mask_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_mask_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_COLOR_MASK_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanoffscreenop.c b/gsk/vulkan/gskvulkanoffscreenop.c index 08865fa844..8a48ebea6c 100644 --- a/gsk/vulkan/gskvulkanoffscreenop.c +++ b/gsk/vulkan/gskvulkanoffscreenop.c @@ -78,7 +78,7 @@ gsk_vulkan_offscreen_op_reserve_descriptor_sets (GskVulkanOp *op, gsk_vulkan_render_pass_reserve_descriptor_sets (self->render_pass, render); } -static void +static GskVulkanOp * gsk_vulkan_offscreen_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -87,6 +87,8 @@ gsk_vulkan_offscreen_op_command (GskVulkanOp *op, GskVulkanOffscreenOp *self = (GskVulkanOffscreenOp *) op; gsk_vulkan_render_draw_pass (render, self->render_pass, VK_NULL_HANDLE); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_OFFSCREEN_OP_CLASS = { @@ -158,12 +160,13 @@ gsk_vulkan_offscreen_end_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_offscreen_end_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer) { + return op->next; } static const GskVulkanOpClass GSK_VULKAN_OFFSCREEN_END_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanop.c b/gsk/vulkan/gskvulkanop.c index bbfc46f8b7..55b8140e39 100644 --- a/gsk/vulkan/gskvulkanop.c +++ b/gsk/vulkan/gskvulkanop.c @@ -57,12 +57,12 @@ gsk_vulkan_op_reserve_descriptor_sets (GskVulkanOp *op, op->op_class->reserve_descriptor_sets (op, render); } -void +GskVulkanOp * gsk_vulkan_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer) { - op->op_class->command (op, render, pipeline_layout, command_buffer); + return op->op_class->command (op, render, pipeline_layout, command_buffer); } diff --git a/gsk/vulkan/gskvulkanopprivate.h b/gsk/vulkan/gskvulkanopprivate.h index cd0a02531c..cfb1e65ceb 100644 --- a/gsk/vulkan/gskvulkanopprivate.h +++ b/gsk/vulkan/gskvulkanopprivate.h @@ -47,7 +47,7 @@ struct _GskVulkanOpClass guchar *data); void (* reserve_descriptor_sets) (GskVulkanOp *op, GskVulkanRender *render); - void (* command) (GskVulkanOp *op, + GskVulkanOp * (* command) (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer); @@ -72,7 +72,7 @@ void gsk_vulkan_op_collect_vertex_data (GskVulk guchar *data); void gsk_vulkan_op_reserve_descriptor_sets (GskVulkanOp *op, GskVulkanRender *render); -void gsk_vulkan_op_command (GskVulkanOp *op, +GskVulkanOp * gsk_vulkan_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer); diff --git a/gsk/vulkan/gskvulkanoutsetshadowop.c b/gsk/vulkan/gskvulkanoutsetshadowop.c index 1366a617e3..d29fbd0ca6 100644 --- a/gsk/vulkan/gskvulkanoutsetshadowop.c +++ b/gsk/vulkan/gskvulkanoutsetshadowop.c @@ -88,7 +88,7 @@ gsk_vulkan_outset_shadow_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_outset_shadow_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -99,6 +99,8 @@ gsk_vulkan_outset_shadow_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_outset_shadow_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_OUTSET_SHADOW_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanpushconstantsop.c b/gsk/vulkan/gskvulkanpushconstantsop.c index 7c5db0f9e7..2dc1d7dc19 100644 --- a/gsk/vulkan/gskvulkanpushconstantsop.c +++ b/gsk/vulkan/gskvulkanpushconstantsop.c @@ -82,7 +82,7 @@ gsk_vulkan_push_constants_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_push_constants_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -96,6 +96,8 @@ gsk_vulkan_push_constants_op_command (GskVulkanOp *op, 0, sizeof (self->instance), &self->instance); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_PUSH_CONSTANTS_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index beb162bb85..008328329a 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -1411,7 +1411,8 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self, const char *current_pipeline_clip_type = NULL; GskVulkanOp *op; - for (op = gsk_vulkan_render_pass_get_first_op (self); op; op = op->next) + op = gsk_vulkan_render_pass_get_first_op (self); + while (op) { if (op->op_class->shader_name && (op->op_class != current_pipeline_class || @@ -1429,7 +1430,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self, current_pipeline_clip_type = op->clip_type; } - gsk_vulkan_op_command (op, render, pipeline_layout, command_buffer); + op = gsk_vulkan_op_command (op, render, pipeline_layout, command_buffer); } } diff --git a/gsk/vulkan/gskvulkanscissorop.c b/gsk/vulkan/gskvulkanscissorop.c index 27e64a676b..c2fa3dff7b 100644 --- a/gsk/vulkan/gskvulkanscissorop.c +++ b/gsk/vulkan/gskvulkanscissorop.c @@ -56,7 +56,7 @@ gsk_vulkan_scissor_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_scissor_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -71,6 +71,8 @@ gsk_vulkan_scissor_op_command (GskVulkanOp *op, { self->rect.x, self->rect.y }, { self->rect.width, self->rect.height }, }); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_SCISSOR_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkantextureop.c b/gsk/vulkan/gskvulkantextureop.c index d6264d33ca..d621e5ae19 100644 --- a/gsk/vulkan/gskvulkantextureop.c +++ b/gsk/vulkan/gskvulkantextureop.c @@ -96,7 +96,7 @@ gsk_vulkan_texture_op_reserve_descriptor_sets (GskVulkanOp *op, self->image_descriptor = gsk_vulkan_render_get_image_descriptor (render, self->image, self->sampler); } -static void +static GskVulkanOp * gsk_vulkan_texture_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, @@ -107,6 +107,8 @@ gsk_vulkan_texture_op_command (GskVulkanOp *op, vkCmdDraw (command_buffer, 6, 1, 0, self->vertex_offset / gsk_vulkan_texture_info.pVertexBindingDescriptions[0].stride); + + return op->next; } static const GskVulkanOpClass GSK_VULKAN_TEXTURE_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanuploadcairoop.c b/gsk/vulkan/gskvulkanuploadcairoop.c index 8464ea9160..72bc6272ed 100644 --- a/gsk/vulkan/gskvulkanuploadcairoop.c +++ b/gsk/vulkan/gskvulkanuploadcairoop.c @@ -90,12 +90,13 @@ gsk_vulkan_upload_cairo_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_upload_cairo_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer) { + return op->next; } static const GskVulkanOpClass GSK_VULKAN_UPLOAD_CAIRO_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanuploadop.c b/gsk/vulkan/gskvulkanuploadop.c index 84092522a6..1a0eb6dfc0 100644 --- a/gsk/vulkan/gskvulkanuploadop.c +++ b/gsk/vulkan/gskvulkanuploadop.c @@ -71,12 +71,13 @@ gsk_vulkan_upload_op_reserve_descriptor_sets (GskVulkanOp *op, { } -static void +static GskVulkanOp * gsk_vulkan_upload_op_command (GskVulkanOp *op, GskVulkanRender *render, VkPipelineLayout pipeline_layout, VkCommandBuffer command_buffer) { + return op->next; } static const GskVulkanOpClass GSK_VULKAN_UPLOAD_OP_CLASS = {