Bug 67676 - Transparent windows no longer work
Summary: Transparent windows no longer work
Status: RESOLVED MOVED
Alias: None
Product: Mesa
Classification: Unclassified
Component: EGL (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Hal Gentz
QA Contact:
URL:
Whiteboard:
Keywords:
: 99237 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-08-02 15:40 UTC by Derek Foreman
Modified: 2019-09-18 18:06 UTC (History)
10 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Proposed patch (2.95 KB, patch)
2014-02-10 14:26 UTC, Sjoerd Simons
Details | Splinter Review
Updated patch (3.00 KB, patch)
2014-02-18 09:39 UTC, Sjoerd Simons
Details | Splinter Review
EGL_MESA_transparent_alpha draft (2.60 KB, text/plain)
2015-01-06 18:13 UTC, Jonny Lamb
Details
EGL_MESA_transparent_alpha draft 2 (2.79 KB, text/plain)
2015-02-16 13:29 UTC, Jonny Lamb
Details
third draft (2.95 KB, text/plain)
2015-02-17 11:35 UTC, Jonny Lamb
Details
version three (2.96 KB, text/plain)
2015-02-17 11:56 UTC, Jonny Lamb
Details
version four (3.19 KB, text/plain)
2015-02-23 10:36 UTC, Jonny Lamb
Details
A patch that fixes transparency. (10.44 KB, patch)
2019-06-21 23:19 UTC, Hal Gentz
Details | Splinter Review
A patch that puts RGBA visuals in the second config selection group. (Depends on first patch) (1.66 KB, patch)
2019-06-21 23:20 UTC, Hal Gentz
Details | Splinter Review
EGL_MESA_config_select_group (2.64 KB, text/plain)
2019-06-21 23:20 UTC, Hal Gentz
Details
EGL_MESA_config_select_group v2 (2.68 KB, text/plain)
2019-07-11 07:15 UTC, Hal Gentz
Details

Description Derek Foreman 2013-08-02 15:40:45 UTC
As of:
https://bugs.freedesktop.org/show_bug.cgi?id=59783
and
http://cgit.freedesktop.org/mesa/mesa/commit/?id=049f343e8ace0057ab5f8218a5c130632964ef71

My application can no longer request a visual that the compositor renders translucently.

I see that this was done intentionally, but there really are applications that ask for that visual on purpose and need it to function as intended...
Comment 1 Chad Versace 2013-08-05 17:19:20 UTC
Sad sad sad :(

EGL provides no mechanism by which the application can request a transparent window. We need to define an EGL extension for that, tentatively named EGL_MESA_transparent_alpha.

Without such an extension, Mesa needs to give transparent windows to everyone, or transparent windows to no one.

The extension is on my todo list, but it's nearer to the bottom than the top of the list. If you'd like to pick the task up, I can explain how to proceed.
Comment 2 Pekka Paalanen 2013-12-12 13:38:55 UTC
Colleagues are hitting this bug, so I started wondering...

EGLConfigs carry the X11 Visual id, right? Would it not be possible to add more EGLConfigs, otherwise equivalent to the current ARGB8888 configs, but having the magic alpha visual? These would be sorted after the opaque ARGB8888 configs, so they hopefully would not be picked up by default. Then apps, who really want the magic alpha, could manually look for the right native visual id in the configs to get it.

It would be an X11-only solution/hack, but is there something fundamentally wrong with it?
Comment 3 Chad Versace 2013-12-19 18:36:41 UTC
I don't think there is anything fundamentally wrong with your proposed X11-specific hack.

But, I think it's unwise to implement the hack. The amount of code and hackery needed---the implementation code in Mesa as well as the client code in the X11 app to use Mesa's hack---I predict will be more convoluted and fragile than the analogous code for a new extension, EGL_MESA_transparent_alpha, that adds a new value for attribute EGL_TRANSPARENT_TYPE. And, unlike an X11-specific hack, this extension would also apply to Wayland.
Comment 4 Daniel Stone 2014-02-07 16:49:47 UTC
(In reply to comment #1)
> Without such an extension, Mesa needs to give transparent windows to
> everyone, or transparent windows to no one.

Maybe I'm just being dense here; surely there's something I'm missing. The ALPHA_SIZE test in ChooseConfig checks for the lowest value that's greater than or equal to what was specified, and the default is zero. So people using ChooseConfig will get non-alpha RGB configs preferred, unless they either hunt for something using a 32bpp visual, or explicitly requested alpha size.

If they've requested alpha explicitly, you can be fairly sure they're going to want to use it ...

Can this at least be hidden behind an EGL_CONFORMANT_IF_NOT_PERHAPS_QUITE_AS_PERFORMANT variable or something? Removing the possibility to ever render destination alpha is pretty vicious, and breaks more than you'd expect (think UIs, not games).

Is the idea behind this hack just to improve performance for people naïvely looking to match an EGL config to the X11 visual it's suggested they use?
Comment 5 Eric Anholt 2014-02-07 19:26:01 UTC
Daniel: the problem is that normal apps use the alpha, but they don't fill it with values that should be used to blend window contents over other windows.  So you must not return the rgba visual when people aren't really looking for the rgba visual.  Nothing in the change was about performance.

We should certainly be exposing EGLConfigs that match up to the rgba visual, though, so you can find it when you try.
Comment 6 Sjoerd Simons 2014-02-10 14:26:46 UTC
Created attachment 93777 [details] [review]
Proposed patch


egl_dri2: Allow both 24 and 32 bit X visuals for RGBA configs
    
When using RGBA EGLConfigs allow both RGB and RGBA X visuals, such that
application can decide whether they want to use RGBA (and have the
compositor blend their windows).
    
On my system with this change EGLConfigs with a 24 bit visual comes up
first, as such applications blindly picking the first EGLConfig will
still get an RGB X visual.


Note that with this patch dri2_match_config only considers EGLConfigs to match iff their NativeVisualID also matches. Which is imho correct for X11, but i'm not sure if this is a valid thing to compare on other display systems.
Comment 7 Sjoerd Simons 2014-02-18 09:39:52 UTC
Created attachment 94274 [details] [review]
Updated patch

From comments by daniels, check for EGL_DONT_CARE in the matching criteria for consistency
Comment 8 Jonny Lamb 2015-01-06 18:13:56 UTC
Created attachment 111864 [details]
EGL_MESA_transparent_alpha draft

Here is my initial draft for this extension. It's already been fixed after a round of comments from Daniel and Pekka.

Anywhere else I should sent it for comments?
Comment 9 Daniel Stone 2015-01-20 16:37:40 UTC
Eric, Chad, any thoughts on the above?

Jonny, did you have the Mesa implementation as well?
Comment 10 Chad Versace 2015-01-30 22:08:39 UTC
The proposed extension looks like the right approach to me.

Regarding issue #1, I weakly prefer that it be illegal to specify EGL_TRANSPARENT_ALPHA for non-window surfaces. I like to emit errors when the user asks for the impossible.

Errors I found in the draft:
  - It should be a EGL display extension, not an EGL client extension.
  - The new symbols must be suffixed with MESA.
Comment 11 Jonny Lamb 2015-02-16 13:29:20 UTC
Created attachment 113529 [details]
EGL_MESA_transparent_alpha draft 2

(In reply to Chad Versace from comment #10)
> The proposed extension looks like the right approach to me.
> 
> Regarding issue #1, I weakly prefer that it be illegal to specify
> EGL_TRANSPARENT_ALPHA for non-window surfaces. I like to emit errors when
> the user asks for the impossible.
> 
> Errors I found in the draft:
>   - It should be a EGL display extension, not an EGL client extension.
>   - The new symbols must be suffixed with MESA.

Thanks for your comments, I've updated the draft and attached it here. What do you think?
Comment 12 Jonny Lamb 2015-02-17 11:35:52 UTC
Created attachment 113561 [details]
third draft

Here is version three with a few typos fixed from version two and a note added about pre-multiplied alpha.
Comment 13 Jonny Lamb 2015-02-17 11:56:04 UTC
Created attachment 113563 [details]
version three

Apologies for the noise, fixed a few extra problems.
Comment 14 Chad Versace 2015-02-20 19:33:08 UTC
n reply to Jonny Lamb from comment #13)
> Created attachment 113563 [details]
> version three

Comments:

- Good call on specifying pre-multiplied alpha.

- I think you should remove the paragraph

    To determine if the EGL implementation supports this extension, clients
    should query the EGL_EXTENSIONS string of the current active display.

  because that's the normal way of querying extensions and needs no
  explanation. I found that paragraph confusing because it made me ask "Why is
  the extension telling me this? Is there some magic in this extension that I've
  failed to see that warrants this explanation?". The platform extension
  specification that you used as a template explicitly describes how to perform
  the extension query because its query mechanism differs from 95% of existing
  EGL extensions.

- You should remove the "New Behavior" section. Normally, the fine details of
  an extension specification are defined in the "Additions to the EGL x.y
  specification" section as a diff against the EGL x.y spec. This extension is no
  different. A few, special extensions, though, define behavior that should *not*
  be added to the EGL spec, such as the platform extensions. That's what the "New
  Behavior" section should be used for, and this alpha extension defines no such
  "outside-of-the-spec" behavior.

- The paragraph

    To obtain an EGL window surface with a meaningful alpha channel, use an
    EGLConfig with EGL_TRANSPARENT_TYPE set to EGL_TRANSPARENT_ALPHA_MESA.

  is still valuable, despite belonging in the "New Behavior" section. The
  proper location for it is the "Overview" section.

- Regarding issue #1:

    RESOLUTION: Yes. Non-window surfaces created with
    EGL_TRANSPARENT_TYPE set to EGL_TRANSPARENT_ALPHA_MESA will
    generate an error.

  What error does it generate? If we refer to this paragraph of Section 3.5.1 as precedent,

    If config does not support rendering to windows (the EGL_SURFACE_TYPE
    attribute does not contain EGL_WINDOW_BIT ), an EGL_BAD_MATCH error is
    generated.

  then the resolution text can be clarified as:

    RESOLUTION: Attempting to create a non-window surface with a config in
    which EGL_TRANSPARENT_TYPE is EGL_TRANSPARENT_ALPHA_MESA, then an
    EGL_BAD_MATCH error is generated.


- Other than the above (mostly sylistic) issues, the extension looks good to
  me.  Thanks for writing it! When you submit to mesa-dev, please CC me.
Comment 15 Jonny Lamb 2015-02-23 10:36:59 UTC
Created attachment 113752 [details]
version four

(In reply to Chad Versace from comment #14)
> - Good call on specifying pre-multiplied alpha.

Thanks to Pekka for suggesting that. :-)

> - I think you should remove the paragraph
> 
>     To determine if the EGL implementation supports this extension, clients
>     should query the EGL_EXTENSIONS string of the current active display.
> 
>   because that's the normal way of querying extensions and needs no
>   explanation. I found that paragraph confusing because it made me ask "Why
> is
>   the extension telling me this? Is there some magic in this extension that
> I've
>   failed to see that warrants this explanation?". The platform extension
>   specification that you used as a template explicitly describes how to
> perform
>   the extension query because its query mechanism differs from 95% of
> existing
>   EGL extensions.

Fair. It was included because it was previously a client extension but now I agree it's not necessary.

> - You should remove the "New Behavior" section. Normally, the fine details of
>   an extension specification are defined in the "Additions to the EGL x.y
>   specification" section as a diff against the EGL x.y spec. This extension
> is no
>   different. A few, special extensions, though, define behavior that should
> *not*
>   be added to the EGL spec, such as the platform extensions. That's what the
> "New
>   Behavior" section should be used for, and this alpha extension defines no
> such
>   "outside-of-the-spec" behavior.

OK, removed.

> - The paragraph
> 
>     To obtain an EGL window surface with a meaningful alpha channel, use an
>     EGLConfig with EGL_TRANSPARENT_TYPE set to EGL_TRANSPARENT_ALPHA_MESA.
> 
>   is still valuable, despite belonging in the "New Behavior" section. The
>   proper location for it is the "Overview" section.

Right.

> - Regarding issue #1:
> 
>     RESOLUTION: Yes. Non-window surfaces created with
>     EGL_TRANSPARENT_TYPE set to EGL_TRANSPARENT_ALPHA_MESA will
>     generate an error.
> 
>   What error does it generate? If we refer to this paragraph of Section
> 3.5.1 as precedent,
> 
>     If config does not support rendering to windows (the EGL_SURFACE_TYPE
>     attribute does not contain EGL_WINDOW_BIT ), an EGL_BAD_MATCH error is
>     generated.
> 
>   then the resolution text can be clarified as:
> 
>     RESOLUTION: Attempting to create a non-window surface with a config in
>     which EGL_TRANSPARENT_TYPE is EGL_TRANSPARENT_ALPHA_MESA, then an
>     EGL_BAD_MATCH error is generated.

Ah yes I now notice I also answered a "this or this?" question with "yes"! Fixed.

> - Other than the above (mostly sylistic) issues, the extension looks good to
>   me.  Thanks for writing it! When you submit to mesa-dev, please CC me.

Thanks very much for your comments, they've been very helpful.

I've attached the updated extension.
Comment 16 Jonny Lamb 2015-02-25 12:51:57 UTC
http://lists.freedesktop.org/archives/mesa-dev/2015-February/077586.html

Extension and implementation posted to the list.
Comment 17 Pekka Paalanen 2015-05-08 05:52:46 UTC
Adding James Jones to CC, because he has expressed disagreement on the proposed solution:
http://lists.x.org/archives/mesa-dev/2015-April/082140.html
Comment 18 Emil Velikov 2015-07-06 12:03:30 UTC
Hi all,

Based on the feedback so far, plus the fact that the i965 (suspecting that others do as well) module allows/exposes relevant format(s) should we mark this as won't fix. Or perhaps there is still some interest in the proposed extension ?
Comment 19 Daniel Stone 2017-01-03 11:13:11 UTC
*** Bug 99237 has been marked as a duplicate of this bug. ***
Comment 20 nfxjfg 2017-01-03 14:00:33 UTC
Of course there should be a solution for this. The current situation would require awful hacks to make it work with Mesa (or not work on nVidia). (See my comments in bug #99237.)

If I read the nVidia person's reply correctly, the complaint is that EGL_TRANSPARENT_TYPE is for color-keying only. Not sure why that blocked progress for years.

Sounds to me like two things should be done:
1. For each EGLConfig add a second EGLConfig with the equivalent RGBA visual if available. (This is what nVidia does on EGL, and what both nVidia and Mesa do on GLX.)
2. Optionally, specify a new extension that adds a new config attribute that specifies whether an EGLConfig is backed by a visual that enables alpha compositing of the window (say, EGL_ALPHA_WINDOW, which could have the values EGL_TRUE or EGL_FALSE).
Comment 21 Adam Jackson 2018-04-09 17:13:16 UTC
(In reply to Daniel Stone from comment #4)

> Can this at least be hidden behind an
> EGL_CONFORMANT_IF_NOT_PERHAPS_QUITE_AS_PERFORMANT variable or something?
> Removing the possibility to ever render destination alpha is pretty vicious,
> and breaks more than you'd expect (think UIs, not games).

This category of config sorting bug is why GLX has visual select groups:

https://www.khronos.org/registry/OpenGL/extensions/SGIX/GLX_SGIX_visual_select_group.txt

https://cgit.freedesktop.org/xorg/xserver/commit/glx/glxscreens.c?id=ea483af99a6351323afe00a0b630cd63310efdb1

Personally I'd just implement the same thing internally to EGL and put the alpha-ful configs in a less-preferred select group. You'll still get alpha if you ask for it, but you won't if you don't.
Comment 22 James Jones 2018-04-09 17:21:51 UTC
Note the NVIDIA proprietary driver maps alpha -> "I want transparency!" in both GLX and EGL, and I warned Mesa when this change was made it would break compatibility with our driver and apps that rely on it.  So I'd be in favor of restoring that behavior in Mesa as well.
Comment 23 Hal Gentz 2019-06-21 23:19:33 UTC
Created attachment 144608 [details] [review]
A patch that fixes transparency.
Comment 24 Hal Gentz 2019-06-21 23:20:17 UTC
Created attachment 144609 [details] [review]
A patch that puts RGBA visuals in the second config selection group. (Depends on first patch)
Comment 25 Hal Gentz 2019-06-21 23:20:54 UTC
Created attachment 144610 [details]
EGL_MESA_config_select_group
Comment 26 Hal Gentz 2019-06-21 23:28:46 UTC
I've implemented the solution suggested by Adam Jackson:

(In reply to Adam Jackson from comment #21)
>
> This category of config sorting bug is why GLX has visual select groups:
> 
> https://www.khronos.org/registry/OpenGL/extensions/SGIX/
> GLX_SGIX_visual_select_group.txt
> 
> https://cgit.freedesktop.org/xorg/xserver/commit/glx/glxscreens.
> c?id=ea483af99a6351323afe00a0b630cd63310efdb1
> 
> Personally I'd just implement the same thing internally to EGL and put the
> alpha-ful configs in a less-preferred select group. You'll still get alpha
> if you ask for it, but you won't if you don't.

I didn't understand Xorg's code, so I wrote a second patch that puts it in the second config selection group from the mesa side. I'm not sure if that's an acceptable solution, so here we are.

Please forgive me, for I've never written an extension before and I'm sure there's some* errors to it, ect ect

*Probably the understatement of the century.
Comment 27 Adam Jackson 2019-07-09 19:58:31 UTC
(In reply to Hal Gentz from comment #26)
> I've implemented the solution suggested by Adam Jackson:
> 
> (In reply to Adam Jackson from comment #21)
> >
> > This category of config sorting bug is why GLX has visual select groups:
> > 
> > https://www.khronos.org/registry/OpenGL/extensions/SGIX/
> > GLX_SGIX_visual_select_group.txt
> > 
> > https://cgit.freedesktop.org/xorg/xserver/commit/glx/glxscreens.
> > c?id=ea483af99a6351323afe00a0b630cd63310efdb1
> > 
> > Personally I'd just implement the same thing internally to EGL and put the
> > alpha-ful configs in a less-preferred select group. You'll still get alpha
> > if you ask for it, but you won't if you don't.
> 
> I didn't understand Xorg's code, so I wrote a second patch that puts it in
> the second config selection group from the mesa side. I'm not sure if that's
> an acceptable solution, so here we are.

This is mostly fine.

> Please forgive me, for I've never written an extension before and I'm sure
> there's some* errors to it, ect ect

Some spec review:

>    This extension provides a mechanism to lower the config selection priority 
>    of the configs returned by eglChooseConfig. A new config attribute is
>    introduced, providing a way for servers to group configs into different
>    config selection categories.

EGL doesn't require a "server" in the X11 sense. It's probably best to
phrase this as "a way for EGL to" or "a way for the implementation to".

>                                  The config selection priorities of all the
>    configs in one category may be higher or lower than the ones in other
>    categories.  The config selection priorities in one category follow the
>    rules of eglChooseConfig.  The new attribute is invisible to users so it
>    can't be queried by eglGetConfigAttrib.

I only sort of understand why the GLX extension decided to hide this extension
from queries, I'm not sure it's all that important to insist on it for EGL.
Particularly since without it, it's difficult to discover why you're getting
an unexpected config.

>    Accepted as the value of the EGLConfig attribute EGL_TRANSPARENT_TYPE:

I don't think you mean this. You don't want to allow filtering configs based
on the select group number, and the select group number is not a transparency
type.

>        EGL_CONFIG_SELECT_GROUP_MESA                0x31D9

Annoyingly, 0x31D9-0x31DB are in use by EGL_WL_bind_wayland_display, but not
noted as such in egl.xml. 0x31DC appears to be the lowest unused enum.

>    "The attribute EGL_CONFIG_SELECT_GROUP_MESA is used for communication
>    between servers and the EGL client. It is not accepted by the <attrib_list>
>    parameter of eglChooseConfig, nor is it accepted as the <attribuite> in
>    eglGetConfigAtrrib."

Again, EGL doesn't necessarily require a client/server split. I might say something more like: "The attribute EGL_CONFIG_SELECT_GROUP_MESA is used by the EGL to override the default sorting rules, by collecting configurations into groups." And if you choose to allow querying the select group, s/nor is it/but it is/.

Also, "attribuite" should be "attribute".
Comment 28 nfxjfg 2019-07-10 19:52:03 UTC
Nice that there's some movement.

I have no idea what the patch does. What does it mean for clients?
Comment 29 Hal Gentz 2019-07-11 07:14:06 UTC
First of all, thank you for taking time to look at this!

> Some spec review:
> 
> >    This extension provides a mechanism to lower the config selection priority 
> >    of the configs returned by eglChooseConfig. A new config attribute is
> >    introduced, providing a way for servers to group configs into different
> >    config selection categories.
> 
> EGL doesn't require a "server" in the X11 sense. It's probably best to 
> phrase this as "a way for EGL to" or "a way for the implementation to".

My bad, this was sort of cargo-culted from the GLX extension, without any regard
to whether or not it was still applicable.

> >                                  The config selection priorities of all the
> >    configs in one category may be higher or lower than the ones in other
> >    categories.  The config selection priorities in one category follow the
> >    rules of eglChooseConfig.  The new attribute is invisible to users so it
> >    can't be queried by eglGetConfigAttrib.
> 
> I only sort of understand why the GLX extension decided to hide this
> extension
> from queries, I'm not sure it's all that important to insist on it for EGL.
> Particularly since without it, it's difficult to discover why you're getting
> an unexpected config.
> 

Fair enough, I presumed there was a reason behind it that I was simply missing
out on, and just cargo-culted this as well. 

> >    Accepted as the value of the EGLConfig attribute EGL_TRANSPARENT_TYPE:
> 
> I don't think you mean this. You don't want to allow filtering configs based
> on the select group number, and the select group number is not a transparency
> type.
> 
> >        EGL_CONFIG_SELECT_GROUP_MESA                0x31D9

My bad, I've replaced this with "Accepted as a new EGLConfig attribute:", as
that is actually correct to my knowledge. It was just another cargo-culted
phrase.

> Annoyingly, 0x31D9-0x31DB are in use by EGL_WL_bind_wayland_display, but not
> noted as such in egl.xml. 0x31DC appears to be the lowest unused enum.

I was not aware. Thank you!

> >    "The attribute EGL_CONFIG_SELECT_GROUP_MESA is used for communication
> >    between servers and the EGL client. It is not accepted by the <attrib_list>
> >    parameter of eglChooseConfig, nor is it accepted as the <attribuite> in
> >    eglGetConfigAtrrib."
> 
> Again, EGL doesn't necessarily require a client/server split. I might say
> something more like: "The attribute EGL_CONFIG_SELECT_GROUP_MESA is used by
> the EGL to override the default sorting rules, by collecting configurations
> into groups." And if you choose to allow querying the select group, s/nor is
> it/but it is/.
> 
> Also, "attribuite" should be "attribute".

Yeah, I was not aware that EGL didn't need a client/server split. I assumed it
would be similar to GLX, and just kept it basically as is. Thanks.

(In reply to nfxjfg from comment #28)
> Nice that there's some movement.
> 
> I have no idea what the patch does. What does it mean for clients?

EGLConfigs with alpha-blending will be placed closer to the bottom of the list.
Clients that want those configs will just have to iterate over the whole list
looking for one which supports alpha-blending. `XRenderFindVisualFormat` is your
friend for this task. Clients that don't want alpha-blending can continue to
just select the first config that pops up.
Comment 30 Hal Gentz 2019-07-11 07:15:09 UTC
Created attachment 144758 [details]
EGL_MESA_config_select_group v2
Comment 31 Hal Gentz 2019-07-11 07:16:29 UTC
I'm going to update my patch to use `0x31DC` on the weekend. I plan to also check that passing EGL_CONFIG_SELECT_GROUP_MESA to eglGetConfigAtrrib doesn't do anything silly.
Comment 32 Hal Gentz 2019-07-16 22:44:39 UTC
It took some fiddling, but I did get it to work, and as you can see, it is sorting everything properly: https://github.com/rust-windowing/glutin/issues/1191#issuecomment-512015144

I've updated the PR on gitlab: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1185
Comment 33 Adam Jackson 2019-09-18 18:06:43 UTC
bz migration script doesn't like this bug, but there's a partial import of this issue here:

https://gitlab.freedesktop.org/mesa/mesa/issues/149

Please follow up there.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.