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)
{
glClientWaitSync (self->sync, 0, -1);
glDeleteSync (self->sync);
g_clear_pointer (&self->sync, glDeleteSync);
}
self->next_texture_slot = 0;

View File

@ -17,23 +17,16 @@ struct _GskGpuBlendModeOp
};
static void
gsk_gpu_blend_mode_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->bottom_id);
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_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_blend_mode_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -52,6 +45,7 @@ static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_blendmode_info,
#endif
gsk_gpu_blend_mode_op_print_instance,
gsk_gpu_blendmode_setup_attrib_locations,
gsk_gpu_blendmode_setup_vao
};

View File

@ -20,22 +20,15 @@ struct _GskGpuBlurOp
};
static void
gsk_gpu_blur_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_blur_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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]);
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_blur_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -54,6 +47,7 @@ static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_blur_info,
#endif
gsk_gpu_blur_op_print_instance,
gsk_gpu_blur_setup_attrib_locations,
gsk_gpu_blur_setup_vao
};

View File

@ -25,18 +25,12 @@ color_equal (const float *color1,
}
static void
gsk_gpu_border_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_border_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_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[3]);
}
gsk_gpu_print_newline (string);
}
#ifdef GDK_RENDERING_VULKAN
@ -85,7 +77,7 @@ static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuBorderOp),
GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_border_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_border_op_vk_command,
#endif
@ -96,6 +88,7 @@ static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_border_info,
#endif
gsk_gpu_border_op_print_instance,
gsk_gpu_border_setup_attrib_locations,
gsk_gpu_border_setup_vao
};

View File

@ -20,24 +20,17 @@ struct _GskGpuBoxShadowOp
};
static void
gsk_gpu_box_shadow_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_box_shadow_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_rgba (string, instance->color);
g_string_append_printf (string, "%g %g %g %g ",
instance->shadow_offset[0], instance->shadow_offset[1],
instance->blur_radius, instance->shadow_spread);
gsk_gpu_print_newline (string);
}
#ifdef GDK_RENDERING_VULKAN
@ -63,7 +56,7 @@ static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuBoxShadowOp),
GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_box_shadow_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_box_shadow_op_vk_command,
#endif
@ -74,6 +67,7 @@ static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_boxshadow_info,
#endif
gsk_gpu_box_shadow_op_print_instance,
gsk_gpu_boxshadow_setup_attrib_locations,
gsk_gpu_boxshadow_setup_vao
};

View File

@ -16,22 +16,15 @@ struct _GskGpuColorizeOp
};
static void
gsk_gpu_colorize_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_colorize_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_rgba (string, instance->color);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_colorize_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_colorize_info,
#endif
gsk_gpu_colorize_op_print_instance,
gsk_gpu_colorize_setup_attrib_locations,
gsk_gpu_colorize_setup_vao
};

View File

@ -16,21 +16,14 @@ struct _GskGpuColorMatrixOp
};
static void
gsk_gpu_color_matrix_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_color_matrix_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_color_matrix_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -49,6 +42,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_colormatrix_info,
#endif
gsk_gpu_color_matrix_op_print_instance,
gsk_gpu_colormatrix_setup_attrib_locations,
gsk_gpu_colormatrix_setup_vao
};

View File

@ -17,21 +17,14 @@ struct _GskGpuColorOp
};
static void
gsk_gpu_color_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_color_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_rgba (string, instance->color);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_color_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_color_info,
#endif
gsk_gpu_color_op_print_instance,
gsk_gpu_color_setup_attrib_locations,
gsk_gpu_color_setup_vao
};

View File

@ -18,20 +18,13 @@ struct _GskGpuConicGradientOp
};
static void
gsk_gpu_conic_gradient_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_conic_gradient_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_conic_gradient_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_conicgradient_info,
#endif
gsk_gpu_conic_gradient_op_print_instance,
gsk_gpu_conicgradient_setup_attrib_locations,
gsk_gpu_conicgradient_setup_vao
};

View File

@ -16,23 +16,16 @@ struct _GskGpuCrossFadeOp
};
static void
gsk_gpu_cross_fade_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_cross_fade_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->start_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->end_id);
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 = {
@ -40,7 +33,7 @@ static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuCrossFadeOp),
GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_cross_fade_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -51,6 +44,7 @@ static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_crossfade_info,
#endif
gsk_gpu_cross_fade_op_print_instance,
gsk_gpu_crossfade_setup_attrib_locations,
gsk_gpu_crossfade_setup_vao
};

