Merge branch 'wip/otte/merge-ops' into 'main'

Speed up stuff

See merge request GNOME/gtk!7036
This commit is contained in:
Benjamin Otte 2024-03-16 09:43:06 +00:00
commit d007d136c5
21 changed files with 228 additions and 245 deletions

View File

@ -70,7 +70,7 @@ gsk_gl_frame_cleanup (GskGpuFrame *frame)
if (self->sync) if (self->sync)
{ {
glClientWaitSync (self->sync, 0, -1); glClientWaitSync (self->sync, 0, -1);
glDeleteSync (self->sync); g_clear_pointer (&self->sync, glDeleteSync);
} }
self->next_texture_slot = 0; self->next_texture_slot = 0;

View File

@ -17,23 +17,16 @@ struct _GskGpuBlendModeOp
}; };
static void static void
gsk_gpu_blend_mode_op_print (GskGpuOp *op, gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuBlendmodeInstance *instance = (GskGpuBlendmodeInstance *) instance_;
GskGpuBlendmodeInstance *instance;
instance = (GskGpuBlendmodeInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "blend-mode");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id);
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation); gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->top_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->top_id);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
@ -41,7 +34,7 @@ static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuBlendModeOp), GSK_GPU_OP_SIZE (GskGpuBlendModeOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_blend_mode_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -52,6 +45,7 @@ static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_blendmode_info, &gsk_gpu_blendmode_info,
#endif #endif
gsk_gpu_blend_mode_op_print_instance,
gsk_gpu_blendmode_setup_attrib_locations, gsk_gpu_blendmode_setup_attrib_locations,
gsk_gpu_blendmode_setup_vao gsk_gpu_blendmode_setup_vao
}; };

View File

@ -20,22 +20,15 @@ struct _GskGpuBlurOp
}; };
static void static void
gsk_gpu_blur_op_print (GskGpuOp *op, gsk_gpu_blur_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuBlurInstance *instance = (GskGpuBlurInstance *) instance_;
GskGpuBlurInstance *instance;
instance = (GskGpuBlurInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "blur");
gsk_gpu_print_shader_info (string, shader->clip);
g_string_append_printf (string, "%g,%g ", instance->blur_direction[0], instance->blur_direction[1]); g_string_append_printf (string, "%g,%g ", instance->blur_direction[0], instance->blur_direction[1]);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
@ -43,7 +36,7 @@ static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuBlurOp), GSK_GPU_OP_SIZE (GskGpuBlurOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_blur_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -54,6 +47,7 @@ static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_blur_info, &gsk_gpu_blur_info,
#endif #endif
gsk_gpu_blur_op_print_instance,
gsk_gpu_blur_setup_attrib_locations, gsk_gpu_blur_setup_attrib_locations,
gsk_gpu_blur_setup_vao gsk_gpu_blur_setup_vao
}; };

View File

@ -25,18 +25,12 @@ color_equal (const float *color1,
} }
static void static void
gsk_gpu_border_op_print (GskGpuOp *op, gsk_gpu_border_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuBorderInstance *instance = (GskGpuBorderInstance *) instance_;
GskGpuBorderInstance *instance;
instance = (GskGpuBorderInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "border");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rounded_rect (string, instance->outline); gsk_gpu_print_rounded_rect (string, instance->outline);
gsk_gpu_print_rgba (string, (const float *) &instance->border_colors[0]); gsk_gpu_print_rgba (string, (const float *) &instance->border_colors[0]);
@ -58,8 +52,6 @@ gsk_gpu_border_op_print (GskGpuOp *op,
instance->border_widths[2], instance->border_widths[2],
instance->border_widths[3]); instance->border_widths[3]);
} }
gsk_gpu_print_newline (string);
} }
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
@ -85,7 +77,7 @@ static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuBorderOp), GSK_GPU_OP_SIZE (GskGpuBorderOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_border_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_border_op_vk_command, gsk_gpu_border_op_vk_command,
#endif #endif
@ -96,6 +88,7 @@ static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_border_info, &gsk_gpu_border_info,
#endif #endif
gsk_gpu_border_op_print_instance,
gsk_gpu_border_setup_attrib_locations, gsk_gpu_border_setup_attrib_locations,
gsk_gpu_border_setup_vao gsk_gpu_border_setup_vao
}; };

View File

@ -20,24 +20,17 @@ struct _GskGpuBoxShadowOp
}; };
static void static void
gsk_gpu_box_shadow_op_print (GskGpuOp *op, gsk_gpu_box_shadow_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuBoxshadowInstance *instance = (GskGpuBoxshadowInstance *) instance_;
GskGpuBoxshadowInstance *instance;
instance = (GskGpuBoxshadowInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, shader->variation & VARIATION_INSET ? "inset-shadow" : "outset-shadow");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rounded_rect (string, instance->outline); gsk_gpu_print_rounded_rect (string, instance->outline);
gsk_gpu_print_rgba (string, instance->color); gsk_gpu_print_rgba (string, instance->color);
g_string_append_printf (string, "%g %g %g %g ", g_string_append_printf (string, "%g %g %g %g ",
instance->shadow_offset[0], instance->shadow_offset[1], instance->shadow_offset[0], instance->shadow_offset[1],
instance->blur_radius, instance->shadow_spread); instance->blur_radius, instance->shadow_spread);
gsk_gpu_print_newline (string);
} }
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
@ -63,7 +56,7 @@ static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuBoxShadowOp), GSK_GPU_OP_SIZE (GskGpuBoxShadowOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_box_shadow_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_box_shadow_op_vk_command, gsk_gpu_box_shadow_op_vk_command,
#endif #endif
@ -74,6 +67,7 @@ static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_boxshadow_info, &gsk_gpu_boxshadow_info,
#endif #endif
gsk_gpu_box_shadow_op_print_instance,
gsk_gpu_boxshadow_setup_attrib_locations, gsk_gpu_boxshadow_setup_attrib_locations,
gsk_gpu_boxshadow_setup_vao gsk_gpu_boxshadow_setup_vao
}; };

View File

@ -16,22 +16,15 @@ struct _GskGpuColorizeOp
}; };
static void static void
gsk_gpu_colorize_op_print (GskGpuOp *op, gsk_gpu_colorize_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuColorizeInstance *instance = (GskGpuColorizeInstance *) instance_;
GskGpuColorizeInstance *instance;
instance = (GskGpuColorizeInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "colorize");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_rgba (string, instance->color); gsk_gpu_print_rgba (string, instance->color);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
@ -39,7 +32,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuColorizeOp), GSK_GPU_OP_SIZE (GskGpuColorizeOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_colorize_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_colorize_info, &gsk_gpu_colorize_info,
#endif #endif
gsk_gpu_colorize_op_print_instance,
gsk_gpu_colorize_setup_attrib_locations, gsk_gpu_colorize_setup_attrib_locations,
gsk_gpu_colorize_setup_vao gsk_gpu_colorize_setup_vao
}; };

View File

@ -16,21 +16,14 @@ struct _GskGpuColorMatrixOp
}; };
static void static void
gsk_gpu_color_matrix_op_print (GskGpuOp *op, gsk_gpu_color_matrix_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuColormatrixInstance *instance = (GskGpuColormatrixInstance *) instance_;
GskGpuColormatrixInstance *instance;
instance = (GskGpuColormatrixInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "color-matrix");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
@ -38,7 +31,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuColorMatrixOp), GSK_GPU_OP_SIZE (GskGpuColorMatrixOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_color_matrix_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -49,6 +42,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_colormatrix_info, &gsk_gpu_colormatrix_info,
#endif #endif
gsk_gpu_color_matrix_op_print_instance,
gsk_gpu_colormatrix_setup_attrib_locations, gsk_gpu_colormatrix_setup_attrib_locations,
gsk_gpu_colormatrix_setup_vao gsk_gpu_colormatrix_setup_vao
}; };

View File

@ -17,21 +17,14 @@ struct _GskGpuColorOp
}; };
static void static void
gsk_gpu_color_op_print (GskGpuOp *op, gsk_gpu_color_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuColorInstance *instance = (GskGpuColorInstance *) instance_;
GskGpuColorInstance *instance;
instance = (GskGpuColorInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "color");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_rgba (string, instance->color); gsk_gpu_print_rgba (string, instance->color);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
@ -39,7 +32,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuColorOp), GSK_GPU_OP_SIZE (GskGpuColorOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_color_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_color_info, &gsk_gpu_color_info,
#endif #endif
gsk_gpu_color_op_print_instance,
gsk_gpu_color_setup_attrib_locations, gsk_gpu_color_setup_attrib_locations,
gsk_gpu_color_setup_vao gsk_gpu_color_setup_vao
}; };

View File

@ -18,20 +18,13 @@ struct _GskGpuConicGradientOp
}; };
static void static void
gsk_gpu_conic_gradient_op_print (GskGpuOp *op, gsk_gpu_conic_gradient_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuConicgradientInstance *instance = (GskGpuConicgradientInstance *) instance_;
GskGpuConicgradientInstance *instance;
instance = (GskGpuConicgradientInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "conic-gradient");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
@ -39,7 +32,7 @@ static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuConicGradientOp), GSK_GPU_OP_SIZE (GskGpuConicGradientOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_conic_gradient_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_conicgradient_info, &gsk_gpu_conicgradient_info,
#endif #endif
gsk_gpu_conic_gradient_op_print_instance,
gsk_gpu_conicgradient_setup_attrib_locations, gsk_gpu_conicgradient_setup_attrib_locations,
gsk_gpu_conicgradient_setup_vao gsk_gpu_conicgradient_setup_vao
}; };

View File

@ -16,23 +16,16 @@ struct _GskGpuCrossFadeOp
}; };
static void static void
gsk_gpu_cross_fade_op_print (GskGpuOp *op, gsk_gpu_cross_fade_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuCrossfadeInstance *instance = (GskGpuCrossfadeInstance *) instance_;
GskGpuCrossfadeInstance *instance;
instance = (GskGpuCrossfadeInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "cross-fade");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->start_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->start_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->end_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->end_id);
g_string_append_printf (string, "%g%%", 100 * instance->opacity_progress[1]); g_string_append_printf (string, "%g%%", 100 * instance->opacity_progress[1]);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
@ -40,7 +33,7 @@ static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuCrossFadeOp), GSK_GPU_OP_SIZE (GskGpuCrossFadeOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_cross_fade_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -51,6 +44,7 @@ static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_crossfade_info, &gsk_gpu_crossfade_info,
#endif #endif
gsk_gpu_cross_fade_op_print_instance,
gsk_gpu_crossfade_setup_attrib_locations, gsk_gpu_crossfade_setup_attrib_locations,
gsk_gpu_crossfade_setup_vao gsk_gpu_crossfade_setup_vao
}; };

View File

@ -40,6 +40,7 @@ struct _GskGpuFramePrivate
GskGpuOps ops; GskGpuOps ops;
GskGpuOp *first_op; GskGpuOp *first_op;
GskGpuOp *last_op;
GskGpuBuffer *vertex_buffer; GskGpuBuffer *vertex_buffer;
guchar *vertex_buffer_data; guchar *vertex_buffer_data;
@ -70,6 +71,8 @@ gsk_gpu_frame_default_cleanup (GskGpuFrame *self)
gsk_gpu_op_finish (op); gsk_gpu_op_finish (op);
} }
gsk_gpu_ops_set_size (&priv->ops, 0); gsk_gpu_ops_set_size (&priv->ops, 0);
priv->last_op = NULL;
} }
static void static void
@ -343,6 +346,8 @@ gsk_gpu_frame_sort_ops (GskGpuFrame *self)
priv->first_op = sort_data.command.first; priv->first_op = sort_data.command.first;
if (sort_data.command.last) if (sort_data.command.last)
sort_data.command.last->next = NULL; sort_data.command.last->next = NULL;
priv->last_op = NULL;
} }
gpointer gpointer
@ -360,7 +365,17 @@ gsk_gpu_frame_alloc_op (GskGpuFrame *self,
NULL, NULL,
size); size);
return gsk_gpu_ops_index (&priv->ops, pos); priv->last_op = (GskGpuOp *) gsk_gpu_ops_index (&priv->ops, pos);
return priv->last_op;
}
GskGpuOp *
gsk_gpu_frame_get_last_op (GskGpuFrame *self)
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
return priv->last_op;
} }
GskGpuImage * GskGpuImage *

