[gtk/win32-gl-improvements] GDK: Force GLES 3.0+ on libANGLE



commit 60e3eb9edc301788ad65cf3ab997de37c8156d02
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jan 19 00:16:11 2022 +0800

    GDK: Force GLES 3.0+ on libANGLE
    
    ...when libANGLE is being used on Windows, by checking for a
    Windows-specific an ANGLE-specific extension.

 gdk/gdkdisplay.c        | 2 ++
 gdk/gdkdisplayprivate.h | 1 +
 gdk/gdkglcontext.c      | 9 +++++++--
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index dddc8b2060..0e935d8176 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1727,6 +1727,8 @@ gdk_display_init_egl (GdkDisplay  *self,
     epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_no_config_context");
   self->have_egl_pixel_format_float =
     epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_pixel_format_float");
+  self->have_egl_win32_libangle =
+    epoxy_has_egl_extension (priv->egl_display, "EGL_ANGLE_d3d_share_handle_client_buffer");
 
   if (self->have_egl_no_config_context)
     priv->egl_config_high_depth = gdk_display_create_egl_config (self,
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index cb80ad3f88..4eb3625d88 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -110,6 +110,7 @@ struct _GdkDisplay
   guint have_egl_swap_buffers_with_damage : 1;
   guint have_egl_no_config_context : 1;
   guint have_egl_pixel_format_float : 1;
+  guint have_egl_win32_libangle : 1;
 };
 
 struct _GdkDisplayClass
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 531344b72e..d5214da2c8 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -1064,18 +1064,23 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
 
-#ifdef G_ENABLE_DEBUG
   display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
+
+#ifdef G_ENABLE_DEBUG
   force_gles = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES);
 #endif
 
+  /* libANGLE on Windows at least requires GLES 3.0+ */
+  if (display->have_egl_win32_libangle)
+    force_gles = TRUE;
+
   /* Default fallback values for uninitialised contexts; we
    * enforce a context version number of 3.2 for desktop GL,
    * and 2.0 for GLES
    */
   if (gdk_gl_context_get_use_es (context) || force_gles)
     {
-      default_major = 2;
+      default_major = display->have_egl_win32_libangle ? 3 : 2;
       default_minor = 0;
     }
   else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]