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

Bug#1031926: bullseye-pu: package gtk+3.0/3.24.24-4+deb11u3



Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian.org@packages.debian.org
Usertags: pu
X-Debbugs-Cc: gtk+3.0@packages.debian.org, Dominique Martinet <dominique.martinet@atmark-techno.com>
Control: affects -1 + src:gtk+3.0

[ Reason ]
User request via #1020937: make it possible to run GTK 3 apps in native
Wayland on some proprietary GLES-only graphics drivers (Raspberry Pi
video core, iMX/Vivante).

[ Impact ]
If not accepted, GTK 3 apps on the affected hardware/driver combination
can only be run if forced to use X11.

[ Tests ]
The proposed change has been in testing and unstable since November
as part of version 3.24.34-4. The version proposed for bullseye is a
straightforward cherry-pick.

For the affected GLES-only graphics drivers, the user requesting the
change has confirmed that a functionally equivalent prerelease package
has the desired effect.

For ordinary "desktop GL" drivers, I used the same prerelease package on
a bullseye/NVIDIA system (with NVIDIA proprietary drivers) for several
weeks without incident, and my partner's bullseye/Intel/Mesa system now
has the proposed package, again without obvious regressions.

[ Risks ]
It's a minimal change, cherry-picked from newer GTK 3 without
modification. The affected code runs whenever GL is initialized for a
window, which should mean that any regressions would be very obvious,
since many (all?) GTK 3 apps use GL.

The version of this change in GTK 4 is much more intrusive and did not
seem suitable for backporting.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
All changes are part of solving #1020937.
diffstat for gtk+3.0-3.24.24 gtk+3.0-3.24.24

 debian/changelog                                                          |   12 +
 debian/patches/gdk_wayland_display_init_gl-use-GLES-API-if-required.patch |   82 ++++++++++
 debian/patches/series                                                     |    1 
 gdk/wayland/gdkglcontext-wayland.c                                        |   12 -
 gdk/wayland/gdkglcontext-wayland.h                                        |    3 
 5 files changed, 105 insertions(+), 5 deletions(-)