View File

@ -85,6 +85,7 @@ void gsk_gpu_frame_download_texture (GskGpuF
GdkMemoryFormat format, GdkMemoryFormat format,
guchar *data, guchar *data,
gsize stride); gsize stride);
GskGpuOp *gsk_gpu_frame_get_last_op (GskGpuFrame *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskGpuFrame, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskGpuFrame, g_object_unref)

View File

@ -19,23 +19,15 @@ struct _GskGpuLinearGradientOp
}; };
static void static void
gsk_gpu_linear_gradient_op_print (GskGpuOp *op, gsk_gpu_linear_gradient_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuLineargradientInstance *instance = (GskGpuLineargradientInstance *) instance_;
GskGpuLineargradientInstance *instance;
instance = (GskGpuLineargradientInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
if (shader->variation & VARIATION_REPEATING) if (shader->variation & VARIATION_REPEATING)
gsk_gpu_print_op (string, indent, "repeating-linear-gradient"); gsk_gpu_print_string (string, "repeating");
else
gsk_gpu_print_op (string, indent, "linear-gradient");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
@ -43,7 +35,7 @@ static const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuLinearGradientOp), GSK_GPU_OP_SIZE (GskGpuLinearGradientOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_linear_gradient_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -54,6 +46,7 @@ static const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_lineargradient_info, &gsk_gpu_lineargradient_info,
#endif #endif
gsk_gpu_linear_gradient_op_print_instance,
gsk_gpu_lineargradient_setup_attrib_locations, gsk_gpu_lineargradient_setup_attrib_locations,
gsk_gpu_lineargradient_setup_vao gsk_gpu_lineargradient_setup_vao
}; };

View File

@ -16,22 +16,15 @@ struct _GskGpuMaskOp
}; };
static void static void
gsk_gpu_mask_op_print (GskGpuOp *op, gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuMaskInstance *instance = (GskGpuMaskInstance *) instance_;
GskGpuMaskInstance *instance;
instance = (GskGpuMaskInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "mask");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
@ -39,7 +32,7 @@ static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuMaskOp), GSK_GPU_OP_SIZE (GskGpuMaskOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_mask_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_mask_info, &gsk_gpu_mask_info,
#endif #endif
gsk_gpu_mask_op_print_instance,
gsk_gpu_mask_setup_attrib_locations, gsk_gpu_mask_setup_attrib_locations,
gsk_gpu_mask_setup_vao gsk_gpu_mask_setup_vao
}; };

View File

@ -19,23 +19,15 @@ struct _GskGpuRadialGradientOp
}; };
static void static void
gsk_gpu_radial_gradient_op_print (GskGpuOp *op, gsk_gpu_radial_gradient_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuRadialgradientInstance *instance = (GskGpuRadialgradientInstance *) instance_;
GskGpuRadialgradientInstance *instance;
instance = (GskGpuRadialgradientInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
if (shader->variation & VARIATION_REPEATING) if (shader->variation & VARIATION_REPEATING)
gsk_gpu_print_op (string, indent, "repeating-radial-gradient"); gsk_gpu_print_string (string, "repeating");
else
gsk_gpu_print_op (string, indent, "radial-gradient");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
@ -43,7 +35,7 @@ static const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuRadialGradientOp), GSK_GPU_OP_SIZE (GskGpuRadialGradientOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_radial_gradient_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -54,6 +46,7 @@ static const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_radialgradient_info, &gsk_gpu_radialgradient_info,
#endif #endif
gsk_gpu_radial_gradient_op_print_instance,
gsk_gpu_radialgradient_setup_attrib_locations, gsk_gpu_radialgradient_setup_attrib_locations,
gsk_gpu_radialgradient_setup_vao gsk_gpu_radialgradient_setup_vao
}; };

