gdkgl: Check for GLsync before using it
Copy what we do in GTK4: Check for GL >= 3.2 or GLES >= 3.0 or the
GL_ARB_sync extension.
Then store that info for a (private) gdk_gl_context_has_sync()
function.
And then check that function before using GLsync objects as introduced
by commit 9811485990.
Fixes #5749
This commit is contained in:
10
gdk/gdkgl.c
10
gdk/gdkgl.c
@ -341,7 +341,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GdkGLContext *paint_context;
|
||||
GdkGLContext *paint_context, *current_context;
|
||||
cairo_surface_t *image;
|
||||
cairo_matrix_t matrix;
|
||||
int dx, dy, window_scale;
|
||||
@ -352,7 +352,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
int alpha_size = 0;
|
||||
cairo_region_t *clip_region;
|
||||
GdkGLContextPaintData *paint_data;
|
||||
GLsync sync = NULL;
|
||||
GLsync sync;
|
||||
|
||||
impl_window = window->impl_window;
|
||||
|
||||
@ -366,9 +366,13 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
||||
}
|
||||
|
||||
clip_region = gdk_cairo_region_from_clip (cr);
|
||||
current_context = gdk_gl_context_get_current ();
|
||||
|
||||
if ((gdk_gl_context_get_current () != NULL) && (gdk_gl_context_get_current () != paint_context))
|
||||
if ((current_context != NULL) && (current_context != paint_context) &&
|
||||
gdk_gl_context_has_sync (current_context))
|
||||
sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
else
|
||||
sync = NULL;
|
||||
|
||||
gdk_gl_context_make_current (paint_context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user