gdkglcontext.c: Ensure EGL contexts are in-sync with shared context
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 17 Jan 2022 09:27:10 +0000 (17:27 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 19 Jan 2022 03:56:32 +0000 (11:56 +0800)
The EGL context that we are actually creating must have matching OpenGL/ES
versions and allowed GL API set with the previously-created EGL context
that will be shared with it so that they can interoperate together, if
applicable.

This will fix the situation by making sure that we request for the
OpenGL/ES version and OpenGL API set that match with what we have in our shared
EGL context.  Otherwise, the newly-created EGL context assumed a OpenGL/ES 2.0
context that supported desktop OpenGL, which may not be what we wanted, such as
in the case of libANGLE.

gdk/gdkglcontext.c

index 3c5e4ffdb103923f57aabbdd1eada5dc7b43208c..531344b72e5e57bf05a71057bff17097ac97be9f 100644 (file)
@@ -278,7 +278,15 @@ gdk_gl_context_real_realize (GdkGLContext  *context,
       int i = 0;
       G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
 
-      gdk_gl_context_get_required_version (context, &major, &minor);
+      if (share != NULL)
+        {
+          gdk_gl_context_get_required_version (share, &major, &minor);
+          gdk_gl_context_set_allowed_apis (context,
+                                           gdk_gl_context_get_allowed_apis (share));
+        }
+      else
+        gdk_gl_context_get_required_version (context, &major, &minor);
+
       debug_bit = gdk_gl_context_get_debug_enabled (context);
       forward_bit = gdk_gl_context_get_forward_compatible (context);
       legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ||