gpu: Pass used images to shader ops
This by itself is just more work refcounting all those images, but there's actually a goal here, that will become visible in future commits. But this is split out for correctness and benchmarking purposes (the overhead from refcounting seems to be negligible on my computer).
This commit is contained in:
@@ -71,6 +71,8 @@ gsk_gpu_blend_mode_op (GskGpuFrame *frame,
|
||||
blend_mode,
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[2]) { bottom->image, top->image },
|
||||
(GskGpuSampler[2]) { bottom->sampler, top->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -72,6 +72,8 @@ gsk_gpu_blur_op_full (GskGpuFrame *frame,
|
||||
variation,
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[1]) { image->image },
|
||||
(GskGpuSampler[1]) { image->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
|
||||
|
||||
@@ -113,6 +113,8 @@ gsk_gpu_border_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_rounded_rect_to_float (outline, offset, instance->outline);
|
||||
|
||||
@@ -97,6 +97,8 @@ gsk_gpu_box_shadow_op (GskGpuFrame *frame,
|
||||
inset ? VARIATION_INSET : 0,
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (bounds, offset, instance->bounds);
|
||||
|
||||
@@ -66,6 +66,8 @@ gsk_gpu_colorize_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
descriptors,
|
||||
(GskGpuImage *[1]) { image->image },
|
||||
(GskGpuSampler[1]) { image->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (image->coverage ? image->coverage : image->bounds, offset, instance->rect);
|
||||
|
||||
@@ -66,6 +66,8 @@ gsk_gpu_color_matrix_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[1]) { image->image },
|
||||
(GskGpuSampler[1]) { image->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
|
||||
|
||||
@@ -66,6 +66,8 @@ gsk_gpu_color_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -73,6 +73,8 @@ gsk_gpu_conic_gradient_op (GskGpuFrame *frame,
|
||||
(gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GRADIENTS) ? VARIATION_SUPERSAMPLING : 0),
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -73,6 +73,8 @@ gsk_gpu_convert_op (GskGpuFrame *frame,
|
||||
(straight_alpha ? VARIATION_STRAIGHT_ALPHA : 0),
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[1]) { image->image },
|
||||
(GskGpuSampler[1]) { image->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
|
||||
|
||||
@@ -70,6 +70,8 @@ gsk_gpu_cross_fade_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[2]) { start->image, end->image },
|
||||
(GskGpuSampler[2]) { start->sampler, end->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -78,6 +78,8 @@ gsk_gpu_linear_gradient_op (GskGpuFrame *frame,
|
||||
(gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GRADIENTS) ? VARIATION_SUPERSAMPLING : 0),
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -70,6 +70,8 @@ gsk_gpu_mask_op (GskGpuFrame *frame,
|
||||
mask_mode,
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[2]) { source->image, mask->image },
|
||||
(GskGpuSampler[2]) { source->sampler, mask->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -80,6 +80,8 @@ gsk_gpu_radial_gradient_op (GskGpuFrame *frame,
|
||||
(gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GRADIENTS) ? VARIATION_SUPERSAMPLING : 0),
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
|
||||
@@ -65,6 +65,8 @@ gsk_gpu_rounded_color_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&instance);
|
||||
|
||||
gsk_rounded_rect_to_float (outline, offset, instance->outline);
|
||||
|
||||
@@ -27,6 +27,8 @@ gsk_gpu_shader_op_finish (GskGpuOp *op)
|
||||
GskGpuShaderOp *self = (GskGpuShaderOp *) op;
|
||||
|
||||
g_clear_object (&self->desc);
|
||||
g_clear_object (&self->images[0]);
|
||||
g_clear_object (&self->images[1]);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -192,7 +194,9 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
|
||||
next_shader->color_states != self->color_states ||
|
||||
next_shader->variation != self->variation ||
|
||||
next_shader->clip != self->clip ||
|
||||
next_shader->vertex_offset != self->vertex_offset + n_ops * shader_op_class->vertex_size)
|
||||
next_shader->vertex_offset != self->vertex_offset + n_ops * shader_op_class->vertex_size ||
|
||||
(shader_op_class->n_textures > 0 && (next_shader->images[0] != self->images[0] || next_shader->samplers[0] != self->samplers[0])) ||
|
||||
(shader_op_class->n_textures > 1 && (next_shader->images[1] != self->images[1] || next_shader->samplers[1] != self->samplers[1])))
|
||||
break;
|
||||
|
||||
n_ops += next_shader->n_ops;
|
||||
@@ -238,11 +242,13 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
||||
guint32 variation,
|
||||
GskGpuShaderClip clip,
|
||||
GskGpuDescriptors *desc,
|
||||
GskGpuImage **images,
|
||||
GskGpuSampler *samplers,
|
||||
gpointer out_vertex_data)
|
||||
{
|
||||
GskGpuOp *last;
|
||||
GskGpuShaderOp *last_shader;
|
||||
gsize vertex_offset;
|
||||
gsize i, vertex_offset;
|
||||
|
||||
vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size);
|
||||
|
||||
@@ -251,11 +257,12 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
||||
last_shader = (GskGpuShaderOp *) last;
|
||||
if (last &&
|
||||
last->op_class == (const GskGpuOpClass *) op_class &&
|
||||
last_shader->desc == desc &&
|
||||
last_shader->color_states == color_states &&
|
||||
last_shader->variation == variation &&
|
||||
last_shader->clip == clip &&
|
||||
last_shader->vertex_offset + last_shader->n_ops * op_class->vertex_size == vertex_offset)
|
||||
last_shader->vertex_offset + last_shader->n_ops * op_class->vertex_size == vertex_offset &&
|
||||
(op_class->n_textures < 1 || (last_shader->images[0] == images[0] && last_shader->samplers[0] == samplers[0])) &&
|
||||
(op_class->n_textures < 2 || (last_shader->images[1] == images[1] && last_shader->samplers[1] == samplers[1])))
|
||||
{
|
||||
last_shader->n_ops++;
|
||||
}
|
||||
@@ -273,6 +280,11 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
||||
else
|
||||
self->desc = NULL;
|
||||
self->n_ops = 1;
|
||||
for (i = 0; i < op_class->n_textures; i++)
|
||||
{
|
||||
self->images[i] = g_object_ref (images[i]);
|
||||
self->samplers[i] = samplers[i];
|
||||
}
|
||||
}
|
||||
|
||||
*((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, vertex_offset);
|
||||
|
||||
@@ -23,6 +23,8 @@ struct _GskGpuShaderOp
|
||||
GskGpuOp parent_op;
|
||||
|
||||
GskGpuDescriptors *desc;
|
||||
GskGpuImage *images[2];
|
||||
GskGpuSampler samplers[2];
|
||||
GskGpuColorStates color_states;
|
||||
guint32 variation;
|
||||
GskGpuShaderClip clip;
|
||||
@@ -53,6 +55,8 @@ void gsk_gpu_shader_op_alloc (GskGpuF
|
||||
guint32 variation,
|
||||
GskGpuShaderClip clip,
|
||||
GskGpuDescriptors *desc,
|
||||
GskGpuImage **images,
|
||||
GskGpuSampler *samplers,
|
||||
gpointer out_vertex_data);
|
||||
|
||||
void gsk_gpu_shader_op_finish (GskGpuOp *op);
|
||||
|
||||
@@ -63,6 +63,8 @@ gsk_gpu_texture_op (GskGpuFrame *frame,
|
||||
0,
|
||||
clip,
|
||||
desc,
|
||||
(GskGpuImage *[1]) { image->image },
|
||||
(GskGpuSampler[1]) { image->sampler },
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (image->coverage ? image->coverage : image->bounds, offset, instance->rect);
|
||||
|
||||
Reference in New Issue
Block a user