From 3e9d858af191bbfaec06bd71b44726031dc0d0cc Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 17 Jan 2022 14:40:23 +0800 Subject: [PATCH 1/7] gskrenderer.c: Use GL renderer on Windows by default Since now we have the shaders working on Windows under GLES with libANGLE using a 3.0+ context, drop the check to fall back to the Cairo renderer when GLES is being used. --- gsk/gskrenderer.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c index b782cfd493..03aa87f512 100644 --- a/gsk/gskrenderer.c +++ b/gsk/gskrenderer.c @@ -597,14 +597,7 @@ get_renderer_for_backend (GdkSurface *surface) #endif #ifdef GDK_WINDOWING_WIN32 if (GDK_IS_WIN32_SURFACE (surface)) - /* remove check for OpenGL/ES when OpenGL/ES 2.0 shader is ready */ - { - GdkDisplay *display = gdk_surface_get_display (surface); - - if (!(GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) || - GDK_WIN32_DISPLAY (display)->running_on_arm64)) - return GSK_TYPE_GL_RENDERER; - } + return GSK_TYPE_GL_RENDERER; #endif return G_TYPE_INVALID; From 598c7d9cf4f1771cf0888d0b275652115c2cc806 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 17 Jan 2022 16:11:27 +0800 Subject: [PATCH 2/7] GDK/Win32: Try to fix initializing GLES contexts We are now able to create EGL contexts properly on Windows, but not GLES. This tries to fix things by doing the following: * Record the GL context type in a more proper fashion, using an Enum. This makes things a bit cleaner. * Force GLES-3.0+ contexts, since libANGLE requires this to properly work with the shaders-its 2.0 contexts don't work well with our shaders. --- gdk/win32/gdkdisplay-win32.c | 38 +++++++++++++++++++++++------- gdk/win32/gdkdisplay-win32.h | 9 ++++++- gdk/win32/gdkglcontext-win32-wgl.c | 9 ++++--- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 675e1af5e2..14de69ff7b 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1181,6 +1181,7 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display, { gboolean result = FALSE; GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); + GdkWin32GLType gl_type = GDK_WIN32_GL_TYPE_NONE; if (display_win32->dummy_context_wgl.hdc == NULL) display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd); @@ -1196,20 +1197,29 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display, * usage against libANGLE EGL. EGL is used more as a compatibility layer * on Windows rather than being a native citizen on Windows */ - if (_gdk_debug_flags & GDK_DEBUG_GL_EGL) - result = gdk_display_init_egl (display, - EGL_PLATFORM_ANGLE_ANGLE, - display_win32->dummy_context_wgl.hdc, - FALSE, - error); + if (GDK_DEBUG_CHECK (GL_EGL) || GDK_DEBUG_CHECK (GL_GLES)) + { + result = gdk_display_init_egl (display, + EGL_PLATFORM_ANGLE_ANGLE, + display_win32->dummy_context_wgl.hdc, + FALSE, + error); + + if (result) + gl_type = GDK_WIN32_GL_TYPE_EGL; + } #endif if (!result) { g_clear_error (error); result = gdk_win32_display_init_wgl (display, error); + + if (result) + gl_type = GDK_WIN32_GL_TYPE_WGL; } + #ifdef HAVE_EGL if (!result) { @@ -1219,9 +1229,13 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display, display_win32->dummy_context_wgl.hdc, TRUE, error); + + if (result) + gl_type = GDK_WIN32_GL_TYPE_EGL; } #endif + display_win32->gl_type = gl_type; return result; } @@ -1235,11 +1249,17 @@ gdk_win32_display_init_gl (GdkDisplay *display, if (!gdk_win32_display_init_gl_backend (display, error)) return NULL; - if (display_win32->wgl_pixel_format != 0) + if (display_win32->gl_type == GDK_WIN32_GL_TYPE_WGL) gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, "display", display, NULL); #ifdef HAVE_EGL - else if (gdk_display_get_egl_display (display)) - gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL); + else if (display_win32->gl_type == GDK_WIN32_GL_TYPE_EGL) + { + gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL); + + /* We want to use a GLES 3.0+ context */ + gdk_gl_context_set_allowed_apis (gl_context, GDK_GL_API_GLES); + gdk_gl_context_set_required_version (gl_context, 3, 0); + } #endif g_return_val_if_fail (gl_context != NULL, NULL); diff --git a/gdk/win32/gdkdisplay-win32.h b/gdk/win32/gdkdisplay-win32.h index 3b746bbe1b..88757e03e0 100644 --- a/gdk/win32/gdkdisplay-win32.h +++ b/gdk/win32/gdkdisplay-win32.h @@ -105,6 +105,13 @@ typedef enum { GDK_WIN32_TABLET_INPUT_API_WINPOINTER } GdkWin32TabletInputAPI; +typedef enum +{ + GDK_WIN32_GL_TYPE_NONE, + GDK_WIN32_GL_TYPE_WGL, + GDK_WIN32_GL_TYPE_EGL, +} GdkWin32GLType; + typedef struct { HDC hdc; @@ -125,7 +132,7 @@ struct _GdkWin32Display /* WGL/OpenGL Items */ GdkWin32GLDummyContextWGL dummy_context_wgl; - int wgl_pixel_format; + GdkWin32GLType gl_type; guint gl_version; GListModel *monitors; diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c index d443a2c7ff..41aed57d1f 100644 --- a/gdk/win32/gdkglcontext-win32-wgl.c +++ b/gdk/win32/gdkglcontext-win32-wgl.c @@ -258,7 +258,7 @@ gdk_win32_display_init_wgl (GdkDisplay *display, if (!gdk_gl_backend_can_be_used (GDK_GL_WGL, error)) return FALSE; - if (display_win32->wgl_pixel_format != 0) + if (display_win32->gl_type == GDK_WIN32_GL_TYPE_WGL) return TRUE; /* acquire and cache dummy Window (HWND & HDC) and @@ -299,8 +299,6 @@ gdk_win32_display_init_wgl (GdkDisplay *display, } } - display_win32->wgl_pixel_format = best_idx; - display_win32->hasWglARBCreateContext = epoxy_has_wgl_extension (hdc, "WGL_ARB_create_context"); display_win32->hasWglEXTSwapControl = @@ -728,10 +726,11 @@ gdk_win32_display_get_wgl_version (GdkDisplay *display, if (!GDK_IS_WIN32_DISPLAY (display)) return FALSE; - display_win32 = GDK_WIN32_DISPLAY (display); - if (display_win32->wgl_pixel_format == 0) + if (!gdk_win32_display_init_wgl (display, NULL)) return FALSE; + display_win32 = GDK_WIN32_DISPLAY (display); + if (major != NULL) *major = display_win32->gl_version / 10; if (minor != NULL) From b85aa10700a3af7aa4e7c7c0cc5a9c02fb36ca35 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 17 Jan 2022 17:27:10 +0800 Subject: [PATCH 3/7] gdkglcontext.c: Ensure EGL contexts are in-sync with shared context 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index 3c5e4ffdb1..531344b72e 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -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) || From 38c17c1f796a394d0cf559712ac7a78409c4ea8b Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 17 Jan 2022 18:14:30 +0800 Subject: [PATCH 4/7] gdkglcontext-win32-wgl.c: Cleanup GL context creation Instead of first trying to explicitly ask for a WGL 4.1 context, ask for the WGL context version that matches what is reported via epoxy_gl_version(), so that we get the maximum WGL version that is supported by the graphics drivers, and make sure any WGL contexts that are shared with this (initial) WGL context are created likewise. We can try to do a default-bog-standard 3.2 core WGL context creation if the need arises, but let's leave that alone for now. --- gdk/win32/gdkglcontext-win32-wgl.c | 54 ++++++++++++++---------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c index 41aed57d1f..9a90ccffc6 100644 --- a/gdk/win32/gdkglcontext-win32-wgl.c +++ b/gdk/win32/gdkglcontext-win32-wgl.c @@ -430,33 +430,13 @@ create_wgl_context (HDC hdc, goto gl_fail; } - /* - * We need a Core GL 4.1 context in order to use the GL support in - * the GStreamer media widget backend, but wglCreateContextAttribsARB() - * may only give us the GL context version that we ask for here, and - * nothing more. So, if we are asking for a pre-GL 4.1 context, - * try to ask for a 4.1 context explicitly first. If that is not supported, - * then we fall back to whatever version that we were asking for (or, even a - * legacy context if that fails), at a price of not able to have GL support - * for the media GStreamer backend. - */ - if (major < 4 || (major == 4 && minor < 1)) - hglrc = create_wgl_context_with_attribs (hdc, - hglrc_base, - share, - flags, - 4, - 1, - is_legacy); - - if (hglrc == NULL) - hglrc = create_wgl_context_with_attribs (hdc, - hglrc_base, - share, - flags, - major, - minor, - is_legacy); + hglrc = create_wgl_context_with_attribs (hdc, + hglrc_base, + share, + flags, + major, + minor, + is_legacy); /* return the legacy context we have if it could be setup properly, in case the 3.0+ context creation failed */ if (hglrc == NULL) @@ -562,10 +542,27 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context, if (!gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, error)) return 0; - gdk_gl_context_get_required_version (context, &major, &minor); debug_bit = gdk_gl_context_get_debug_enabled (context); compat_bit = gdk_gl_context_get_forward_compatible (context); + /* + * We may need a Core GL 4.1+ context in order to use the GL support in + * the GStreamer media widget backend (such as on Intel drivers), but + * wglCreateContextAttribsARB() may only give us the GL context version + * that we ask for here, and nothing more. So, improve things here by + * asking for the GL version that is reported to us via epoxy_gl_version(), + * rather than the default GL core 3.2 context. Save this up in our + * GdkGLContext so that subsequent contexts that are shared with this + * context are created likewise too. + */ + if (share != NULL) + gdk_gl_context_get_required_version (share, &major, &minor); + else + { + major = display_win32->gl_version / 10; + minor = display_win32->gl_version % 10; + } + if (surface != NULL) hdc = GDK_WIN32_SURFACE (surface)->hdc; else @@ -632,6 +629,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context, /* Ensure that any other context is created with a legacy bit set */ gdk_gl_context_set_is_legacy (context, legacy_bit); + gdk_gl_context_set_required_version (context, major, minor); return GDK_GL_API_GL; } From 6f2848c311fd06f8bf33bb755bc1cf665ffe0bc3 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 18 Jan 2022 10:41:28 +0800 Subject: [PATCH 5/7] Cleanup "GDK/Win32: Try to fix initializing GLES contexts" As per Benjamin's suggestions, cleanup the previous implementation on initializing the GLES context on Windows, so that we use more items that are already in GDK proper and integrate two functions into one. --- gdk/win32/gdkdisplay-win32.c | 91 +++++++++++++----------------- gdk/win32/gdkdisplay-win32.h | 8 --- gdk/win32/gdkglcontext-win32-wgl.c | 5 +- 3 files changed, 40 insertions(+), 64 deletions(-) diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 14de69ff7b..aee962bd80 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1175,17 +1175,19 @@ gdk_win32_display_get_setting (GdkDisplay *display, #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 #endif -static gboolean -gdk_win32_display_init_gl_backend (GdkDisplay *display, - GError **error) +static GdkGLContext * +gdk_win32_display_init_gl (GdkDisplay *display, + GError **error) { - gboolean result = FALSE; GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); - GdkWin32GLType gl_type = GDK_WIN32_GL_TYPE_NONE; + HDC init_gl_hdc = NULL; + gboolean is_egl = FALSE; if (display_win32->dummy_context_wgl.hdc == NULL) display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd); + init_gl_hdc = display_win32->dummy_context_wgl.hdc; + /* * No env vars set, do the regular GL initialization, first WGL and then EGL, * as WGL is the more tried-and-tested configuration. @@ -1193,78 +1195,63 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display, #ifdef HAVE_EGL /* - * Disable defaulting to EGL for now, since shaders need to be fixed for - * usage against libANGLE EGL. EGL is used more as a compatibility layer + * Disable defaulting to EGL as EGL is used more as a compatibility layer * on Windows rather than being a native citizen on Windows */ if (GDK_DEBUG_CHECK (GL_EGL) || GDK_DEBUG_CHECK (GL_GLES)) { - result = gdk_display_init_egl (display, - EGL_PLATFORM_ANGLE_ANGLE, - display_win32->dummy_context_wgl.hdc, - FALSE, - error); - - if (result) - gl_type = GDK_WIN32_GL_TYPE_EGL; + if (gdk_display_init_egl (display, + EGL_PLATFORM_ANGLE_ANGLE, + init_gl_hdc, + FALSE, + error)) + is_egl = TRUE; } #endif - if (!result) + if (!is_egl) { g_clear_error (error); - result = gdk_win32_display_init_wgl (display, error); - if (result) - gl_type = GDK_WIN32_GL_TYPE_WGL; + if (gdk_win32_display_init_wgl (display, error)) + { + gdk_gl_backend_use (GDK_GL_WGL); + return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, + "display", display, + NULL); + } } - #ifdef HAVE_EGL - if (!result) + if (!is_egl) { g_clear_error (error); - result = gdk_display_init_egl (display, - EGL_PLATFORM_ANGLE_ANGLE, - display_win32->dummy_context_wgl.hdc, - TRUE, - error); - if (result) - gl_type = GDK_WIN32_GL_TYPE_EGL; + if (gdk_display_init_egl (display, + EGL_PLATFORM_ANGLE_ANGLE, + init_gl_hdc, + TRUE, + error)) + is_egl = TRUE; } -#endif - display_win32->gl_type = gl_type; - return result; -} - -static GdkGLContext * -gdk_win32_display_init_gl (GdkDisplay *display, - GError **error) -{ - GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); - GdkGLContext *gl_context = NULL; - - if (!gdk_win32_display_init_gl_backend (display, error)) - return NULL; - - if (display_win32->gl_type == GDK_WIN32_GL_TYPE_WGL) - gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, "display", display, NULL); -#ifdef HAVE_EGL - else if (display_win32->gl_type == GDK_WIN32_GL_TYPE_EGL) + if (is_egl) { - gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL); + GdkGLContext *gl_context = NULL; - /* We want to use a GLES 3.0+ context */ + /* We want to use a GLES 3.0+ context for libANGLE GLES */ + gdk_gl_backend_use (GDK_GL_EGL); + gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, + "display", display, + NULL); gdk_gl_context_set_allowed_apis (gl_context, GDK_GL_API_GLES); gdk_gl_context_set_required_version (gl_context, 3, 0); + + return gl_context; } #endif - g_return_val_if_fail (gl_context != NULL, NULL); - - return gl_context; + g_return_val_if_reached (NULL); } /** diff --git a/gdk/win32/gdkdisplay-win32.h b/gdk/win32/gdkdisplay-win32.h index 88757e03e0..19f11e5f9f 100644 --- a/gdk/win32/gdkdisplay-win32.h +++ b/gdk/win32/gdkdisplay-win32.h @@ -105,13 +105,6 @@ typedef enum { GDK_WIN32_TABLET_INPUT_API_WINPOINTER } GdkWin32TabletInputAPI; -typedef enum -{ - GDK_WIN32_GL_TYPE_NONE, - GDK_WIN32_GL_TYPE_WGL, - GDK_WIN32_GL_TYPE_EGL, -} GdkWin32GLType; - typedef struct { HDC hdc; @@ -132,7 +125,6 @@ struct _GdkWin32Display /* WGL/OpenGL Items */ GdkWin32GLDummyContextWGL dummy_context_wgl; - GdkWin32GLType gl_type; guint gl_version; GListModel *monitors; diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c index 9a90ccffc6..231f2a6a01 100644 --- a/gdk/win32/gdkglcontext-win32-wgl.c +++ b/gdk/win32/gdkglcontext-win32-wgl.c @@ -258,9 +258,6 @@ gdk_win32_display_init_wgl (GdkDisplay *display, if (!gdk_gl_backend_can_be_used (GDK_GL_WGL, error)) return FALSE; - if (display_win32->gl_type == GDK_WIN32_GL_TYPE_WGL) - return TRUE; - /* acquire and cache dummy Window (HWND & HDC) and * dummy GL Context, it is used to query functions * and used for other stuff as well @@ -724,7 +721,7 @@ gdk_win32_display_get_wgl_version (GdkDisplay *display, if (!GDK_IS_WIN32_DISPLAY (display)) return FALSE; - if (!gdk_win32_display_init_wgl (display, NULL)) + if (!gdk_gl_backend_can_be_used (GDK_GL_WGL, NULL)) return FALSE; display_win32 = GDK_WIN32_DISPLAY (display); From 43839898b3e9a4daa96981e2e897ce24ad9b2061 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 19 Jan 2022 00:16:11 +0800 Subject: [PATCH 6/7] 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 | 11 +++++++---- 3 files changed, 10 insertions(+), 4 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..d1bc7c57c2 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -1056,26 +1056,29 @@ gdk_gl_context_get_required_version (GdkGLContext *context, { GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); gboolean force_gles = FALSE; -#ifdef G_ENABLE_DEBUG GdkDisplay *display; -#endif int default_major, default_minor; int maj, min; 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 From 0fe37d18282c436d736280a13bfa62538bd6ace6 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 19 Jan 2022 00:18:07 +0800 Subject: [PATCH 7/7] gdkdisplay-win32.c: Clean up GL initialization further --- gdk/win32/gdkdisplay-win32.c | 68 ++++++++++++++---------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index aee962bd80..a544bf3827 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1181,7 +1181,6 @@ gdk_win32_display_init_gl (GdkDisplay *display, { GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display); HDC init_gl_hdc = NULL; - gboolean is_egl = FALSE; if (display_win32->dummy_context_wgl.hdc == NULL) display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd); @@ -1205,53 +1204,40 @@ gdk_win32_display_init_gl (GdkDisplay *display, init_gl_hdc, FALSE, error)) - is_egl = TRUE; - } -#endif - - if (!is_egl) - { - g_clear_error (error); - - if (gdk_win32_display_init_wgl (display, error)) { - gdk_gl_backend_use (GDK_GL_WGL); - return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, + return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL); } - } - -#ifdef HAVE_EGL - if (!is_egl) - { - g_clear_error (error); - - if (gdk_display_init_egl (display, - EGL_PLATFORM_ANGLE_ANGLE, - init_gl_hdc, - TRUE, - error)) - is_egl = TRUE; - } - - if (is_egl) - { - GdkGLContext *gl_context = NULL; - - /* We want to use a GLES 3.0+ context for libANGLE GLES */ - gdk_gl_backend_use (GDK_GL_EGL); - gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, - "display", display, - NULL); - gdk_gl_context_set_allowed_apis (gl_context, GDK_GL_API_GLES); - gdk_gl_context_set_required_version (gl_context, 3, 0); - - return gl_context; + else + g_clear_error (error); } #endif - g_return_val_if_reached (NULL); + if (gdk_win32_display_init_wgl (display, error)) + { + return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, + "display", display, + NULL); + } + +#ifdef HAVE_EGL + g_clear_error (error); + + if (gdk_display_init_egl (display, + EGL_PLATFORM_ANGLE_ANGLE, + init_gl_hdc, + TRUE, + error)) + { + return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, + "display", display, + NULL); + + } +#endif + + return NULL; } /**