[gtk/matthiasc/color-profiles: 17/32] wayland: Use EGL_KHR_no_config_context
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profiles: 17/32] wayland: Use EGL_KHR_no_config_context
- Date: Sun, 3 Oct 2021 20:23:25 +0000 (UTC)
commit 656b9b79c27ab51fb41590b13ad697d6bedfa5d3
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 1 20:18:18 2021 -0400
wayland: Use EGL_KHR_no_config_context
Require the EGL_KHR_no_config_context extension and
create a configless GL context that can be used with
any surface. This decouples context creation from
fbconfig setting, and will let us change fbconfigs
of surfaces on the fly, in the future.
gdk/wayland/gdkglcontext-wayland.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 4fc946cfab..f47bc0eb69 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -58,6 +58,7 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
GdkGLContext *share = gdk_display_get_gl_context (display);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLContext ctx;
+ EGLContext shared;
EGLint context_attribs[N_EGL_ATTRS];
int major, minor, flags;
gboolean debug_bit, forward_bit, legacy_bit, use_es;
@@ -121,10 +122,14 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
legacy_bit ? "yes" : "no",
use_es ? "yes" : "no"));
+ if (share != NULL)
+ shared = GDK_WAYLAND_GL_CONTEXT (share)->egl_context;
+ else
+ shared = EGL_NO_CONTEXT;
+
ctx = eglCreateContext (display_wayland->egl_display,
- display_wayland->egl_config,
- share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
- : EGL_NO_CONTEXT,
+ EGL_NO_CONFIG_KHR,
+ shared,
context_attribs);
/* If context creation failed without the ES bit, let's try again with it */
@@ -147,10 +152,10 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
GDK_DISPLAY_NOTE (display, OPENGL,
g_message ("eglCreateContext failed, switching to OpenGLĀ ES"));
+
ctx = eglCreateContext (display_wayland->egl_display,
- display_wayland->egl_config,
- share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
- : EGL_NO_CONTEXT,
+ EGL_NO_CONFIG_KHR,
+ shared,
context_attribs);
}
@@ -176,10 +181,10 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
GDK_DISPLAY_NOTE (display, OPENGL,
g_message ("eglCreateContext failed, switching to legacy"));
+
ctx = eglCreateContext (display_wayland->egl_display,
- display_wayland->egl_config,
- share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
- : EGL_NO_CONTEXT,
+ EGL_NO_CONFIG_KHR,
+ shared,
context_attribs);
}
@@ -611,6 +616,15 @@ gdk_wayland_display_init_gl (GdkDisplay *display,
return NULL;
}
+ if (!epoxy_has_egl_extension (dpy, "EGL_KHR_no_config_context"))
+ {
+ eglTerminate (dpy);
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_UNSUPPORTED_PROFILE,
+ _("Configless contexts are not supported on this EGL implementation"));
+ return NULL;
+ }
+
start_time2 = GDK_PROFILER_CURRENT_TIME;
get_eglconfig (dpy, &display_wayland->egl_config_sdr, &display_wayland->egl_config_hdr);
gdk_profiler_end_mark (start_time2, "get_eglconfig", NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]