[gtk/wip/chergert/glproto: 512/526] bring begin/end draw into render job
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 512/526] bring begin/end draw into render job
- Date: Tue, 16 Feb 2021 01:14:40 +0000 (UTC)
commit 70b8b7d9b549b7734dee4fa6d5fc907fcf7ca5fc
Author: Christian Hergert <chergert redhat com>
Date: Fri Feb 12 14:34:50 2021 -0800
bring begin/end draw into render job
we can optimize things a bit better here
gsk/next/gskglprogramprivate.h | 12 ---
gsk/next/gskglrenderjob.c | 172 ++++++++++++++++++++++-------------------
2 files changed, 93 insertions(+), 91 deletions(-)
---
diff --git a/gsk/next/gskglprogramprivate.h b/gsk/next/gskglprogramprivate.h
index c66f6dabe2..7c3b9b7a51 100644
--- a/gsk/next/gskglprogramprivate.h
+++ b/gsk/next/gskglprogramprivate.h
@@ -77,18 +77,6 @@ void gsk_gl_program_begin_draw (GskGLProgram *self,
const GskRoundedRect *clip,
float alpha);
-static inline void
-gsk_gl_program_end_draw (GskGLProgram *self)
-{
- gsk_gl_command_queue_end_draw (self->driver->command_queue);
-}
-
-static inline void
-gsk_gl_program_split_draw (GskGLProgram *self)
-{
- gsk_gl_command_queue_split_draw (self->driver->command_queue);
-}
-
#define gsk_gl_program_get_uniform_location(s,k) ((s)->uniform_locations[(k)])
static inline void
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index ebe07af591..c45eaa7885 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -179,19 +179,6 @@ static gboolean gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob
const GskRenderNode *node,
GskGLRenderOffscreen *offscreen);
-static inline void
-gsk_gl_render_job_begin_draw (GskGLRenderJob *job,
- GskGLProgram *program)
-{
- /* TODO: Use stamps */
- gsk_gl_program_begin_draw (program,
- &job->viewport,
- &job->projection,
- &job->current_modelview->matrix,
- &job->current_clip->rect,
- job->alpha);
-}
-
static inline void
init_full_texture_region (GskGLRenderOffscreen *offscreen)
{
@@ -928,6 +915,58 @@ gsk_gl_render_job_draw_offscreen_rect (GskGLRenderJob *job,
gsk_gl_render_job_draw_coords (job, min_x, min_y, max_x, max_y);
}
+static inline void
+gsk_gl_render_job_begin_draw (GskGLRenderJob *job,
+ GskGLProgram *program)
+{
+ gsk_gl_command_queue_begin_draw (job->command_queue,
+ program->program_info,
+ &job->viewport);
+
+ if (program->uniform_locations[UNIFORM_SHARED_VIEWPORT] > -1)
+ gsk_gl_uniform_state_set4fv (program->uniforms,
+ program->program_info,
+ program->uniform_locations[UNIFORM_SHARED_VIEWPORT],
+ 1,
+ (const float *)&job->viewport);
+
+ if (program->uniform_locations[UNIFORM_SHARED_MODELVIEW] > -1)
+ gsk_gl_uniform_state_set_matrix (program->uniforms,
+ program->program_info,
+ program->uniform_locations[UNIFORM_SHARED_MODELVIEW],
+ &job->current_modelview->matrix);
+
+ if (program->uniform_locations[UNIFORM_SHARED_PROJECTION] > -1)
+ gsk_gl_uniform_state_set_matrix (program->uniforms,
+ program->program_info,
+ program->uniform_locations[UNIFORM_SHARED_PROJECTION],
+ &job->projection);
+
+ if (program->uniform_locations[UNIFORM_SHARED_CLIP_RECT] > -1)
+ gsk_gl_uniform_state_set_rounded_rect (program->uniforms,
+ program->program_info,
+ program->uniform_locations[UNIFORM_SHARED_CLIP_RECT],
+ &job->current_clip->rect);
+
+ if (program->uniform_locations[UNIFORM_SHARED_ALPHA] > -1)
+ gsk_gl_uniform_state_set1f (program->uniforms,
+ program->program_info,
+ program->uniform_locations[UNIFORM_SHARED_ALPHA],
+ job->alpha);
+}
+
+static inline void
+gsk_gl_render_job_split_draw (GskGLRenderJob *job)
+{
+ gsk_gl_command_queue_split_draw (job->command_queue);
+}
+
+static inline void
+gsk_gl_render_job_end_draw (GskGLRenderJob *job)
+{
+ gsk_gl_command_queue_end_draw (job->command_queue);
+}
+
static inline void
gsk_gl_render_job_visit_as_fallback (GskGLRenderJob *job,
const GskRenderNode *node)
@@ -962,7 +1001,7 @@ gsk_gl_render_job_visit_as_fallback (GskGLRenderJob *job,
UNIFORM_SHARED_SOURCE,
GL_TEXTURE_2D, GL_TEXTURE0, cached_id);
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
return;
}
@@ -1043,7 +1082,7 @@ gsk_gl_render_job_visit_as_fallback (GskGLRenderJob *job,
GL_TEXTURE0,
texture_id);
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
static guint
@@ -1113,7 +1152,7 @@ blur_offscreen (GskGLRenderJob *job,
UNIFORM_BLUR_DIR,
1, 0);
gsk_gl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height);
- gsk_gl_program_end_draw (job->driver->blur);
+ gsk_gl_render_job_end_draw (job);
/* Bind second pass framebuffer and clear it */
gsk_gl_command_queue_bind_framebuffer (job->command_queue, pass2->framebuffer_id);
@@ -1137,7 +1176,7 @@ blur_offscreen (GskGLRenderJob *job,
UNIFORM_BLUR_DIR,
0, 1);
gsk_gl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height);
- gsk_gl_program_end_draw (job->driver->blur);
+ gsk_gl_render_job_end_draw (job);
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_pop_clip (job);
@@ -1214,7 +1253,7 @@ gsk_gl_render_job_visit_color_node (GskGLRenderJob *job,
UNIFORM_COLOR_COLOR,
gsk_color_node_get_color (node));
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->color);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -1248,7 +1287,7 @@ gsk_gl_render_job_visit_linear_gradient_node (GskGLRenderJob *job,
UNIFORM_LINEAR_GRADIENT_REPEAT,
repeat);
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->linear_gradient);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -1280,7 +1319,7 @@ gsk_gl_render_job_visit_conic_gradient_node (GskGLRenderJob *job,
scale,
bias);
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->conic_gradient);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -1321,7 +1360,7 @@ gsk_gl_render_job_visit_radial_gradient_node (GskGLRenderJob *job,
1.0f / (hradius * job->scale_x),
1.0f / (vradius * job->scale_y));
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->radial_gradient);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -1379,7 +1418,7 @@ gsk_gl_render_job_visit_clipped_child (GskGLRenderJob *job,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_draw_offscreen_rect (job, &child->bounds);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
}
@@ -1490,7 +1529,7 @@ gsk_gl_render_job_visit_rounded_clip_node (GskGLRenderJob *job,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
}
@@ -1550,7 +1589,7 @@ gsk_gl_render_job_visit_uniform_border_node (GskGLRenderJob *job,
UNIFORM_INSET_SHADOW_OFFSET,
0, 0);
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->inset_shadow);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -1688,7 +1727,7 @@ gsk_gl_render_job_visit_border_node (GskGLRenderJob *job,
(const float *)&colors[indices[i]]);
vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
memcpy (vertices, side_data[indices[i]], sizeof (GskGLDrawVertex) * GSK_GL_N_VERTICES);
- gsk_gl_program_end_draw (job->driver->border);
+ gsk_gl_render_job_end_draw (job);
}
}
}
@@ -1794,7 +1833,7 @@ gsk_gl_render_job_visit_transform_node (GskGLRenderJob *job,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_load_vertices_from_offscreen (job, &child->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
gsk_gl_render_job_pop_modelview (job);
}
@@ -1830,7 +1869,7 @@ gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
gsk_inset_shadow_node_get_dx (node),
gsk_inset_shadow_node_get_dy (node));
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->inset_shadow);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -1933,7 +1972,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
offset_x * scale_x,
offset_y * scale_y);
gsk_gl_render_job_draw (job, 0, 0, texture_width, texture_height);
- gsk_gl_program_end_draw (job->driver->inset_shadow);
+ gsk_gl_render_job_end_draw (job);
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_pop_clip (job);
@@ -1995,7 +2034,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
GL_TEXTURE0,
blurred_texture_id);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
if (needs_clip)
gsk_gl_render_job_pop_clip (job);
@@ -2076,7 +2115,7 @@ gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
x, y + corner_sizes[0][1],
edge_sizes[3], h - corner_sizes[0][1] - corner_sizes[3][1]);
- gsk_gl_program_end_draw (job->driver->unblurred_outset_shadow);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2188,7 +2227,7 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
UNIFORM_COLOR_COLOR,
&white);
gsk_gl_render_job_draw (job, 0, 0, texture_width, texture_height);
- gsk_gl_program_end_draw (job->driver->color);
+ gsk_gl_render_job_end_draw (job);
/* Reset state from offscreen */
gsk_gl_render_job_pop_clip (job);
@@ -2247,7 +2286,7 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
texture_width / scale_x,
texture_height / scale_y),
&offscreen);
- gsk_gl_program_end_draw (job->driver->outset_shadow);
+ gsk_gl_render_job_end_draw (job);
return;
}
@@ -2402,7 +2441,7 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
}
}
- gsk_gl_program_end_draw (job->driver->outset_shadow);
+ gsk_gl_render_job_end_draw (job);
}
static inline gboolean G_GNUC_PURE
@@ -2474,7 +2513,7 @@ gsk_gl_render_job_visit_cross_fade_node (GskGLRenderJob *job,
UNIFORM_CROSS_FADE_PROGRESS,
progress);
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->cross_fade);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2512,7 +2551,7 @@ gsk_gl_render_job_visit_opacity_node (GskGLRenderJob *job,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
else
{
@@ -2597,7 +2636,7 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
if G_UNLIKELY (last_texture != texture_id)
{
if G_LIKELY (last_texture != 0)
- gsk_gl_program_split_draw (program);
+ gsk_gl_render_job_split_draw (job);
gsk_gl_program_set_uniform_texture (program,
UNIFORM_SHARED_SOURCE,
GL_TEXTURE_2D,
@@ -2656,7 +2695,7 @@ next:
if (used != num_glyphs)
gsk_gl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
- gsk_gl_program_end_draw (program);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2746,7 +2785,7 @@ gsk_gl_render_job_visit_shadow_node (GskGLRenderJob *job,
UNIFORM_COLORING_COLOR,
&shadow->color);
gsk_gl_render_job_load_vertices_from_offscreen (job, &bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->coloring);
+ gsk_gl_render_job_end_draw (job);
gsk_gl_render_job_offset (job, -dx, -dy);
}
@@ -2800,7 +2839,7 @@ gsk_gl_render_job_visit_blur_node (GskGLRenderJob *job,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_draw_coords (job, min_x, min_y, max_x, max_y);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2839,7 +2878,7 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
GL_TEXTURE0,
bottom_offscreen.texture_id);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &bottom_offscreen);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
return;
}
@@ -2860,7 +2899,7 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
UNIFORM_BLEND_MODE,
gsk_blend_node_get_blend_mode (node));
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->blend);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2898,7 +2937,7 @@ gsk_gl_render_job_visit_color_matrix_node (GskGLRenderJob *job,
1,
offset);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->color_matrix);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2912,7 +2951,7 @@ gsk_gl_render_job_visit_gl_shader_node_fallback (GskGLRenderJob *job,
UNIFORM_COLOR_COLOR,
&pink);
gsk_gl_render_job_draw_rect (job, &node->bounds);
- gsk_gl_program_end_draw (job->driver->color);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
@@ -2964,12 +3003,7 @@ gsk_gl_render_job_visit_gl_shader_node (GskGLRenderJob *job,
base = g_bytes_get_data (args, NULL);
uniforms = gsk_gl_shader_get_uniforms (shader, &n_uniforms);
- gsk_gl_program_begin_draw (program,
- &job->viewport,
- &job->projection,
- &job->current_modelview->matrix,
- &job->current_clip->rect,
- job->alpha);
+ gsk_gl_render_job_begin_draw (job, program);
for (guint i = 0; i < n_children; i++)
gsk_gl_program_set_uniform_texture (program,
UNIFORM_CUSTOM_TEXTURE1 + i,
@@ -3034,7 +3068,7 @@ gsk_gl_render_job_visit_gl_shader_node (GskGLRenderJob *job,
}
}
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_gl_program_end_draw (program);
+ gsk_gl_render_job_end_draw (job);
}
}
@@ -3078,19 +3112,14 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
- gsk_gl_program_begin_draw (job->driver->blit,
- &job->viewport,
- &job->projection,
- &job->current_modelview->matrix,
- &job->current_clip->rect,
- job->alpha);
+ gsk_gl_render_job_begin_draw (job, job->driver->blit);
gsk_gl_program_set_uniform_texture (job->driver->blit,
UNIFORM_SHARED_SOURCE,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
else
{
@@ -3108,12 +3137,7 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
g_assert (slices != NULL);
g_assert (n_slices > 0);
- gsk_gl_program_begin_draw (job->driver->blit,
- &job->viewport,
- &job->projection,
- &job->current_modelview->matrix,
- &job->current_clip->rect,
- job->alpha);
+ gsk_gl_render_job_begin_draw (job, job->driver->blit);
for (guint i = 0; i < n_slices; i ++)
{
@@ -3127,7 +3151,7 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
y2 = y1 + (slice->rect.height * scale_y);
if (i > 0)
- gsk_gl_program_split_draw (job->driver->blit);
+ gsk_gl_render_job_split_draw (job);
gsk_gl_program_set_uniform_texture (job->driver->blit,
UNIFORM_SHARED_SOURCE,
GL_TEXTURE_2D,
@@ -3166,7 +3190,7 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
vertices[5].uv[1] = 0;
}
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
}
}
@@ -3203,12 +3227,7 @@ gsk_gl_render_job_visit_repeat_node (GskGLRenderJob *job,
if (!gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen))
g_assert_not_reached ();
- gsk_gl_program_begin_draw (job->driver->repeat,
- &job->viewport,
- &job->projection,
- &job->current_modelview->matrix,
- &job->current_clip->rect,
- job->alpha);
+ gsk_gl_render_job_begin_draw (job, job->driver->repeat);
gsk_gl_program_set_uniform_texture (job->driver->repeat,
UNIFORM_SHARED_SOURCE,
GL_TEXTURE_2D,
@@ -3227,7 +3246,7 @@ gsk_gl_render_job_visit_repeat_node (GskGLRenderJob *job,
offscreen.area.x2,
offscreen.was_offscreen ? offscreen.area.y : offscreen.area.y2);
gsk_gl_render_job_load_vertices_from_offscreen (job, &node->bounds, &offscreen);
- gsk_gl_program_end_draw (job->driver->repeat);
+ gsk_gl_render_job_end_draw (job);
}
static void
@@ -3594,19 +3613,14 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
gsk_gl_render_job_set_alpha (job, 1.0f);
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
- gsk_gl_program_begin_draw (job->driver->blit,
- &job->viewport,
- &proj,
- &job->current_modelview->matrix,
- &job->current_clip->rect,
- job->alpha);
+ gsk_gl_render_job_begin_draw (job, job->driver->blit);
gsk_gl_program_set_uniform_texture (job->driver->blit,
UNIFORM_SHARED_SOURCE,
GL_TEXTURE_2D,
GL_TEXTURE0,
texture_id);
gsk_gl_render_job_draw_rect (job, &job->viewport);
- gsk_gl_program_end_draw (job->driver->blit);
+ gsk_gl_render_job_end_draw (job);
gdk_gl_context_push_debug_group (job->command_queue->context, "Executing command queue");
gsk_gl_command_queue_execute (job->command_queue, surface_height, 1, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]