Commit ab66c3d7 authored by Carlos Garnacho's avatar Carlos Garnacho

wayland: Disable EGL swap interval

We have a frame clock that ensures rendering is done as per the
output vsync. There is no need to have Mesa do the same for us.

This, most notably, ensures Mesa doesn't schedule frame callbacks
that will be left unattended if the compositor stops throttling
frames for its surface, this is eg. the case if the toplevel is
moved to another workspace.

Also, given a SwapInterval!=0 will always bring these unexpected
side effects, check that it's possible to disable it, and spew
a debug message if that isn't the case.

https://bugzilla.gnome.org/show_bug.cgi?id=769835
parent eb57651f
......@@ -120,6 +120,7 @@ struct _GdkWaylandDisplay
guint have_egl_buffer_age : 1;
guint have_egl_swap_buffers_with_damage : 1;
guint have_egl_surfaceless_context : 1;
EGLint egl_min_swap_interval;
};
struct _GdkWaylandDisplayClass
......
......@@ -369,6 +369,7 @@ gdk_wayland_display_init_gl (GdkDisplay *display)
static gboolean
find_eglconfig_for_window (GdkWindow *window,
EGLConfig *egl_config_out,
EGLint *min_swap_interval_out,
GError **error)
{
GdkDisplay *display = gdk_window_get_display (window);
......@@ -376,7 +377,7 @@ find_eglconfig_for_window (GdkWindow *window,
GdkVisual *visual = gdk_window_get_visual (window);
EGLint attrs[MAX_EGL_ATTRS];
EGLint count;
EGLConfig *configs;
EGLConfig *configs, chosen_config;
gboolean use_rgba;
int i = 0;
......@@ -429,9 +430,20 @@ find_eglconfig_for_window (GdkWindow *window,
}
/* Pick first valid configuration i guess? */
chosen_config = configs[0];
if (!eglGetConfigAttrib (display_wayland->egl_display, chosen_config,
EGL_MIN_SWAP_INTERVAL, min_swap_interval_out))
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
"Could not retrieve the minimum swap interval");
g_free (configs);
return FALSE;
}
if (egl_config_out != NULL)
*egl_config_out = configs[0];
*egl_config_out = chosen_config;
g_free (configs);
......@@ -465,7 +477,9 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
return NULL;
}
if (!find_eglconfig_for_window (window, &config, error))
if (!find_eglconfig_for_window (window, &config,
&display_wayland->egl_min_swap_interval,
error))
return NULL;
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
......@@ -543,5 +557,10 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
return FALSE;
}
if (display_wayland->egl_min_swap_interval == 0)
eglSwapInterval (display_wayland->egl_display, 0);
else
g_debug ("Can't disable GL swap interval");
return TRUE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment