[gtk/matthiasc/color-profiles: 126/140] wayland: Use EGL_KHR_no_config_context




commit 44364fbe05cb68e31ebb77c4ad2bddd723e391b7
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 | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 4fc946cfab..ab36c44639 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -58,7 +58,9 @@ 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];
+  EGLConfig config;
   int major, minor, flags;
   gboolean debug_bit, forward_bit, legacy_bit, use_es;
   int i = 0;
@@ -121,10 +123,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 +153,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 +182,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 +617,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]