View File

@ -40,6 +40,7 @@ struct _GskGpuFramePrivate
GskGpuOps ops;
GskGpuOp *first_op;
GskGpuOp *last_op;
GskGpuBuffer *vertex_buffer;
guchar *vertex_buffer_data;
@ -70,6 +71,8 @@ gsk_gpu_frame_default_cleanup (GskGpuFrame *self)
gsk_gpu_op_finish (op);
}
gsk_gpu_ops_set_size (&priv->ops, 0);
priv->last_op = NULL;
}
static void
@ -343,6 +346,8 @@ gsk_gpu_frame_sort_ops (GskGpuFrame *self)
priv->first_op = sort_data.command.first;
if (sort_data.command.last)
sort_data.command.last->next = NULL;
priv->last_op = NULL;
}
gpointer
@ -360,7 +365,17 @@ gsk_gpu_frame_alloc_op (GskGpuFrame *self,
NULL,
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 *

View File

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

View File

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

View File

@ -16,22 +16,15 @@ struct _GskGpuMaskOp
};
static void
gsk_gpu_mask_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->source_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 = {
@ -39,7 +32,7 @@ static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
GSK_GPU_OP_SIZE (GskGpuMaskOp),
GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_mask_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_mask_info,
#endif
gsk_gpu_mask_op_print_instance,
gsk_gpu_mask_setup_attrib_locations,
gsk_gpu_mask_setup_vao
};

View File

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

View File

@ -17,21 +17,14 @@ struct _GskGpuRoundedColorOp
};
static void
gsk_gpu_rounded_color_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_rounded_color_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_rgba (string, instance->color);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_rounded_color_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -50,6 +43,7 @@ static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_roundedcolor_info,
#endif
gsk_gpu_rounded_color_op_print_instance,
gsk_gpu_roundedcolor_setup_attrib_locations,
gsk_gpu_roundedcolor_setup_vao
};

View File

@ -3,6 +3,7 @@
#include "gskgpushaderopprivate.h"
#include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskgldescriptorsprivate.h"
#include "gskgldeviceprivate.h"
#include "gskglframeprivate.h"
@ -26,6 +27,36 @@ gsk_gpu_shader_op_finish (GskGpuOp *op)
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
GskGpuOp *
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;
GskVulkanDescriptors *desc;
GskGpuOp *next;
gsize i, n;
gsize i, n_ops, max_ops_per_draw;
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)),
GDK_VULKAN_FEATURE_NONUNIFORM_INDEXING))
n = MAX_MERGE_OPS;
max_ops_per_draw = MAX_MERGE_OPS;
else
n = 1;
i = 1;
max_ops_per_draw = 1;
desc = GSK_VULKAN_DESCRIPTORS (self->desc);
if (desc && state->desc != desc)
{
@ -53,7 +84,8 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
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;
@ -61,10 +93,10 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
next_shader->desc != self->desc ||
next_shader->variation != self->variation ||
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;
i++;
n_ops += next_shader->n_ops;
}
vkCmdBindPipeline (state->vk_command_buffer,
@ -78,9 +110,12 @@ gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
state->vk_format,
state->vk_render_pass));
for (i = 0; i < n_ops; i += max_ops_per_draw)
{
vkCmdDraw (state->vk_command_buffer,
6 * instance_scale, i,
0, self->vertex_offset / shader_op_class->vertex_size);
6 * instance_scale, MIN (max_ops_per_draw, n_ops - i),
0, self->vertex_offset / shader_op_class->vertex_size + i);
}
return next;
}
@ -104,7 +139,7 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
GskGpuShaderOpClass *shader_op_class = (GskGpuShaderOpClass *) op->op_class;
GskGLDescriptors *desc;
GskGpuOp *next;
gsize i, n, n_external;
gsize i, n_ops, n_external, max_ops_per_draw;
desc = GSK_GL_DESCRIPTORS (self->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))
n = MAX_MERGE_OPS;
max_ops_per_draw = MAX_MERGE_OPS;
else
n = 1;
i = 1;
for (next = op->next; next && i < n; next = next->next)
max_ops_per_draw = 1;
n_ops = self->n_ops;
for (next = op->next; next; next = next->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->variation != self->variation ||
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;
i++;
n_ops += next_shader->n_ops;
}
for (i = 0; i < n_ops; i += max_ops_per_draw)
{
if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE))
{
glDrawArraysInstancedBaseInstance (GL_TRIANGLES,
0,
6 * instance_scale,
i,
self->vertex_offset / shader_op_class->vertex_size);
MIN (max_ops_per_draw, n_ops - i),
self->vertex_offset / shader_op_class->vertex_size + i);
}
else
{
shader_op_class->setup_vao (self->vertex_offset);
shader_op_class->setup_vao (self->vertex_offset + i * shader_op_class->vertex_size);
glDrawArraysInstanced (GL_TRIANGLES,
0,
6 * instance_scale,
i);
MIN (max_ops_per_draw, n_ops - i));
}
}
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);
}
GskGpuShaderOp *
void
gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
const GskGpuShaderOpClass *op_class,
guint32 variation,
@ -190,20 +229,39 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
GskGpuDescriptors *desc,
gpointer out_vertex_data)
{
GskGpuShaderOp *self;
GskGpuOp *last;
GskGpuShaderOp *last_shader;
gsize vertex_offset;
vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size);
last = gsk_gpu_frame_get_last_op (frame);
/* careful: We're casting without checking, but the if() does the check */
last_shader = (GskGpuShaderOp *) last;
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
{
GskGpuShaderOp *self;
self = (GskGpuShaderOp *) gsk_gpu_op_alloc (frame, &op_class->parent_class);
self->variation = variation;
self->clip = clip;
self->vertex_offset = vertex_offset;
if (desc)
self->desc = g_object_ref (desc);
else
self->desc = NULL;
self->vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size);
*((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, self->vertex_offset);
return self;
self->n_ops = 1;
}
*((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, vertex_offset);
}

View File

@ -14,6 +14,7 @@ struct _GskGpuShaderOp
guint32 variation;
GskGpuShaderClip clip;
gsize vertex_offset;
gsize n_ops;
};
struct _GskGpuShaderOpClass
@ -25,11 +26,14 @@ struct _GskGpuShaderOpClass
#ifdef GDK_RENDERING_VULKAN
const VkPipelineVertexInputStateCreateInfo *vertex_input_state;
#endif
void (* print_instance) (GskGpuShaderOp *shader,
gpointer instance,
GString *string);
void (* setup_attrib_locations) (GLuint program);
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,
guint32 variation,
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_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent);
#ifdef GDK_RENDERING_VULKAN
GskGpuOp * gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
GskGpuFrame *frame,

View File

@ -19,21 +19,14 @@ struct _GskGpuStraightAlphaOp
};
static void
gsk_gpu_straight_alpha_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_straight_alpha_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_straight_alpha_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -52,6 +45,7 @@ static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_straightalpha_info,
#endif
gsk_gpu_straight_alpha_op_print_instance,
gsk_gpu_straightalpha_setup_attrib_locations,
gsk_gpu_straightalpha_setup_vao
};

View File

@ -16,21 +16,14 @@ struct _GskGpuTextureOp
};
static void
gsk_gpu_texture_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_texture_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
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_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_texture_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -49,6 +42,7 @@ static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_texture_info,
#endif
gsk_gpu_texture_op_print_instance,
gsk_gpu_texture_setup_attrib_locations,
gsk_gpu_texture_setup_vao
};

View File

@ -17,20 +17,13 @@ struct _GskGpuUberOp
};
static void
gsk_gpu_uber_op_print (GskGpuOp *op,
GskGpuFrame *frame,
GString *string,
guint indent)
gsk_gpu_uber_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
GskGpuShaderOp *shader = (GskGpuShaderOp *) op;
GskGpuUberInstance *instance;
GskGpuUberInstance *instance = 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_newline (string);
}
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_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_uber_op_print,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
@ -49,8 +42,9 @@ static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_uber_info,
#endif
gsk_gpu_uber_op_print_instance,
gsk_gpu_uber_setup_attrib_locations,
gsk_gpu_uber_setup_vao
gsk_gpu_uber_setup_vao,
};
void