From: Benjamin Otte Date: Wed, 7 Jul 2021 01:00:09 +0000 (+0200) Subject: gl: Require EGL_KHR_surfaceless_context with egl X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~3^2~9^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=15ed1a329e2f4939b239d0845f3200df1cdcdd7e;p=gtk4.git gl: Require EGL_KHR_surfaceless_context with egl The code to create and manage a fake egl surface to bind to is complex and completely untested because everyone seems to support this extension. nvidia and Mesa do support it and according to Mesa devs, adding support in a new driver is rather simple and Mesa drivers gain that feature automatically, so all future drivers shoould have it. --- diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index d431405570..66e8020b28 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -159,7 +159,6 @@ struct _GdkWaylandDisplay guint have_egl_buffer_age : 1; guint have_egl_swap_buffers_with_damage : 1; - guint have_egl_surfaceless_context : 1; }; struct _GdkWaylandDisplayClass diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index 2e83d501f1..de60ebc820 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -469,6 +469,15 @@ gdk_wayland_display_init_gl (GdkDisplay *display, return NULL; } + if (!epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context")) + { + eglTerminate (dpy); + g_set_error_literal (error, GDK_GL_ERROR, + GDK_GL_ERROR_UNSUPPORTED_PROFILE, + _("Surfaceless contexts are not supported on this EGL implementation")); + return NULL; + } + display_wayland->egl_config = get_eglconfig (dpy); if (!display_wayland->egl_config) { @@ -489,9 +498,6 @@ gdk_wayland_display_init_gl (GdkDisplay *display, display_wayland->have_egl_swap_buffers_with_damage = epoxy_has_egl_extension (dpy, "EGL_EXT_swap_buffers_with_damage"); - display_wayland->have_egl_surfaceless_context = - epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context"); - GDK_DISPLAY_NOTE (display, OPENGL, g_message ("EGL API version %d.%d found\n" " - Vendor: %s\n" @@ -572,13 +578,7 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display, if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context))) egl_surface = gdk_wayland_surface_get_egl_surface (surface); else - { - if (display_wayland->have_egl_surfaceless_context) - egl_surface = EGL_NO_SURFACE; - else - egl_surface = gdk_wayland_surface_get_dummy_egl_surface (surface, - display_wayland->egl_config); - } + egl_surface = EGL_NO_SURFACE; if (!eglMakeCurrent (display_wayland->egl_display, egl_surface, egl_surface, context_wayland->egl_context)) diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index 2177cef90d..09f41606f3 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -182,9 +182,6 @@ cairo_surface_t * _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *di struct wl_buffer *_gdk_wayland_shm_surface_get_wl_buffer (cairo_surface_t *surface); gboolean _gdk_wayland_is_shm_surface (cairo_surface_t *surface); -EGLSurface gdk_wayland_surface_get_dummy_egl_surface (GdkSurface *surface, - EGLConfig config); - struct gtk_surface1 * gdk_wayland_surface_get_gtk_surface (GdkSurface *surface); void gdk_wayland_seat_set_global_cursor (GdkSeat *seat, diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 124b810394..404b10b226 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -103,7 +103,6 @@ struct _GdkWaylandSurface struct gtk_surface1 *gtk_surface; struct wl_egl_window *egl_window; - struct wl_egl_window *dummy_egl_window; struct zxdg_exported_v1 *xdg_exported; struct org_kde_kwin_server_decoration *server_decoration; } display_server; @@ -111,7 +110,6 @@ struct _GdkWaylandSurface struct wl_event_queue *event_queue; EGLSurface egl_surface; - EGLSurface dummy_egl_surface; uint32_t reposition_token; uint32_t received_reposition_token; @@ -2901,18 +2899,6 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface) if (impl->display_server.wl_surface) { - if (impl->dummy_egl_surface) - { - eglDestroySurface (display_wayland->egl_display, impl->dummy_egl_surface); - impl->dummy_egl_surface = NULL; - } - - if (impl->display_server.dummy_egl_window) - { - wl_egl_window_destroy (impl->display_server.dummy_egl_window); - impl->display_server.dummy_egl_window = NULL; - } - if (impl->egl_surface) { eglDestroySurface (display_wayland->egl_display, impl->egl_surface); @@ -4325,29 +4311,6 @@ gdk_wayland_surface_get_egl_surface (GdkSurface *surface) return impl->egl_surface; } -EGLSurface -gdk_wayland_surface_get_dummy_egl_surface (GdkSurface *surface, - EGLConfig config) -{ - GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)); - GdkWaylandSurface *impl; - - g_return_val_if_fail (GDK_IS_WAYLAND_SURFACE (surface), NULL); - - impl = GDK_WAYLAND_SURFACE (surface); - - if (impl->dummy_egl_surface == NULL) - { - impl->display_server.dummy_egl_window = - wl_egl_window_create (impl->display_server.wl_surface, 1, 1); - - impl->dummy_egl_surface = - eglCreateWindowSurface (display->egl_display, config, impl->display_server.dummy_egl_window, NULL); - } - - return impl->dummy_egl_surface; -} - struct gtk_surface1 * gdk_wayland_surface_get_gtk_surface (GdkSurface *surface) { diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h index 0bdc4488f0..2a7356f752 100644 --- a/gdk/x11/gdkdisplay-x11.h +++ b/gdk/x11/gdkdisplay-x11.h @@ -164,7 +164,6 @@ struct _GdkX11Display guint has_egl_khr_create_context : 1; guint has_egl_buffer_age : 1; guint has_egl_swap_buffers_with_damage : 1; - guint has_egl_surfaceless_context : 1; }; struct _GdkX11DisplayClass diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c index 280df54b7b..632209a43f 100644 --- a/gdk/x11/gdkglcontext-egl.c +++ b/gdk/x11/gdkglcontext-egl.c @@ -631,6 +631,16 @@ gdk_x11_display_init_egl (GdkX11Display *self, return FALSE; } + if (!epoxy_has_egl_extension (self->egl_display, "EGL_KHR_surfaceless_context")) + { + eglTerminate (dpy); + self->egl_display = NULL; + g_set_error_literal (error, GDK_GL_ERROR, + GDK_GL_ERROR_UNSUPPORTED_PROFILE, + _("Surfaceless contexts are not supported on this EGL implementation")); + return FALSE; + } + if (!gdk_x11_display_create_egl_config (self, force, out_visual, out_depth, error)) { eglTerminate (self->egl_display); @@ -646,8 +656,6 @@ gdk_x11_display_init_egl (GdkX11Display *self, epoxy_has_egl_extension (self->egl_display, "EGL_EXT_buffer_age"); self->has_egl_swap_buffers_with_damage = epoxy_has_egl_extension (self->egl_display, "EGL_EXT_swap_buffers_with_damage"); - self->has_egl_surfaceless_context = - epoxy_has_egl_extension (self->egl_display, "EGL_KHR_surfaceless_context"); GDK_DISPLAY_NOTE (display, OPENGL, g_message ("EGL found\n" @@ -657,15 +665,13 @@ gdk_x11_display_init_egl (GdkX11Display *self, " - Checked extensions:\n" "\t* EGL_KHR_create_context: %s\n" "\t* EGL_EXT_buffer_age: %s\n" - "\t* EGL_EXT_swap_buffers_with_damage: %s\n" - "\t* EGL_KHR_surfaceless_context: %s\n", + "\t* EGL_EXT_swap_buffers_with_damage: %s\n", eglQueryString (self->egl_display, EGL_VERSION), eglQueryString (self->egl_display, EGL_VENDOR), eglQueryString (self->egl_display, EGL_CLIENT_APIS), self->has_egl_khr_create_context ? "yes" : "no", self->has_egl_buffer_age ? "yes" : "no", - self->has_egl_swap_buffers_with_damage ? "yes" : "no", - self->has_egl_surfaceless_context ? "yes" : "no")); + self->has_egl_swap_buffers_with_damage ? "yes" : "no")); return TRUE; } @@ -711,12 +717,7 @@ gdk_x11_gl_context_egl_make_current (GdkDisplay *display, if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context))) egl_surface = gdk_x11_surface_get_egl_surface (surface); else - { - if (display_x11->has_egl_surfaceless_context) - egl_surface = EGL_NO_SURFACE; - else - egl_surface = gdk_x11_surface_get_egl_surface (display_x11->leader_gdk_surface); - } + egl_surface = EGL_NO_SURFACE; GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Making EGL context %p current to surface %p",