egl: Implement EGL_MESA_x11_native_visual_id

EGL 1.5 specification requires to not match on EGL_NATIVE_VISUAL_ID.

EGL_MESA_x11_native_visual_id extension allows us to remove this
restriction for X11, where we need to match EGL_NATIVE_VISUAL_ID to find
visuals which allow blending.

The reasoning is that on X11, compositors use the visual as "magic bit"
to decide whether to alpha-blend surface contents.
Unlike on most (all?) other windowing systems, requesting an alpha channel
for the config alone does not already imply blending on the compositor
level.

Thus, in order to allow clients to explicitly request configs with
"magic bit" and, similar to GLX, to order configs in a way so clients
not requesting alpha-blending do not get it by accident, do match
visual ids.

Note that one consequence of this is that more configs get
reported to clients.

Based on a patch by Freya Gentz <zegentzy@protonmail.com>, see
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2376

Signed-off-by: Robert Mader <robert.mader@posteo.de>
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9989>
This commit is contained in:
Robert Mader 2021-10-16 17:16:46 +02:00 committed by Marge Bot
parent 3736c9997c
commit 9bdab38424
4 changed files with 91 additions and 0 deletions

View file

@ -0,0 +1,80 @@
Name
MESA_x11_native_visual_id
Name Strings
EGL_MESA_x11_native_visual_id
Contact
Eric Engestrom <eric@engestrom.ch>
Status
Complete, shipping.
Version
Version 2, May 10, 2024
Number
EGL Extension #TBD
Extension Type
EGL display extension
Dependencies
None. This extension is written against the
wording of the EGL 1.5 specification.
Overview
This extension allows EGL_NATIVE_VISUAL_ID to be used in
eglChooseConfig() for a display of type EGL_PLATFORM_X11_EXT.
IP Status
Open-source; freely implementable.
New Types
None
New Procedures and Functions
None
New Tokens
None
In section 3.4.1.1 "Selection of EGLConfigs" of the EGL 1.5
Specification, replace:
If EGL_MAX_PBUFFER_WIDTH, EGL_MAX_PBUFFER_HEIGHT,
EGL_MAX_PBUFFER_PIXELS, or EGL_NATIVE_VISUAL_ID are specified in
attrib list, then they are ignored [...]
with:
If EGL_MAX_PBUFFER_WIDTH, EGL_MAX_PBUFFER_HEIGHT,
or EGL_MAX_PBUFFER_PIXELS are specified in attrib list, then they
are ignored [...]. EGL_NATIVE_VISUAL_ID is ignored except on
a display of type EGL_PLATFORM_X11_EXT when EGL_ALPHA_SIZE is
greater than zero.
Issues
None.
Revision History
Version 1, March 27, 2024 (Eric Engestrom)
Initial draft
Version 2, May 10, 2024 (David Heidelberg)
add EGL_ALPHA_SIZE condition
add Extension type and set it to display extension

View file

@ -288,6 +288,13 @@ dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
static EGLBoolean
dri2_match_config(const _EGLConfig *conf, const _EGLConfig *criteria)
{
#ifdef HAVE_X11_PLATFORM
if (conf->Display->Platform == _EGL_PLATFORM_X11 &&
conf->AlphaSize > 0 &&
conf->NativeVisualID != criteria->NativeVisualID)
return EGL_FALSE;
#endif
if (_eglCompareConfigs(conf, criteria, NULL, EGL_FALSE) != 0)
return EGL_FALSE;
@ -836,6 +843,8 @@ dri2_setup_screen(_EGLDisplay *disp)
disp->Extensions.MESA_image_dma_buf_export = EGL_TRUE;
}
disp->Extensions.MESA_x11_native_visual_id = EGL_TRUE;
disp->Extensions.KHR_image_base = EGL_TRUE;
disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE;

View file

@ -594,6 +594,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp)
_EGL_CHECK_EXTENSION(MESA_gl_interop);
_EGL_CHECK_EXTENSION(MESA_image_dma_buf_export);
_EGL_CHECK_EXTENSION(MESA_query_driver);
_EGL_CHECK_EXTENSION(MESA_x11_native_visual_id);
_EGL_CHECK_EXTENSION(NOK_swap_region);
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);

View file

@ -146,6 +146,7 @@ struct _egl_extensions {
EGLBoolean MESA_gl_interop;
EGLBoolean MESA_image_dma_buf_export;
EGLBoolean MESA_query_driver;
EGLBoolean MESA_x11_native_visual_id;
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;