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...
This commit is contained in:
Benjamin Otte 2023-07-09 15:56:30 +02:00
parent da4a4f6a25
commit c0b185bee9
20 changed files with 58 additions and 24 deletions

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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);
}

View File

@ -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);

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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);
}
}

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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 = {