diff options
author | Matthias Clasen <mclasen@redhat.com> | 2023-01-28 11:04:10 -0500 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2023-04-28 06:23:40 +0200 |
commit | bec0afa61b09d02eb1118a0ab1fd2609755ef961 (patch) | |
tree | 00ecf9403c8058c4b401b63fee14946a897ae3b6 /gtk/gtkglarea.c | |
parent | 8292b846d58a09295e4e30c25c4e19c3ea4be8e1 (diff) | |
download | gtk+-bec0afa61b09d02eb1118a0ab1fd2609755ef961.tar.gz |
glarea: Synchronize
Create a fence object and pass it along when
creating the GL texture, so that the GL renderer
can wait for the texture to be ready.
Diffstat (limited to 'gtk/gtkglarea.c')
-rw-r--r-- | gtk/gtkglarea.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c index 33f7881281..f547a4995f 100644 --- a/gtk/gtkglarea.c +++ b/gtk/gtkglarea.c @@ -32,6 +32,8 @@ #include "gtksnapshot.h" #include "gtkrenderlayoutprivate.h" #include "gtkcssnodeprivate.h" +#include "gdk/gdkgltextureprivate.h" +#include "gdk/gdkglcontextprivate.h" #include <epoxy/gl.h> @@ -697,6 +699,15 @@ static void release_texture (gpointer data) { Texture *texture = data; + gpointer sync; + + sync = gdk_gl_texture_builder_get_sync (texture->builder); + if (sync) + { + glDeleteSync (sync); + gdk_gl_texture_builder_set_sync (texture->builder, NULL); + } + texture->holder = NULL; } @@ -742,6 +753,7 @@ gtk_gl_area_snapshot (GtkWidget *widget, if (status == GL_FRAMEBUFFER_COMPLETE) { Texture *texture; + gpointer sync = NULL; if (priv->needs_render || priv->auto_render) { @@ -760,6 +772,11 @@ gtk_gl_area_snapshot (GtkWidget *widget, priv->texture = NULL; priv->textures = g_list_prepend (priv->textures, texture); + if (gdk_gl_context_has_sync (priv->context)) + sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + gdk_gl_texture_builder_set_sync (texture->builder, sync); + texture->holder = gdk_gl_texture_builder_build (texture->builder, release_texture, texture); |