View File

@ -17,21 +17,14 @@ struct _GskGpuRoundedColorOp
}; };
static void static void
gsk_gpu_rounded_color_op_print (GskGpuOp *op, gsk_gpu_rounded_color_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuRoundedcolorInstance *instance = (GskGpuRoundedcolorInstance *) instance_;
GskGpuRoundedcolorInstance *instance;
instance = (GskGpuRoundedcolorInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "rounded-color");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rounded_rect (string, instance->outline); gsk_gpu_print_rounded_rect (string, instance->outline);
gsk_gpu_print_rgba (string, instance->color); gsk_gpu_print_rgba (string, instance->color);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
@ -39,7 +32,7 @@ static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuRoundedColorOp), GSK_GPU_OP_SIZE (GskGpuRoundedColorOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_rounded_color_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_roundedcolor_info, &gsk_gpu_roundedcolor_info,
#endif #endif
gsk_gpu_rounded_color_op_print_instance,
gsk_gpu_roundedcolor_setup_attrib_locations, gsk_gpu_roundedcolor_setup_attrib_locations,
gsk_gpu_roundedcolor_setup_vao gsk_gpu_roundedcolor_setup_vao
}; };

View File

@ -3,6 +3,7 @@
#include "gskgpushaderopprivate.h" #include "gskgpushaderopprivate.h"
#include "gskgpuframeprivate.h" #include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskgldescriptorsprivate.h" #include "gskgldescriptorsprivate.h"
#include "gskgldeviceprivate.h" #include "gskgldeviceprivate.h"
#include "gskglframeprivate.h" #include "gskglframeprivate.h"
@ -26,6 +27,36 @@ gsk_gpu_shader_op_finish (GskGpuOp *op)
g_clear_object (&self->desc); g_clear_object (&self->desc);
} }
void
gsk_gpu_shader_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
{
GskGpuShaderOp *self = (GskGpuShaderOp *) op;
const GskGpuShaderOpClass *shader_class = (const GskGpuShaderOpClass *) op->op_class;
const char *shader_name;
guchar *instance;
gsize i;
if (g_str_has_prefix (shader_class->shader_name, "gskgpu"))
shader_name = shader_class->shader_name + 6;
else
shader_name = shader_class->shader_name;
instance = gsk_gpu_frame_get_vertex_data (frame, self->vertex_offset);
for (i = 0; i < self->n_ops; i++)
{
gsk_gpu_print_op (string, indent, shader_name);
gsk_gpu_print_shader_info (string, self->clip);
shader_class->print_instance (self,
instance + i * shader_class->vertex_size,
string);
gsk_gpu_print_newline (string);
}
}
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
GskGpuOp * GskGpuOp *
gsk_gpu_shader_op_vk_command_n (GskGpuOp *op, gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
@ -37,15 +68,15 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
GskGpuShaderOpClass *shader_op_class = (GskGpuShaderOpClass *) op->op_class; GskGpuShaderOpClass *shader_op_class = (GskGpuShaderOpClass *) op->op_class;
GskVulkanDescriptors *desc; GskVulkanDescriptors *desc;
GskGpuOp *next; GskGpuOp *next;
gsize i, n; gsize i, n_ops, max_ops_per_draw;
if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_MERGE) && if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_MERGE) &&
gsk_vulkan_device_has_feature (GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame)), gsk_vulkan_device_has_feature (GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame)),
GDK_VULKAN_FEATURE_NONUNIFORM_INDEXING)) GDK_VULKAN_FEATURE_NONUNIFORM_INDEXING))
n = MAX_MERGE_OPS; max_ops_per_draw = MAX_MERGE_OPS;
else else
n = 1; max_ops_per_draw = 1;
i = 1;
desc = GSK_VULKAN_DESCRIPTORS (self->desc); desc = GSK_VULKAN_DESCRIPTORS (self->desc);
if (desc && state->desc != desc) if (desc && state->desc != desc)
{ {
@ -53,7 +84,8 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
state->desc = desc; state->desc = desc;
} }
for (next = op->next; next && i < n; next = next->next) n_ops = self->n_ops;
for (next = op->next; next; next = next->next)
{ {
GskGpuShaderOp *next_shader = (GskGpuShaderOp *) next; GskGpuShaderOp *next_shader = (GskGpuShaderOp *) next;
@ -61,10 +93,10 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
next_shader->desc != self->desc || next_shader->desc != self->desc ||
next_shader->variation != self->variation || next_shader->variation != self->variation ||
next_shader->clip != self->clip || next_shader->clip != self->clip ||
next_shader->vertex_offset != self->vertex_offset + i * shader_op_class->vertex_size) next_shader->vertex_offset != self->vertex_offset + n_ops * shader_op_class->vertex_size)
break; break;
i++; n_ops += next_shader->n_ops;
} }
vkCmdBindPipeline (state->vk_command_buffer, vkCmdBindPipeline (state->vk_command_buffer,
@ -78,9 +110,12 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
state->vk_format, state->vk_format,
state->vk_render_pass)); state->vk_render_pass));
vkCmdDraw (state->vk_command_buffer, for (i = 0; i < n_ops; i += max_ops_per_draw)
6 * instance_scale, i, {
0, self->vertex_offset / shader_op_class->vertex_size); vkCmdDraw (state->vk_command_buffer,
6 * instance_scale, MIN (max_ops_per_draw, n_ops - i),
0, self->vertex_offset / shader_op_class->vertex_size + i);
}
return next; return next;
} }
@ -104,7 +139,7 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
GskGpuShaderOpClass *shader_op_class = (GskGpuShaderOpClass *) op->op_class; GskGpuShaderOpClass *shader_op_class = (GskGpuShaderOpClass *) op->op_class;
GskGLDescriptors *desc; GskGLDescriptors *desc;
GskGpuOp *next; GskGpuOp *next;
gsize i, n, n_external; gsize i, n_ops, n_external, max_ops_per_draw;
desc = GSK_GL_DESCRIPTORS (self->desc); desc = GSK_GL_DESCRIPTORS (self->desc);
if (desc) if (desc)
@ -135,11 +170,12 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
} }
if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_MERGE)) if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_MERGE))
n = MAX_MERGE_OPS; max_ops_per_draw = MAX_MERGE_OPS;
else else
n = 1; max_ops_per_draw = 1;
i = 1;
for (next = op->next; next && i < n; next = next->next) n_ops = self->n_ops;
for (next = op->next; next; next = next->next)
{ {
GskGpuShaderOp *next_shader = (GskGpuShaderOp *) next; GskGpuShaderOp *next_shader = (GskGpuShaderOp *) next;
@ -147,28 +183,31 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
next_shader->desc != self->desc || next_shader->desc != self->desc ||
next_shader->variation != self->variation || next_shader->variation != self->variation ||
next_shader->clip != self->clip || next_shader->clip != self->clip ||
next_shader->vertex_offset != self->vertex_offset + i * shader_op_class->vertex_size) next_shader->vertex_offset != self->vertex_offset + n_ops * shader_op_class->vertex_size)
break; break;
i++; n_ops += next_shader->n_ops;
} }
if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE)) for (i = 0; i < n_ops; i += max_ops_per_draw)
{ {
glDrawArraysInstancedBaseInstance (GL_TRIANGLES, if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE))
0, {
6 * instance_scale, glDrawArraysInstancedBaseInstance (GL_TRIANGLES,
i, 0,
self->vertex_offset / shader_op_class->vertex_size); 6 * instance_scale,
} MIN (max_ops_per_draw, n_ops - i),
else self->vertex_offset / shader_op_class->vertex_size + i);
{ }
shader_op_class->setup_vao (self->vertex_offset); else
{
shader_op_class->setup_vao (self->vertex_offset + i * shader_op_class->vertex_size);
glDrawArraysInstanced (GL_TRIANGLES, glDrawArraysInstanced (GL_TRIANGLES,
0, 0,
6 * instance_scale, 6 * instance_scale,
i); MIN (max_ops_per_draw, n_ops - i));
}
} }
return next; return next;
@ -182,7 +221,7 @@ gsk_gpu_shader_op_gl_command (GskGpuOp *op,
return gsk_gpu_shader_op_gl_command_n (op, frame, state, 1); return gsk_gpu_shader_op_gl_command_n (op, frame, state, 1);
} }
GskGpuShaderOp * void
gsk_gpu_shader_op_alloc (GskGpuFrame *frame, gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
const GskGpuShaderOpClass *op_class, const GskGpuShaderOpClass *op_class,
guint32 variation, guint32 variation,
@ -190,20 +229,39 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
GskGpuDescriptors *desc, GskGpuDescriptors *desc,
gpointer out_vertex_data) gpointer out_vertex_data)
{ {
GskGpuShaderOp *self; GskGpuOp *last;
GskGpuShaderOp *last_shader;
gsize vertex_offset;
self = (GskGpuShaderOp *) gsk_gpu_op_alloc (frame, &op_class->parent_class); vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size);
self->variation = variation; last = gsk_gpu_frame_get_last_op (frame);
self->clip = clip; /* careful: We're casting without checking, but the if() does the check */
if (desc) last_shader = (GskGpuShaderOp *) last;
self->desc = g_object_ref (desc); if (last &&
last->op_class == (const GskGpuOpClass *) op_class &&
last_shader->desc == desc &&
last_shader->variation == variation &&
last_shader->clip == clip &&
last_shader->vertex_offset + last_shader->n_ops * op_class->vertex_size == vertex_offset)
{
last_shader->n_ops++;
}
else else
self->desc = NULL; {
self->vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size); GskGpuShaderOp *self;
self = (GskGpuShaderOp *) gsk_gpu_op_alloc (frame, &op_class->parent_class);
*((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, self->vertex_offset); self->variation = variation;
self->clip = clip;
self->vertex_offset = vertex_offset;
if (desc)
self->desc = g_object_ref (desc);
else
self->desc = NULL;
self->n_ops = 1;
}
return self; *((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, vertex_offset);
} }

