From: Benjamin Otte Date: Sun, 9 Jul 2023 14:50:19 +0000 (+0200) Subject: vulkan: Batch together multiple draw calls X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~60^2~34 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=63ad2343916f9a75fd7b068b4ccb0bc1a133f29f;p=gtk4.git vulkan: Batch together multiple draw calls If multiple instances of the same op appear in order, we can emit one vkCmdDraw() for all of them together. So do that. --- diff --git a/gsk/vulkan/gskvulkanop.c b/gsk/vulkan/gskvulkanop.c index 657e4e31a7..6ce89a2591 100644 --- a/gsk/vulkan/gskvulkanop.c +++ b/gsk/vulkan/gskvulkanop.c @@ -98,11 +98,25 @@ gsk_vulkan_op_draw_command_n (GskVulkanOp *op, VkCommandBuffer command_buffer, gsize instance_scale) { + GskVulkanOp *next; + gsize stride = op->op_class->vertex_input_state->pVertexBindingDescriptions[0].stride; + gsize i; + + i = 1; + for (next = op->next; next; next = next->next) + { + if (next->op_class != op->op_class || + next->vertex_offset != op->vertex_offset + i * stride) + break; + + i++; + } + vkCmdDraw (command_buffer, - 6 * instance_scale, 1, - 0, op->vertex_offset / op->op_class->vertex_input_state->pVertexBindingDescriptions[0].stride); + 6 * instance_scale, i, + 0, op->vertex_offset / stride); - return op->next; + return next; } GskVulkanOp *