From: Benjamin Otte Date: Sun, 6 Jun 2021 15:07:05 +0000 (+0200) Subject: x11: Initialize GL at startup X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~3^2~9^2~46 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0fce30070f84c0cfa8daf87634bba39379def23b;p=gtk4.git x11: Initialize GL at startup We need to initialize GL to select the Visual we are going to use for all our Windows. As the Visual needs to be known before we know if we are even gonna use GL later, we can't avoid initializing it. Note that this previously happened, too. It was just hidden behind the GdkScreen initialization. --- diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 707abe491f..5eaf09ec6b 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1335,6 +1335,25 @@ set_sm_client_id (GdkDisplay *display, gdk_x11_get_xatom_by_name_for_display (display, "SM_CLIENT_ID")); } +static void +gdk_x11_display_init_gl (GdkX11Display *self) +{ + GdkDisplay *display G_GNUC_UNUSED = GDK_DISPLAY (self); + + if (GDK_DISPLAY_DEBUG_CHECK (display, GL_DISABLE)) + return; + + if (!GDK_DISPLAY_DEBUG_CHECK (display, GL_GLX)) + { + /* We favour EGL */ + if (gdk_x11_screen_init_egl (self->screen)) + return; + } + + if (gdk_x11_screen_init_glx (self->screen)) + return; +} + /** * gdk_x11_display_open: * @display_name: (nullable): name of the X display. @@ -1406,6 +1425,7 @@ gdk_x11_display_open (const char *display_name) * as we care about GLX details such as alpha/depth/stencil depth, * stereo and double buffering */ + gdk_x11_display_init_gl (display_x11); gdk_x11_screen_update_visuals_for_glx (display_x11->screen); if (display_x11->screen->rgba_visual) diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c index cb87cf8425..b97a77464a 100644 --- a/gdk/x11/gdkglcontext-x11.c +++ b/gdk/x11/gdkglcontext-x11.c @@ -54,27 +54,6 @@ gdk_x11_gl_context_init (GdkX11GLContext *self) self->do_frame_sync = TRUE; } -gboolean -gdk_x11_screen_init_gl (GdkX11Screen *screen) -{ - GdkDisplay *display G_GNUC_UNUSED = GDK_SCREEN_DISPLAY (screen); - - if (GDK_DISPLAY_DEBUG_CHECK (display, GL_DISABLE)) - return FALSE; - - if (!GDK_DISPLAY_DEBUG_CHECK (display, GL_GLX)) - { - /* We favour EGL */ - if (gdk_x11_screen_init_egl (screen)) - return TRUE; - } - - if (gdk_x11_screen_init_glx (screen)) - return TRUE; - - return FALSE; -} - GdkGLContext * gdk_x11_surface_create_gl_context (GdkSurface *surface, gboolean attached, @@ -86,8 +65,13 @@ gdk_x11_surface_create_gl_context (GdkSurface *surface, GdkDisplay *display; display = gdk_surface_get_display (surface); + display_x11 = GDK_X11_DISPLAY (display); - if (!gdk_x11_screen_init_gl (GDK_SURFACE_SCREEN (surface))) + if (display_x11->have_egl) + context = gdk_x11_gl_context_egl_new (surface, attached, share, error); + else if (display_x11->have_glx) + context = gdk_x11_gl_context_glx_new (surface, attached, share, error); + else { g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE, @@ -95,14 +79,6 @@ gdk_x11_surface_create_gl_context (GdkSurface *surface, return NULL; } - display_x11 = GDK_X11_DISPLAY (display); - if (display_x11->have_egl) - context = gdk_x11_gl_context_egl_new (surface, attached, share, error); - else if (display_x11->have_glx) - context = gdk_x11_gl_context_glx_new (surface, attached, share, error); - else - g_assert_not_reached (); - if (context == NULL) return NULL; diff --git a/gdk/x11/gdkglcontext-x11.h b/gdk/x11/gdkglcontext-x11.h index dc6048b3fe..991c361cc5 100644 --- a/gdk/x11/gdkglcontext-x11.h +++ b/gdk/x11/gdkglcontext-x11.h @@ -60,8 +60,6 @@ struct _GdkX11GLContextClass void (* bind_for_frame_fence) (GdkX11GLContext *self); }; -gboolean gdk_x11_screen_init_gl (GdkX11Screen *screen); - GdkGLContext * gdk_x11_surface_create_gl_context (GdkSurface *window, gboolean attached, GdkGLContext *share,