View File

@ -14,6 +14,7 @@ struct _GskGpuShaderOp
guint32 variation; guint32 variation;
GskGpuShaderClip clip; GskGpuShaderClip clip;
gsize vertex_offset; gsize vertex_offset;
gsize n_ops;
}; };
struct _GskGpuShaderOpClass struct _GskGpuShaderOpClass
@ -25,11 +26,14 @@ struct _GskGpuShaderOpClass
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
const VkPipelineVertexInputStateCreateInfo *vertex_input_state; const VkPipelineVertexInputStateCreateInfo *vertex_input_state;
#endif #endif
void (* print_instance) (GskGpuShaderOp *shader,
gpointer instance,
GString *string);
void (* setup_attrib_locations) (GLuint program); void (* setup_attrib_locations) (GLuint program);
void (* setup_vao) (gsize offset); void (* setup_vao) (gsize offset);
}; };
GskGpuShaderOp * gsk_gpu_shader_op_alloc (GskGpuFrame *frame, void gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
const GskGpuShaderOpClass *op_class, const GskGpuShaderOpClass *op_class,
guint32 variation, guint32 variation,
GskGpuShaderClip clip, GskGpuShaderClip clip,
@ -38,6 +42,10 @@ GskGpuShaderOp * gsk_gpu_shader_op_alloc (GskGpuF
void gsk_gpu_shader_op_finish (GskGpuOp *op); void gsk_gpu_shader_op_finish (GskGpuOp *op);
void gsk_gpu_shader_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent);
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
GskGpuOp * gsk_gpu_shader_op_vk_command_n (GskGpuOp *op, GskGpuOp * gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
GskGpuFrame *frame, GskGpuFrame *frame,

View File

@ -19,21 +19,14 @@ struct _GskGpuStraightAlphaOp
}; };
static void static void
gsk_gpu_straight_alpha_op_print (GskGpuOp *op, gsk_gpu_straight_alpha_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuStraightalphaInstance *instance = (GskGpuStraightalphaInstance *) instance_;
GskGpuStraightalphaInstance *instance;
instance = (GskGpuStraightalphaInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "straight-alpha");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
@ -41,7 +34,7 @@ static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuStraightAlphaOp), GSK_GPU_OP_SIZE (GskGpuStraightAlphaOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_straight_alpha_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -52,6 +45,7 @@ static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_straightalpha_info, &gsk_gpu_straightalpha_info,
#endif #endif
gsk_gpu_straight_alpha_op_print_instance,
gsk_gpu_straightalpha_setup_attrib_locations, gsk_gpu_straightalpha_setup_attrib_locations,
gsk_gpu_straightalpha_setup_vao gsk_gpu_straightalpha_setup_vao
}; };

View File

@ -16,21 +16,14 @@ struct _GskGpuTextureOp
}; };
static void static void
gsk_gpu_texture_op_print (GskGpuOp *op, gsk_gpu_texture_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuTextureInstance *instance = (GskGpuTextureInstance *) instance_;
GskGpuTextureInstance *instance;
instance = (GskGpuTextureInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "texture");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
@ -38,7 +31,7 @@ static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuTextureOp), GSK_GPU_OP_SIZE (GskGpuTextureOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_texture_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -49,6 +42,7 @@ static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_texture_info, &gsk_gpu_texture_info,
#endif #endif
gsk_gpu_texture_op_print_instance,
gsk_gpu_texture_setup_attrib_locations, gsk_gpu_texture_setup_attrib_locations,
gsk_gpu_texture_setup_vao gsk_gpu_texture_setup_vao
}; };

View File

@ -17,20 +17,13 @@ struct _GskGpuUberOp
}; };
static void static void
gsk_gpu_uber_op_print (GskGpuOp *op, gsk_gpu_uber_op_print_instance (GskGpuShaderOp *shader,
GskGpuFrame *frame, gpointer instance_,
GString *string, GString *string)
guint indent)
{ {
GskGpuShaderOp *shader = (GskGpuShaderOp *) op; GskGpuUberInstance *instance = instance_;
GskGpuUberInstance *instance;
instance = (GskGpuUberInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
gsk_gpu_print_op (string, indent, "uber");
gsk_gpu_print_shader_info (string, shader->clip);
gsk_gpu_print_rect (string, instance->rect); gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_newline (string);
} }
static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = { static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
@ -38,7 +31,7 @@ static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuUberOp), GSK_GPU_OP_SIZE (GskGpuUberOp),
GSK_GPU_STAGE_SHADER, GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish, gsk_gpu_shader_op_finish,
gsk_gpu_uber_op_print, gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command, gsk_gpu_shader_op_vk_command,
#endif #endif
@ -49,8 +42,9 @@ static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
&gsk_gpu_uber_info, &gsk_gpu_uber_info,
#endif #endif
gsk_gpu_uber_op_print_instance,
gsk_gpu_uber_setup_attrib_locations, gsk_gpu_uber_setup_attrib_locations,
gsk_gpu_uber_setup_vao gsk_gpu_uber_setup_vao,
}; };
void void