We try EGL first, but are very picky about what we accept.
If that fails, we try to go with GLX instead.
And if that also fails, we try EGL again, but this time accept anything.
The idea here is that EGL is the preferred method going forward, but GLX is
the tried and tested method that we know works. So if we detect issues with
EGL, we want to avoid using it in favor of GLX.
Also add a GDK_DEBUG=gl-egl option to force EGL at all costs and not try
GLX.
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context" },
{ "gl-gles", GDK_DEBUG_GL_GLES, "Use a GLES OpenGL context" },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
+ { "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11" },
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support" },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
GDK_DEBUG_GL_LEGACY = 1 << 15,
GDK_DEBUG_GL_GLES = 1 << 16,
GDK_DEBUG_GL_DEBUG = 1 << 17,
- GDK_DEBUG_GL_GLX = 1 << 18,
- GDK_DEBUG_VULKAN_DISABLE = 1 << 19,
- GDK_DEBUG_VULKAN_VALIDATE = 1 << 20,
- GDK_DEBUG_DEFAULT_SETTINGS= 1 << 21
+ GDK_DEBUG_GL_EGL = 1 << 18,
+ GDK_DEBUG_GL_GLX = 1 << 19,
+ GDK_DEBUG_VULKAN_DISABLE = 1 << 20,
+ GDK_DEBUG_VULKAN_VALIDATE = 1 << 21,
+ GDK_DEBUG_DEFAULT_SETTINGS= 1 << 22
} GdkDebugFlags;
extern guint _gdk_debug_flags;
static gboolean
gdk_x11_display_create_egl_config (GdkX11Display *display,
+ gboolean force,
Visual **out_visual,
int *out_depth,
GError **error)
_("No EGL configuration with required features found"));
return FALSE;
}
+ else if (!force && best_features != PERFECT)
+ {
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_NOT_AVAILABLE,
+ _("No perfect EGL configuration found"));
+ return FALSE;
+ }
return TRUE;
}
gboolean
gdk_x11_display_init_egl (GdkX11Display *self,
+ gboolean force,
Visual **out_visual,
int *out_depth,
GError **error)
return FALSE;
}
- if (!gdk_x11_display_create_egl_config (self, out_visual, out_depth, error))
+ if (!gdk_x11_display_create_egl_config (self, force, out_visual, out_depth, error))
{
eglTerminate (self->egl_display);
self->egl_display = NULL;
GError **error)
{
GdkDisplay *display G_GNUC_UNUSED = GDK_DISPLAY (self);
- GError *egl_error = NULL;
- GError *glx_error = NULL;
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_DISABLE))
{
return FALSE;
}
- if (!GDK_DISPLAY_DEBUG_CHECK (display, GL_GLX))
- {
- /* We favour EGL */
- if (gdk_x11_display_init_egl (self, out_visual, out_depth, &egl_error))
- return TRUE;
- }
-
- if (gdk_x11_display_init_glx (self, out_visual, out_depth, &glx_error))
- {
- g_clear_error (&egl_error);
- return TRUE;
- }
-
- if (egl_error)
- {
- *error = egl_error;
- g_clear_error (&glx_error);
- }
- else
- *error = glx_error;
-
- return FALSE;
+ if (GDK_DISPLAY_DEBUG_CHECK (display, GL_EGL))
+ return gdk_x11_display_init_egl (self, TRUE, out_visual, out_depth, error);
+ if (GDK_DISPLAY_DEBUG_CHECK (display, GL_GLX))
+ return gdk_x11_display_init_glx (self, out_visual, out_depth, error);
+
+ /* No env vars set, do the regular GL initialization.
+ *
+ * We try EGL first, but are very picky about what we accept.
+ * If that fails, we try to go with GLX instead.
+ * And if that also fails, we try EGL again, but this time accept anything.
+ *
+ * The idea here is that EGL is the preferred method going forward, but GLX is
+ * the tried and tested method that we know works. So if we detect issues with
+ * EGL, we want to avoid using it in favor of GLX.
+ */
+
+ if (gdk_x11_display_init_egl (self, FALSE, out_visual, out_depth, error))
+ return TRUE;
+ g_clear_error (error);
+
+ if (gdk_x11_display_init_glx (self, out_visual, out_depth, error))
+ return TRUE;
+ g_clear_error (error);
+
+ return gdk_x11_display_init_egl (self, TRUE, out_visual, out_depth, error);
}
typedef struct _GdkX11GLContextEGL GdkX11GLContextEGL;
gboolean gdk_x11_display_init_egl (GdkX11Display *display_x11,
+ gboolean force,
Visual **out_visual,
int *out_depth,
GError **error);