Commit 4e3a7dcf authored by Adam Jackson's avatar Adam Jackson 🎧 Committed by Marge Bot
Browse files

gallium: enable EGL_EXT_image_dma_buf_import_modifiers unconditionally

This is a re-do of [1].

Enable EGL_EXT_image_dma_buf_import_modifiers with
EXT_image_dma_buf_import. This allows users to use queryDmaBufFormats to
query the list of supported formats even if modifiers are not supported.

With this change, queryDmaBufModifiers always returns zero modifiers. A
compositor survey reveals that this should be fine: wlroots [2],
Weston [3], Mutter [4] [5], kwin [6] and xorg-xserver [7] seem to all
support this case gracefully.

Tested with Sway and wlroots by running weston-info and checking the
list of formats advertised by zwp_linux_dmabuf_v1. Also ran weston-simple-egl
and checked zwp_linux_dmabuf_v1 was used instead of wl_drm.

[1]: !1812
[2]: https://github.com/swaywm/wlroots/blob/8707a9b7ecbba0321804604d9ea954a46ecced21/render/egl.c#L629
[3]: https://gitlab.freedesktop.org/wayland/weston/-/blob/786490cb53439624fd3c20b9e19d3ea5ec316c00/libweston/renderer-gl/gl-renderer.c#L2337
[4]: https://gitlab.gnome.org/GNOME/mutter/-/blob/f0df07cba3ca308b47c9aefcc8112e8880fd9950/src/wayland/meta-wayland-dma-buf.c#L486
[5]: https://gitlab.gnome.org/GNOME/mutter/-/blob/0a6034ef3a745c25ab63c2ca8d4ae08bc5e09d88/src/backends/native/meta-renderer-native.c#L399
[6]: https://cgit.kde.org/kwin.git/tree/platformsupport/scenes/opengl/egl_dmabuf.cpp?id=9b7ab4d16a8ee0cb35108362ee5aa046f4ae20b7#n473
[7]: https://gitlab.freedesktop.org/xorg/xserver/-/blob/26004df63c25061586a967f3586795a75280acc2/glamor/glamor_egl.c#L682

Tested-by: Marge Bot <!4298>
Part-of: <!4298>
parent e0aa203f
Pipeline #127699 passed with stages
in 29 minutes and 29 seconds
......@@ -1006,11 +1006,6 @@ dri2_setup_screen(_EGLDisplay *disp)
if (dri2_dpy->image->base.version >= 8 &&
dri2_dpy->image->createImageFromDmaBufs) {
disp->Extensions.EXT_image_dma_buf_import = EGL_TRUE;
}
if (dri2_dpy->image->base.version >= 15 &&
dri2_dpy->image->createImageFromDmaBufs2 &&
dri2_dpy->image->queryDmaBufFormats &&
dri2_dpy->image->queryDmaBufModifiers) {
disp->Extensions.EXT_image_dma_buf_import_modifiers = EGL_TRUE;
}
#endif
......
......@@ -1391,14 +1391,16 @@ dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
format = map->pipe_format;
if (pscreen->query_dmabuf_modifiers != NULL &&
(pscreen->is_format_supported(pscreen, format, screen->target, 0, 0,
if (pscreen->is_format_supported(pscreen, format, screen->target, 0, 0,
PIPE_BIND_RENDER_TARGET) ||
pscreen->is_format_supported(pscreen, format, screen->target, 0, 0,
PIPE_BIND_SAMPLER_VIEW) ||
dri2_yuv_dma_buf_supported(screen, map))) {
pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers,
external_only, count);
dri2_yuv_dma_buf_supported(screen, map)) {
if (pscreen->query_dmabuf_modifiers != NULL)
pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers,
external_only, count);
else
*count = 0;
return true;
}
return false;
......@@ -1409,6 +1411,12 @@ dri2_query_dma_buf_format_modifier_attribs(__DRIscreen *_screen,
uint32_t fourcc, uint64_t modifier,
int attrib, uint64_t *value)
{
struct dri_screen *screen = dri_screen(_screen);
struct pipe_screen *pscreen = screen->base.screen;
if (!pscreen->query_dmabuf_modifiers)
return false;
switch (attrib) {
case __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT: {
uint64_t mod_planes = dri2_get_modifier_num_planes(modifier, fourcc);
......@@ -2086,13 +2094,11 @@ dri2_init_screen(__DRIscreen * sPriv)
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
if (pscreen->query_dmabuf_modifiers) {
dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
dri2ImageExtension.queryDmaBufModifiers =
dri2_query_dma_buf_modifiers;
dri2ImageExtension.queryDmaBufFormatModifierAttribs =
dri2_query_dma_buf_format_modifier_attribs;
}
dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
dri2ImageExtension.queryDmaBufModifiers =
dri2_query_dma_buf_modifiers;
dri2ImageExtension.queryDmaBufFormatModifierAttribs =
dri2_query_dma_buf_format_modifier_attribs;
}
}
......@@ -2168,10 +2174,8 @@ dri_kms_init_screen(__DRIscreen * sPriv)
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
if (pscreen->query_dmabuf_modifiers) {
dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
dri2ImageExtension.queryDmaBufModifiers = dri2_query_dma_buf_modifiers;
}
dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
dri2ImageExtension.queryDmaBufModifiers = dri2_query_dma_buf_modifiers;
}
sPriv->extensions = dri_screen_extensions;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment