Gtk3: GtkGLArea + GLES + EGL/Wayland not rendering anything with IMG PowerVR driver
Steps to reproduce
Run the GLarea demo with GDK_GL=gles gtk3-demo
on a system using the proprietary PowerVR GLES implementation (on a TI AM62x SoC).
Other GtkGL software like gsteamer's gtkglsink are affected as well.
I'm running under Weston/Wayland; I have not tested with X11.
Current behavior
Only a black area is shown.
Expected outcome
A triangle is rendered.
Version information
Gtk 3.24.41 (on Yocto), as well as latest gtk-3-24 branch.
Gtk4 is not affected.
The used driver is https://git.ti.com/cgit/graphics/ti-img-rogue-umlibs/tree/targetfs/am62_linux/lws-generic/release/usr/lib?h=linuxws/scarthgap/k6.6/24.1.6554834, and while based on Mesa, it is mostly proprietary.
(a newer Vulkan driver for the same hardware is now in upstream Mesa, but the closed-source driver is the solution used by TI's AM62x SDK for now until the new driver and its kernel support are more mature; in addition, it is likely that the closed-source driver will remain relevant for older generations of IMG GPUs that are unsupported by the new driver)
Additional information
The issue is caused by the glReadPixels(GL_BGRA)
call at https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/gdkgl.c?ref_type=heads#L703-704, introduced in 261780ac. While it is correct that the colors were wrong on GLES before that commit, the change is made on the incorrect assumption that checking for GL_EXT_texture_format_BGRA8888
is a valid proxy for determining BGRA support of glReadPixels()
, breaking rendering completely in some environments.
See also: https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glReadPixels.xhtml - unless I'm overlooking something, only RGBA support is required, and support for other formats is implementation-specific. I don't know if there are any other extensions that might help here, or if there is a good way to make the expectations of GLES and Cairo match up?