Skip to content

Fix compositor alpha-blending with EGL on X11

Robert Mader requested to merge rmader/mesa:egl-transparency-master into main

Why?

Because an application using EGL on the X11 platform currently cannot request alpha-blended config/visuals.

This impacts multiple apps, but most notably everything based on GTK toolkit and Firefox browser. Applications usually resolve situations in three ways:

  • staying on GLX instead of leveraging EGL
  • giving up on alpha-blended behavior under X11
  • querying through old GLX, which is a valid thing to do, but introduces dependency on technology which gets disabled and may be removed at some point

History

The MR started as a rebase of https://gitlab.freedesktop.org/ajax/mesa/-/commits/egl-transparency (which was a rebase and continuation of !2376 (closed) )

How?

This MR does:

  1. implement the EGL_EXT_config_select_group extension to signal that configs are ordered in a non-standard way
  2. move all RGBA configs with magic transparency bit to the second group (effectively puts all these configs at the end of the list)
  3. match config EGL_NATIVE_VISUAL_ID on X11, so clients can request config with "magic bit" for their needs
  4. drop limitation where 32-bit RGB visuals couldn't match against 32-bit RGBA configs

These steps lead to exposing more visuals on the X11 EGL platform again, crucially those with the alpha bit so compositors render apps with transparency.

How to test?

CI

  • VK-GL-CTS is now aware of the extension.
  • Piglit tests aren't focused on exact ordering, so additional entries at the end of the list aren't causing any trouble.

The successful pipeline can be found here.

Locally

  • GDK_BACKEND=x11 gtk4-demo # should pick EGL (open inspector via with ctrl+shift+i -> "Global" -> check value for "GL Version")
  • check that glmark2-es2 picks an opaque visual (on GNOME: open looking glass via alt+f2 -> lg -> "Flags" section -> enable "OPAQUE_REGION" to get a visual indicator)

Risks

As noted in the egl: Match config EGL_NATIVE_VISUAL_ID on X11, the commit introduces new extension change EGL 1.5 specification under X11.

The reason why this shouldn't matter for applications is that the newly added visuals are at the end of the visual lists, so the legacy (everything except GTK, Firefox, and a few aware apps utilizing the magic transparency bit) will pick from the existing list and never get at the end of it. If the application isn't able to find sufficient visuals in the 1st group, it'll fail anyway.

The only known change is reporting more visual configs to the clients.

Result

With this MR it becomes possible to request alpha-blended configs/visuals on EGL. GTK4 apps on X11 (GDK_BACKEND=x11) will prefer EGL over GLX.

eglinfo

Sample eglinfo from recent Mesa on Intel TGL (iris):

+0x51 32  0  8  8  8  8  0  0  0 0 0x72TC      a  y  y  y     win,pb,pix
+0x52 32  0  8  8  8  8 16  0  0 0 0x72TC      a  y  y  y     win,pb,pix
+0x53 32  0  8  8  8  8 24  0  0 0 0x72TC      a  y  y  y     win,pb,pix
+0x54 32  0  8  8  8  8 24  8  0 0 0x72TC      a  y  y  y     win,pb,pix
+0x55 32  0  8  8  8  8  0  0  2 1 0x72TC      a  y  y  y     win,pb,pix
+0x56 32  0  8  8  8  8  0  0  4 1 0x72TC      a  y  y  y     win,pb,pix
+0x57 32  0  8  8  8  8  0  0  8 1 0x72TC      a  y  y  y     win,pb,pix
+0x58 32  0  8  8  8  8  0  0 16 1 0x72TC      a  y  y  y     win,pb,pix
+0x59 32  0  8  8  8  8 16  0  2 1 0x72TC      a  y  y  y     win,pb,pix
+0x5a 32  0  8  8  8  8 16  0  4 1 0x72TC      a  y  y  y     win,pb,pix
+0x5b 32  0  8  8  8  8 16  0  8 1 0x72TC      a  y  y  y     win,pb,pix
+0x5c 32  0  8  8  8  8 16  0 16 1 0x72TC      a  y  y  y     win,pb,pix
+0x5d 32  0  8  8  8  8 24  0  2 1 0x72TC      a  y  y  y     win,pb,pix
+0x5e 32  0  8  8  8  8 24  0  4 1 0x72TC      a  y  y  y     win,pb,pix
+0x5f 32  0  8  8  8  8 24  0  8 1 0x72TC      a  y  y  y     win,pb,pix
+0x60 32  0  8  8  8  8 24  0 16 1 0x72TC      a  y  y  y     win,pb,pix
+0x61 32  0  8  8  8  8 24  8  2 1 0x72TC      a  y  y  y     win,pb,pix
+0x62 32  0  8  8  8  8 24  8  4 1 0x72TC      a  y  y  y     win,pb,pix
+0x63 32  0  8  8  8  8 24  8  8 1 0x72TC      a  y  y  y     win,pb,pix
+0x64 32  0  8  8  8  8 24  8 16 1 0x72TC      a  y  y  y     win,pb,pix

See also:

Edited by David Heidelberg

Merge request reports