[Spice-devel] [PATCH spice-gtk 5/7] egl: fix multiple gl display flickering
Marc-André Lureau
marcandre.lureau at gmail.com
Fri May 20 16:23:02 UTC 2016
On Fri, May 20, 2016 at 5:16 PM, Marc-André Lureau
<marcandre.lureau at gmail.com> wrote:
> For some unclear reason, when multiple display use gl in the same
> process (with virt-manager for ex), the texture content can be
> overwritten by another display on update.
>
> Although the gl contexts are differents when using multiple widgets,
> even when sharing a texture ID, it shouldn't overwrite the other context
> texture, there is something fishy.
>
> Set the image texture target before drawing to solve this for now.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> ---
> src/spice-widget-egl.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
> index 210b834..5c24524 100644
> --- a/src/spice-widget-egl.c
> +++ b/src/spice-widget-egl.c
> @@ -548,8 +548,12 @@ void spice_egl_update_display(SpiceDisplay *display)
> }
> SPICE_DEBUG("update %f +%d+%d %dx%d +%f+%f %fx%f", s, x, y, w, h,
> tx, ty, tw, th);
> -
> glBindTexture(GL_TEXTURE_2D, d->egl.tex_id);
> + /* FIXME: this should be only necessary on scanout update */
actually, it's the same issue as with other multiple display bugs, we
need to make context current in spice_egl_update_scanout(), otherwise
it may manipulate a texture from a different context, depending on the
last display to have changed it.
However, there doesn't seem to be an easy way to do that with
gtkglarea < 3.16, thus this patch is still valid. A further patch can
move it back to update_scanout() for 3.16 and x11, but it will stil
need this here for gtkglarea < 3.16.
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
> + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)d->egl.image);
> +
> glDisable(GL_BLEND);
> glGetIntegerv(GL_CURRENT_PROGRAM, &prog);
> glUseProgram(d->egl.prog);
> @@ -627,10 +631,6 @@ gboolean spice_egl_update_scanout(SpiceDisplay *display,
> (EGLClientBuffer)NULL,
> attrs);
>
> - glBindTexture(GL_TEXTURE_2D, d->egl.tex_id);
> - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
> - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)d->egl.image);
> d->egl.scanout = *scanout;
>
> return TRUE;
> --
> 2.7.4
>
--
Marc-André Lureau
More information about the Spice-devel
mailing list