[PATCH weston] nested: Fix skipping frames due to texture update without a context
Kristian Høgsberg
hoegsberg at gmail.com
Thu Aug 15 15:34:51 PDT 2013
On Thu, Aug 15, 2013 at 08:00:05PM +0300, Ander Conselvan de Oliveira wrote:
> To clarify, what causes the wrong context to be bound is the call to
> cairo_destroy_surface(). Some of the cairo-gl functions do a
> cairo_gl_context_acquire() followed by some operation and finish by doing
> cairo_gl_context_release(). That last call is basically
> eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), so
> when the call to glBindTexture() is made there is no current context.
Yeah, I see, and the animation visibly speeds up. But it's still only
running at half-speed. If you try running with WAYLAND_DEBUG=server
and then look at the time between commits we're running with ~34ms per
frame. Your commit doesn't change that, but we were only seeing every
other frame and thus effectively updating at ~15 fps. So there's more
brokeness in there we need to figure out.
Kristian
> Cheers,
> Ander
>
>
> 2013/7/16 Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com
> >
>
> > Calls into cairo-gles may change the current context, so it was only by
> > chance that sometimes we had the proper one as current and updated the
> > correct texture in surface_attach().
> >
> > In order to fix this, calling display_acquire_window_surface() before
> > binding the texture for setup is necessary. However this call has the
> > side effect of allocating a cairo surface for the window. At flush time,
> > the existence of this surface will cause an eglSwapBuffers(), even
> > if no rendering was done to it, leading to undefined contents on the
> > screen. This happens when the idle redraw task runs while there is a
> > pending frame callback.
> >
> > Workaround this by moving the texture setup from surface_attach() to the
> > redraw handler, so that the cairo surface is only allocated when
> > redering is done.
> > ---
> > clients/nested.c | 12 +++++++++---
> > 1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/clients/nested.c b/clients/nested.c
> > index a4e07f7..7137086 100644
> > --- a/clients/nested.c
> > +++ b/clients/nested.c
> > @@ -136,6 +136,15 @@ redraw_handler(struct widget *widget, void *data)
> > cairo_fill(cr);
> >
> > wl_list_for_each(s, &nested->surface_list, link) {
> > + display_acquire_window_surface(nested->display,
> > + nested->window, NULL);
> > +
> > + glBindTexture(GL_TEXTURE_2D, s->texture);
> > + image_target_texture_2d(GL_TEXTURE_2D, s->image);
> > +
> > + display_release_window_surface(nested->display,
> > + nested->window);
> > +
> > cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
> > cairo_set_source_surface(cr, s->cairo_surface,
> > allocation.x + 10,
> > @@ -313,9 +322,6 @@ surface_attach(struct wl_client *client,
> > surface->texture,
> > width, height);
> >
> > - glBindTexture(GL_TEXTURE_2D, surface->texture);
> > - image_target_texture_2d(GL_TEXTURE_2D, surface->image);
> > -
> > window_schedule_redraw(nested->window);
> > }
> >
> > --
> > 1.7.10.4
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> >
More information about the wayland-devel
mailing list