diff -Nru gtk+3.0-3.24.24/debian/changelog gtk+3.0-3.24.24/debian/changelog
--- gtk+3.0-3.24.24/debian/changelog	2022-03-10 10:30:09.000000000 +0000
+++ gtk+3.0-3.24.24/debian/changelog	2023-02-24 19:07:01.000000000 +0000
@@ -1,3 +1,15 @@
+gtk+3.0 (3.24.24-4+deb11u3) bullseye; urgency=medium
+
+  * d/p/gdk_wayland_display_init_gl-use-GLES-API-if-required.patch:
+    Apply patch from 3.24.35 to fix Wayland + EGL on GLES-only platforms.
+    Previously, GTK assumed that EGL could use the OpenGL API everywhere,
+    but some proprietary drivers like those for Raspberry Pi and Vivante
+    only support OpenGL ES. Allow use of OpenGL ES to be forced via
+    environment variable GDK_GL=gles.
+    Thanks to Dominique Martinet (Closes: #1020937)
+
+ -- Simon McVittie <smcv@debian.org>  Fri, 24 Feb 2023 19:07:01 +0000
+
 gtk+3.0 (3.24.24-4+deb11u2) bullseye; urgency=medium
 
   [ Jian-Hong Pan ]
diff -Nru gtk+3.0-3.24.24/debian/patches/gdk_wayland_display_init_gl-use-GLES-API-if-required.patch gtk+3.0-3.24.24/debian/patches/gdk_wayland_display_init_gl-use-GLES-API-if-required.patch
--- gtk+3.0-3.24.24/debian/patches/gdk_wayland_display_init_gl-use-GLES-API-if-required.patch	1970-01-01 01:00:00.000000000 +0100
+++ gtk+3.0-3.24.24/debian/patches/gdk_wayland_display_init_gl-use-GLES-API-if-required.patch	2023-02-24 19:07:01.000000000 +0000
@@ -0,0 +1,82 @@
+From: Dominique Martinet <dominique.martinet@atmark-techno.com>
+Date: Wed, 28 Sep 2022 14:18:31 +0900
+Subject: gdk_wayland_display_init_gl: use GLES API if required
+
+gdk_wayland_gl_context_realize properly checks for GLES and uses
+eglBindAPI with the proper API, but before that init is always called
+with regular GL interface which is not implemented for many embedded
+devices.
+
+This was fixed in GTK 4 with commit 482845b02705 ("wayland: Remove
+initial GL API bind"), but that commit cannot easily be applied because
+the current version queries some GL properties during init so we would
+need to backport more for it to be applicable.
+
+This patch takes the minimal approach of initializing GLES context,
+allowing the gtk3 demo OpenGL test (and real applications) to work
+when GDK_GL=gles is set.
+
+Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/3028
+Bug-Debian: https://bugs.debian.org/1020937
+Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5062
+Applied-upstream: 3.24.35, commit:0e5fe45ea20cce074a128911949dbedf4f8265bf
+---
+ gdk/wayland/gdkglcontext-wayland.c | 12 ++++++++----
+ gdk/wayland/gdkglcontext-wayland.h |  3 ++-
+ 2 files changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
+index a221025..296e5e0 100644
+--- a/gdk/wayland/gdkglcontext-wayland.c
++++ b/gdk/wayland/gdkglcontext-wayland.c
+@@ -309,11 +309,13 @@ gdk_wayland_get_display (GdkWaylandDisplay *display_wayland)
+ }
+ 
+ gboolean
+-gdk_wayland_display_init_gl (GdkDisplay *display)
++gdk_wayland_display_init_gl (GdkDisplay *display,
++                             GdkGLContext *share)
+ {
+   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
+   EGLint major, minor;
+   EGLDisplay dpy;
++  gboolean use_es;
+ 
+   if (display_wayland->have_egl)
+     return TRUE;
+@@ -326,8 +328,10 @@ gdk_wayland_display_init_gl (GdkDisplay *display)
+   if (!eglInitialize (dpy, &major, &minor))
+     return FALSE;
+ 
+-  if (!eglBindAPI (EGL_OPENGL_API))
+-    return FALSE;
++  use_es = (_gdk_gl_flags & GDK_GL_GLES) != 0 ||
++           (share != NULL && gdk_gl_context_get_use_es (share));
++  if (!eglBindAPI (use_es ? EGL_OPENGL_ES_API : EGL_OPENGL_API))
++      return FALSE;
+ 
+   display_wayland->egl_display = dpy;
+   display_wayland->egl_major_version = major;
+@@ -461,7 +465,7 @@ gdk_wayland_window_create_gl_context (GdkWindow     *window,
+   GdkWaylandGLContext *context;
+   EGLConfig config;
+ 
+-  if (!gdk_wayland_display_init_gl (display))
++  if (!gdk_wayland_display_init_gl (display, share))
+     {
+       g_set_error_literal (error, GDK_GL_ERROR,
+                            GDK_GL_ERROR_NOT_AVAILABLE,
+diff --git a/gdk/wayland/gdkglcontext-wayland.h b/gdk/wayland/gdkglcontext-wayland.h
+index bd2bb88..88a319e 100644
+--- a/gdk/wayland/gdkglcontext-wayland.h
++++ b/gdk/wayland/gdkglcontext-wayland.h
+@@ -47,7 +47,8 @@ struct _GdkWaylandGLContextClass
+   GdkGLContextClass parent_class;
+ };
+ 
+-gboolean        gdk_wayland_display_init_gl                         (GdkDisplay        *display);
++gboolean        gdk_wayland_display_init_gl                         (GdkDisplay        *display,
++                                                                     GdkGLContext      *share);
+ GdkGLContext *  gdk_wayland_window_create_gl_context                (GdkWindow         *window,
+ 								     gboolean           attach,
+                                                                      GdkGLContext      *share,
diff -Nru gtk+3.0-3.24.24/debian/patches/series gtk+3.0-3.24.24/debian/patches/series
--- gtk+3.0-3.24.24/debian/patches/series	2022-03-10 10:30:09.000000000 +0000
+++ gtk+3.0-3.24.24/debian/patches/series	2023-02-24 19:07:01.000000000 +0000
@@ -26,3 +26,4 @@
 printing-Show-all-Avahi-advertised-printers.patch
 Don-t-try-to-create-local-cups-printers-before-CUPS-2.2.patch
 debian/cups-Use-the-same-name-mangling-as-Debian-11-s-cups-brows.patch
+gdk_wayland_display_init_gl-use-GLES-API-if-required.patch
diff -Nru gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.c gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.c
--- gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.c	2020-12-02 22:21:55.000000000 +0000
+++ gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.c	2023-02-25 11:30:29.000000000 +0000
@@ -309,11 +309,13 @@
 }
 
 gboolean
-gdk_wayland_display_init_gl (GdkDisplay *display)
+gdk_wayland_display_init_gl (GdkDisplay *display,
+                             GdkGLContext *share)
 {
   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
   EGLint major, minor;
   EGLDisplay dpy;
+  gboolean use_es;
 
   if (display_wayland->have_egl)
     return TRUE;
@@ -326,8 +328,10 @@
   if (!eglInitialize (dpy, &major, &minor))
     return FALSE;
 
-  if (!eglBindAPI (EGL_OPENGL_API))
-    return FALSE;
+  use_es = (_gdk_gl_flags & GDK_GL_GLES) != 0 ||
+           (share != NULL && gdk_gl_context_get_use_es (share));
+  if (!eglBindAPI (use_es ? EGL_OPENGL_ES_API : EGL_OPENGL_API))
+      return FALSE;
 
   display_wayland->egl_display = dpy;
   display_wayland->egl_major_version = major;
@@ -461,7 +465,7 @@
   GdkWaylandGLContext *context;
   EGLConfig config;
 
-  if (!gdk_wayland_display_init_gl (display))
+  if (!gdk_wayland_display_init_gl (display, share))
     {
       g_set_error_literal (error, GDK_GL_ERROR,
                            GDK_GL_ERROR_NOT_AVAILABLE,
diff -Nru gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.h gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.h
--- gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.h	2020-12-02 22:21:55.000000000 +0000
+++ gtk+3.0-3.24.24/gdk/wayland/gdkglcontext-wayland.h	2023-02-25 11:30:29.000000000 +0000
@@ -47,7 +47,8 @@
   GdkGLContextClass parent_class;
 };
 
-gboolean        gdk_wayland_display_init_gl                         (GdkDisplay        *display);
+gboolean        gdk_wayland_display_init_gl                         (GdkDisplay        *display,
+                                                                     GdkGLContext      *share);
 GdkGLContext *  gdk_wayland_window_create_gl_context                (GdkWindow         *window,
 								     gboolean           attach,
                                                                      GdkGLContext      *share,

Reply to: