From af817a33626bdf8454bb35d2b1c3fe9830709396 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 13 Jul 2023 11:17:04 +0200 Subject: [PATCH] vulkan: Merge function into only caller The renderpass reshuffling means we can move a bunch of functions now. This is one of them. --- gsk/vulkan/gskvulkanrender.c | 42 ----------------------------- gsk/vulkan/gskvulkanrenderpassop.c | 35 +++++++++++++++++++++++- gsk/vulkan/gskvulkanrenderprivate.h | 4 --- 3 files changed, 34 insertions(+), 47 deletions(-) diff --git a/gsk/vulkan/gskvulkanrender.c b/gsk/vulkan/gskvulkanrender.c index a4137ec34a..6a9a1bac50 100644 --- a/gsk/vulkan/gskvulkanrender.c +++ b/gsk/vulkan/gskvulkanrender.c @@ -892,48 +892,6 @@ gsk_vulkan_render_collect_vertex_buffer (GskVulkanRender *self) gsk_vulkan_buffer_unmap (self->vertex_buffer); } -GskVulkanOp * -gsk_vulkan_render_draw_pass (GskVulkanRender *self, - GskVulkanRenderPass *render_pass, - GskVulkanOp *op, - VkCommandBuffer command_buffer) -{ - VkPipeline current_pipeline = VK_NULL_HANDLE; - const GskVulkanOpClass *current_pipeline_class = NULL; - const char *current_pipeline_clip_type = NULL; - VkRenderPass vk_render_pass; - - vk_render_pass = gsk_vulkan_render_pass_begin_draw (render_pass, self, self->pipeline_layout, command_buffer); - - while (op && op->op_class->stage != GSK_VULKAN_STAGE_END_PASS) - { - if (op->op_class->shader_name && - (op->op_class != current_pipeline_class || - current_pipeline_clip_type != op->clip_type)) - { - current_pipeline = gsk_vulkan_render_get_pipeline (self, - op->op_class, - op->clip_type, - gsk_vulkan_image_get_vk_format (self->target), - vk_render_pass); - vkCmdBindPipeline (command_buffer, - VK_PIPELINE_BIND_POINT_GRAPHICS, - current_pipeline); - current_pipeline_class = op->op_class; - current_pipeline_clip_type = op->clip_type; - } - - op = gsk_vulkan_op_command (op, self, self->pipeline_layout, command_buffer); - } - - if (op && op->op_class->stage == GSK_VULKAN_STAGE_END_PASS) - op = gsk_vulkan_op_command (op, self, self->pipeline_layout, command_buffer); - else - gsk_vulkan_render_pass_end_draw (render_pass, self, self->pipeline_layout, command_buffer); - - return op; -} - void gsk_vulkan_render_draw (GskVulkanRender *self) { diff --git a/gsk/vulkan/gskvulkanrenderpassop.c b/gsk/vulkan/gskvulkanrenderpassop.c index aabbe7951a..400f68cb05 100644 --- a/gsk/vulkan/gskvulkanrenderpassop.c +++ b/gsk/vulkan/gskvulkanrenderpassop.c @@ -72,8 +72,41 @@ gsk_vulkan_render_pass_op_command (GskVulkanOp *op, VkCommandBuffer command_buffer) { GskVulkanRenderPassOp *self = (GskVulkanRenderPassOp *) op; + VkPipeline current_pipeline = VK_NULL_HANDLE; + const GskVulkanOpClass *current_pipeline_class = NULL; + const char *current_pipeline_clip_type = NULL; + VkRenderPass vk_render_pass; - return gsk_vulkan_render_draw_pass (render, self->render_pass, op->next, command_buffer); + vk_render_pass = gsk_vulkan_render_pass_begin_draw (self->render_pass, render, pipeline_layout, command_buffer); + + op = op->next; + while (op && op->op_class->stage != GSK_VULKAN_STAGE_END_PASS) + { + if (op->op_class->shader_name && + (op->op_class != current_pipeline_class || + current_pipeline_clip_type != op->clip_type)) + { + current_pipeline = gsk_vulkan_render_get_pipeline (render, + op->op_class, + op->clip_type, + gsk_vulkan_image_get_vk_format (self->image), + vk_render_pass); + vkCmdBindPipeline (command_buffer, + VK_PIPELINE_BIND_POINT_GRAPHICS, + current_pipeline); + current_pipeline_class = op->op_class; + current_pipeline_clip_type = op->clip_type; + } + + op = gsk_vulkan_op_command (op, render, pipeline_layout, command_buffer); + } + + if (op && op->op_class->stage == GSK_VULKAN_STAGE_END_PASS) + op = gsk_vulkan_op_command (op, render, pipeline_layout, command_buffer); + else + gsk_vulkan_render_pass_end_draw (self->render_pass, render, pipeline_layout, command_buffer); + + return op; } static const GskVulkanOpClass GSK_VULKAN_RENDER_PASS_OP_CLASS = { diff --git a/gsk/vulkan/gskvulkanrenderprivate.h b/gsk/vulkan/gskvulkanrenderprivate.h index eb96de005a..a040a73723 100644 --- a/gsk/vulkan/gskvulkanrenderprivate.h +++ b/gsk/vulkan/gskvulkanrenderprivate.h @@ -54,10 +54,6 @@ guchar * gsk_vulkan_render_get_buffer_memory (GskVulk gsize *out_offset); void gsk_vulkan_render_draw (GskVulkanRender *self); -GskVulkanOp * gsk_vulkan_render_draw_pass (GskVulkanRender *self, - GskVulkanRenderPass *render_pass, - GskVulkanOp *op, - VkCommandBuffer command_buffer); GdkTexture * gsk_vulkan_render_download_target (GskVulkanRender *self); VkFence gsk_vulkan_render_get_fence (GskVulkanRender *self);