Merge branch 'gl-renderer-more-defensive' into 'main'

gsk: Stop setting uniforms when we are out of batches

See merge request GNOME/gtk!5981
This commit is contained in:
Matthias Clasen 2023-05-17 00:29:40 +00:00
commit 2ec1bd7248
3 changed files with 962 additions and 886 deletions

View File

@ -579,7 +579,7 @@ discard_batch (GskGLCommandQueue *self)
self->batches.len--;
}
void
gboolean
gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
GskGLUniformProgram *program,
guint width,
@ -596,7 +596,7 @@ gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
* of batches we can have in one frame.
*/
if (will_ignore_batch (self))
return;
return FALSE;
self->program_info = program;
@ -617,6 +617,8 @@ gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
self->fbo_max = MAX (self->fbo_max, batch->draw.framebuffer);
self->in_draw = TRUE;
return TRUE;
}
void

View File

@ -331,7 +331,7 @@ void gsk_gl_command_queue_delete_program (GskGLCommandQueue
void gsk_gl_command_queue_clear (GskGLCommandQueue *self,
guint clear_bits,
const graphene_rect_t *viewport);
void gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
gboolean gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
GskGLUniformProgram *program_info,
guint width,
guint height);

View File

@ -1095,16 +1095,17 @@ gsk_gl_render_job_draw_offscreen_rect (GskGLRenderJob *job,
color);
}
static inline void
static inline gboolean
gsk_gl_render_job_begin_draw (GskGLRenderJob *job,
GskGLProgram *program)
{
job->current_program = program;
gsk_gl_command_queue_begin_draw (job->command_queue,
if (!gsk_gl_command_queue_begin_draw (job->command_queue,
program->program_info,
job->viewport.size.width,
job->viewport.size.height);
job->viewport.size.height))
return FALSE;
gsk_gl_uniform_state_set4fv (program->uniforms,
program->program_info,
@ -1136,6 +1137,8 @@ gsk_gl_render_job_begin_draw (GskGLRenderJob *job,
UNIFORM_SHARED_ALPHA,
job->driver->stamps[UNIFORM_SHARED_ALPHA],
job->alpha);
return TRUE;
}
#define CHOOSE_PROGRAM(job,name) \
@ -1267,7 +1270,9 @@ done:
gsk_transform_unref (transform);
}
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (!gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
goto out;
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -1276,6 +1281,7 @@ done:
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
out:
if (scale_x < 0 || scale_y < 0)
gsk_gl_render_job_pop_modelview (job);
}
@ -1330,7 +1336,8 @@ blur_offscreen (GskGLRenderJob *job,
/* Begin drawing the first horizontal pass, using offscreen as the
* source texture for the program.
*/
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -1351,13 +1358,15 @@ blur_offscreen (GskGLRenderJob *job,
0, 1, 1, 0,
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
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);
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
/* Draw using blur program with first pass as source texture */
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -1378,6 +1387,7 @@ blur_offscreen (GskGLRenderJob *job,
0, 1, 1, 0,
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
gsk_gl_render_job_end_draw (job);
}
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_pop_clip (job);
@ -1476,8 +1486,8 @@ gsk_gl_render_job_visit_color_node (GskGLRenderJob *job,
{
GskGLRenderOffscreen offscreen = {0};
gsk_gl_render_job_begin_draw (job, program);
if (gsk_gl_render_job_begin_draw (job, program))
{
/* The top left few pixels in our atlases are always
* solid white, so we can use it here, without
* having to choose any particular atlas texture.
@ -1495,12 +1505,15 @@ gsk_gl_render_job_visit_color_node (GskGLRenderJob *job,
gsk_gl_render_job_end_draw (job);
}
}
else
{
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)))
{
gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, color);
gsk_gl_render_job_end_draw (job);
}
}
}
static inline void
@ -1519,7 +1532,8 @@ gsk_gl_render_job_visit_linear_gradient_node (GskGLRenderJob *job,
g_assert (n_color_stops < MAX_GRADIENT_STOPS);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, linear_gradient));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, linear_gradient)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_LINEAR_GRADIENT_NUM_COLOR_STOPS, 0,
n_color_stops);
@ -1535,6 +1549,7 @@ gsk_gl_render_job_visit_linear_gradient_node (GskGLRenderJob *job,
repeat);
gsk_gl_render_job_draw_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -1551,7 +1566,8 @@ gsk_gl_render_job_visit_conic_gradient_node (GskGLRenderJob *job,
g_assert (n_color_stops < MAX_GRADIENT_STOPS);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, conic_gradient));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, conic_gradient)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_CONIC_GRADIENT_NUM_COLOR_STOPS, 0,
n_color_stops);
@ -1567,6 +1583,7 @@ gsk_gl_render_job_visit_conic_gradient_node (GskGLRenderJob *job,
bias);
gsk_gl_render_job_draw_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -1586,7 +1603,8 @@ gsk_gl_render_job_visit_radial_gradient_node (GskGLRenderJob *job,
g_assert (n_color_stops < MAX_GRADIENT_STOPS);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, radial_gradient));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, radial_gradient)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_RADIAL_GRADIENT_NUM_COLOR_STOPS, 0,
n_color_stops);
@ -1608,6 +1626,7 @@ gsk_gl_render_job_visit_radial_gradient_node (GskGLRenderJob *job,
1.0f / (vradius * job->scale_y));
gsk_gl_render_job_draw_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -1660,7 +1679,8 @@ gsk_gl_render_job_visit_clipped_child (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -1669,6 +1689,7 @@ gsk_gl_render_job_visit_clipped_child (GskGLRenderJob *job,
gsk_gl_render_job_draw_offscreen_rect (job, clip);
gsk_gl_render_job_end_draw (job);
}
}
}
static inline void
@ -1748,7 +1769,8 @@ gsk_gl_render_job_visit_rounded_clip_node (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -1757,6 +1779,7 @@ gsk_gl_render_job_visit_rounded_clip_node (GskGLRenderJob *job,
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
}
}
static inline void
@ -1769,8 +1792,8 @@ gsk_gl_render_job_visit_rect_border_node (GskGLRenderJob *job,
const graphene_size_t *size = &node->bounds.size;
guint16 color[4];
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)))
{
if (widths[0] > 0)
{
rgba_to_half (&colors[0], color);
@ -1804,6 +1827,7 @@ gsk_gl_render_job_visit_rect_border_node (GskGLRenderJob *job,
}
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -1852,8 +1876,8 @@ gsk_gl_render_job_visit_border_node (GskGLRenderJob *job,
gsk_gl_render_job_translate_rounded_rect (job, rounded_outline, &outline);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, border));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, border)))
{
gsk_gl_program_set_uniform4fv (job->current_program,
UNIFORM_BORDER_WIDTHS, 0,
1,
@ -1923,6 +1947,7 @@ gsk_gl_render_job_visit_border_node (GskGLRenderJob *job,
}
gsk_gl_render_job_end_draw (job);
}
}
/* A special case for a pattern that occurs frequently with CSS
@ -1956,8 +1981,8 @@ gsk_gl_render_job_visit_css_background (GskGLRenderJob *job,
gsk_gl_render_job_translate_rounded_rect (job, rounded_outline, &outline);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, filled_border));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, filled_border)))
{
gsk_gl_program_set_uniform4fv (job->current_program,
UNIFORM_FILLED_BORDER_WIDTHS, 0,
1,
@ -1976,6 +2001,7 @@ gsk_gl_render_job_visit_css_background (GskGLRenderJob *job,
vertices[5] = (GskGLDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
gsk_gl_render_job_end_draw (job);
}
}
/* Returns TRUE if applying @transform to @bounds
@ -2106,7 +2132,8 @@ gsk_gl_render_job_visit_transform_node (GskGLRenderJob *job,
if (transform)
gsk_gl_render_job_push_modelview (job, transform);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -2116,6 +2143,7 @@ gsk_gl_render_job_visit_transform_node (GskGLRenderJob *job,
linear_filter ? GL_LINEAR : GL_NEAREST);
gsk_gl_render_job_draw_offscreen (job, &child->bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
if (transform)
gsk_gl_render_job_pop_modelview (job);
@ -2147,7 +2175,8 @@ gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
gsk_gl_render_job_translate_rounded_rect (job, outline, &transformed_outline);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)))
{
gsk_gl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline);
@ -2161,6 +2190,7 @@ gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, color);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -2248,7 +2278,8 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
gsk_gl_render_job_translate_rounded_rect (job, &outline_to_blur, &transformed_outline);
/* Actual inset shadow outline drawing */
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)))
{
gsk_gl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline);
@ -2264,6 +2295,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
0, 0, texture_width, texture_height,
color);
gsk_gl_render_job_end_draw (job);
}
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_pop_clip (job);
@ -2311,7 +2343,8 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
offscreen.area.x2 = tx2;
offscreen.area.y2 = ty2;
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -2319,6 +2352,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
blurred_texture_id);
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
if (needs_clip)
gsk_gl_render_job_pop_clip (job);
@ -2353,7 +2387,8 @@ gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
gsk_gl_render_job_translate_rounded_rect (job, outline, &transformed_outline);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow)))
{
gsk_gl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline);
@ -2407,6 +2442,7 @@ gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
color);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -2526,10 +2562,12 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
/* Draw the outline using color program */
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)))
{
gsk_gl_render_job_draw_with_color (job, 0, 0, texture_width, texture_height,
(guint16[]){ FP16_ONE, FP16_ONE, FP16_ONE, FP16_ONE });
gsk_gl_render_job_end_draw (job);
}
/* Reset state from offscreen */
gsk_gl_render_job_pop_clip (job);
@ -2570,7 +2608,8 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
offscreen.texture_id = blurred_texture_id;
init_full_texture_region (&offscreen);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -2587,13 +2626,15 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
&offscreen,
color);
gsk_gl_render_job_end_draw (job);
}
return;
}
/* slicing */
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -2757,6 +2798,7 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
}
gsk_gl_render_job_end_draw (job);
}
}
static inline gboolean G_GNUC_PURE
@ -2823,7 +2865,8 @@ gsk_gl_render_job_visit_cross_fade_node (GskGLRenderJob *job,
g_assert (offscreen_end.texture_id);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, cross_fade));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, cross_fade)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -2839,6 +2882,7 @@ gsk_gl_render_job_visit_cross_fade_node (GskGLRenderJob *job,
progress);
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen_end);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -2872,7 +2916,8 @@ gsk_gl_render_job_visit_opacity_node (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -2881,6 +2926,7 @@ gsk_gl_render_job_visit_opacity_node (GskGLRenderJob *job,
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
}
gsk_gl_render_job_set_alpha (job, prev_alpha);
}
@ -2952,8 +2998,8 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
yshift = compute_phase_and_pos (y, &ypos);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring)))
{
batch = gsk_gl_command_queue_get_batch (job->command_queue);
vertices = gsk_gl_command_queue_add_n_vertices (job->command_queue, num_glyphs);
@ -3047,6 +3093,7 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
gsk_gl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3130,7 +3177,8 @@ gsk_gl_render_job_visit_shadow_node (GskGLRenderJob *job,
}
gsk_gl_render_job_offset (job, dx, dy);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3139,6 +3187,7 @@ gsk_gl_render_job_visit_shadow_node (GskGLRenderJob *job,
rgba_to_half (&shadow->color, color);
gsk_gl_render_job_draw_offscreen_with_color (job, &bounds, &offscreen, color);
gsk_gl_render_job_end_draw (job);
}
gsk_gl_render_job_offset (job, -dx, -dy);
}
@ -3184,7 +3233,8 @@ gsk_gl_render_job_visit_blur_node (GskGLRenderJob *job,
if (cache_texture)
gsk_gl_driver_cache_texture (job->driver, &key, offscreen.texture_id);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3195,6 +3245,7 @@ gsk_gl_render_job_visit_blur_node (GskGLRenderJob *job,
0, 1, 1, 0,
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO } );
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3232,7 +3283,8 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
{
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3240,6 +3292,7 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
bottom_offscreen.texture_id);
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &bottom_offscreen);
gsk_gl_render_job_end_draw (job);
}
return;
}
@ -3247,7 +3300,8 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blend));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blend)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3263,6 +3317,7 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
gsk_blend_node_get_blend_mode (node));
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3307,7 +3362,8 @@ gsk_gl_render_job_visit_mask_node (GskGLRenderJob *job,
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, mask));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, mask)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3323,6 +3379,7 @@ gsk_gl_render_job_visit_mask_node (GskGLRenderJob *job,
gsk_mask_node_get_mask_mode (node));
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3346,7 +3403,8 @@ gsk_gl_render_job_visit_color_matrix_node (GskGLRenderJob *job,
graphene_vec4_to_float (gsk_color_matrix_node_get_color_offset (node), offset);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color_matrix));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color_matrix)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3361,6 +3419,7 @@ gsk_gl_render_job_visit_color_matrix_node (GskGLRenderJob *job,
offset);
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3369,9 +3428,11 @@ gsk_gl_render_job_visit_gl_shader_node_fallback (GskGLRenderJob *job,
{
guint16 pink[4] = { 15360, 13975, 14758, 15360 }; /* 255 105 180 */
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)))
{
gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, pink);
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3423,7 +3484,8 @@ 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_render_job_begin_draw (job, program);
if (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, 0,
@ -3486,6 +3548,7 @@ gsk_gl_render_job_visit_gl_shader_node (GskGLRenderJob *job,
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
}
}
static void
@ -3553,8 +3616,8 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3566,6 +3629,7 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
gsk_gl_render_job_draw_offscreen (job, bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
}
else
{
float min_x = job->offset_x + bounds->origin.x;
@ -3578,8 +3642,8 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (slices != NULL);
g_assert (n_slices > 0);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
for (unsigned int i = 0; i < n_slices; i++)
{
const GskGLTextureSlice *slice = &slices[i];
@ -3609,6 +3673,7 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
gsk_gl_render_job_end_draw (job);
}
}
}
static inline void
@ -3706,7 +3771,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
u1 = (clip_rect.origin.x + clip_rect.size.width - bounds->origin.x) / bounds->size.width;
v1 = (clip_rect.origin.y + clip_rect.size.height - bounds->origin.y) / bounds->size.height;
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3721,6 +3787,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
gsk_gl_render_job_end_draw (job);
}
}
else
{
float scale_x = bounds->size.width / texture->width;
@ -3730,8 +3797,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_driver_slice_texture (job->driver, texture, filter == GSK_SCALING_FILTER_TRILINEAR, &slices, &n_slices);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
for (guint i = 0; i < n_slices; i++)
{
const GskGLTextureSlice *slice = &slices[i];
@ -3767,6 +3834,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_render_job_end_draw (job);
}
}
gsk_gl_render_job_pop_clip (job);
gsk_gl_render_job_pop_modelview (job);
@ -3779,7 +3847,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
render_texture:
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3794,6 +3863,7 @@ render_texture:
clip_rect.size.height / ceilf (clip_rect.size.height), 0,
(guint16[]){ FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO } );
gsk_gl_render_job_end_draw (job);
}
}
static inline void
@ -3829,7 +3899,8 @@ 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_render_job_begin_draw (job, CHOOSE_PROGRAM (job, repeat));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, repeat)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -3849,6 +3920,7 @@ gsk_gl_render_job_visit_repeat_node (GskGLRenderJob *job,
offscreen.was_offscreen ? offscreen.area.y : offscreen.area.y2);
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
}
static void
@ -4313,7 +4385,8 @@ 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_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@ -4321,6 +4394,7 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
texture_id);
gsk_gl_render_job_draw_rect (job, &job->viewport);
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, job->default_framebuffer);