Commit graph

382 commits

Author SHA1 Message Date
Emma Anholt
24d03a1c0f dri: Replace createImageFromDmaBufs() with createImageFromDmaBufs3()
If FromDmaBufs()/FromDmaBufs2() are available, then FromDmaBufs3() is.
Drop the old method (unused by third parties) and make the new preferred
entrypoint take its name.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30245>
2024-07-18 14:16:50 +00:00
Faith Ekstrand
1f906f8715 zink/kopper: Set VK_COMPOSITE_ALPHA_OPAQUE_BIT when PresentOpaque is set
This is required for EGL_EXT_present_opaque to work correctly.

Fixes: 8ade5588e3 ("zink: add kopper api")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11007
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30133>
2024-07-12 15:22:44 +00:00
msizanoen
e5e108706c egl/wayland: Fix direct scanout with EGL_EXT_present_opaque
We select the feedback tranche according to the image format but not the
actual format that we will use for presentation. This breaks direct
scanout in cases where the application selected a visual with an alpha
channel but using EGL_EXT_present_opaque which previously worked as
expected.

Fix this by selecting the feedback tranche according to the actual
presentation format.

Fixes: 9ea9a963aa ("egl/wayland: Fix EGL_EXT_present_opaque")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28153>
2024-07-09 06:42:33 +00:00
Alexandros Frantzis
4cac8468d4 egl/wayland: Fail EGL surface creation if opaque format is unsupported
When using the EGL_EXT_present_opaque extension we create wayland
buffers with the opaque variant of the surface format, while the
underlying image is created with the normal surface format. However,
there is no guarantee that the compositor supports that opaque format,
or that we can use that format with all the modifiers of the surface
format.

Since this is completely out of the control of the application, and the
compositor will disconnect the client with an error if the format is not
supported, this commit:

1. Fails EGL surface creation if it determines that the opaque format
   cannot be used, either because it's not present at all, or because
   it shares no modifier with the non-opaque format.
2. When creating the DRI image ensures that we use a modifier that's
   also supported by the opaque format.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28153>
2024-07-09 06:42:33 +00:00
Alexandros Frantzis
a271a34d59 egl/wayland: Pass dri2_wl_formats to create_dri_image
Make the dri2_wl_formats struct available in create_dri_image, in
preparation for upcoming changes.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28153>
2024-07-09 06:42:33 +00:00
Julian Orth
77759f7683 egl/wayland: ignore unsupported driver configs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29904>
2024-06-26 06:56:39 +00:00
Louis-Francis Ratté-Boulianne
ea8977618f egl/dri2: add support for EGL_EXT_surface_compression
Use the new DRI interface hooks to implement
eglQuerySupportedCompressionRatesEXT and the new
EGL_SURFACE_COMPRESSION_EXT attribute when creating a window
surface.

Only wayland support for now.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27109>
2024-06-12 21:20:06 +00:00
Louis-Francis Ratté-Boulianne
f5d85365a7 egl/wayland: factor out common part of DRI image creation
Both paths are pretty much the same no matter if we are using the
old format protocol or the dmabuf_feedback protocol.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27109>
2024-06-12 21:20:06 +00:00
Adrian Perez de Castro
2934e1fad5 Revert "egl/wayland: Remove EGL_WL_create_wayland_buffer_from_image"
The EGL_WL_create_wayland_buffer_from_image is still used in WPE WebKit.
There is work in progress to continue adoption of DMA-BUF usage inside
WebKit which will eventually render the extension unneeded; but in the
meantime an update to a version of Mesa without the extension would
render applications using WPE WebKit unusable.

This reverts commit a3418105b9.

Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29266>
2024-05-17 14:15:47 +00:00
Mykhailo Skorokhodov
066fc39f45 egl/wayland: Fix sRGB format look up for config
That check should help with situations when
the dri2_wl_visual_idx_from_pipe_format function
can't recognize pipe_format as before.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10829
Fixes: 6a084e2b("egl/wayland: Use pipe_format to look up configs")
Signed-off-by: Mykhailo Skorokhodov <mykhailo.skorokhodov@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29052>
2024-05-06 20:55:59 +00:00
Derek Foreman
8b460cf9b5 egl/wayland: Use loader_wayland_dispatch
This is just to get event tracing in perfetto, as the wrapper calls
MESA_TRACE_FUNC().

It can be useful to see how long and when we stall in wayland dispatch.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28634>
2024-05-02 19:37:26 +00:00
Eric Engestrom
aeab27cc24 egl: drop dead dri2_dpy param in dri2_wl_visual_idx_from_config()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28528>
2024-04-18 11:22:49 +00:00
Lucas Fryzek
b3680c92a1 egl/wayland/sw: don't invert y wl_surface_damage_buffer
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28242>
2024-03-24 17:27:21 +00:00
Daniel Stone
a3418105b9 egl/wayland: Remove EGL_WL_create_wayland_buffer_from_image
This extension was originally intended to complement
EGL_WL_bind_wayland_display.

The idea behind bind_wayland_display was that libEGL.so on the server
side could register Wayland extensions for libEGL.so on the client side
to use to create buffers, with eglQueryWaylandBufferWL being used to
query the buffer properties, and EGL_WAYLAND_BUFFER_WL added as an
EGLImage target for texturing.

eglCreateWaylandBufferFromImageWL was then to be used for nested
compositors to perform passthrough: it would take an EGLImage created by
the magical libEGL secret handshake, and make it usable in the parent
compositor by doing the same secret handshake again.

Since that original idea, we've just standardised dmabuf across the
Wayland ecosystem instead. The last known user of this extension was a
sample client in the Weston tree, which was broken quite some years ago
and never ported to the Meson build system when we moved.

Given it won't affect anyone, let's just remove this extension so no-one
thinks it would be a good idea to use it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27793>
2024-02-29 18:26:53 +00:00
Mike Blumenkrantz
f0430b095b egl/wayland: delete swrast references to zink
this is an entirely separate path now

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
17355e737d egl/wayland: split out kopper update_buffers
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
1959691033 egl/wayland/kopper: actually call kopper swapbuffer functions
this allows passing through the zsbuf discard flag

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
9cf22c5fd0 egl/kopper: call swrast buffer age query for kopper+swrast
with zink+lavapipe, this is actually how it works since the vtable is
different

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
1bd28d62e4 egl/wayland: split out kopper swapbuffers functions
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
76f74f55a4 egl/wayland: add a separate hook for kopper buffer age
this otherwise hits the swrast one which is wrong

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
4345c415d7 egl/wayland: split out kopper vtable
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
c83768c76c egl/wayland/sw: clamp putimage geometry to surface size
this otherwise writes oob

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
fa465e34ca egl/wayland/sw: pass damage region through from put_image2 to wl_surface_damage
this propagates damage from drisw to wayland; y inversion matches protocol

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
d90b14c768 egl/wayland/sw: fix no-op updating of current backbuffer
if the frontbuffer is the backbuffer then its contents are up-to-date

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
75cf82005d egl/wayland/sw: move partial->full copy promotion to swapbuffers
this will ensure that the wl_buffer data is always fully updated

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
425d919b0a egl/wayland/sw: trigger damage from put_image2
no functional changes currently

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
e4db8c6e8d egl/wayland/sw: call dri2_wl_swrast_attach_backbuffer() before swap
should be no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
448cd2cd37 egl/wayland/sw: split out surface attach from dri2_wl_swrast_commit_backbuffer()
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
cce12981e4 egl/wayland: unify back/current swapping between zink and swrast
these are functionally the same, they just happened in different places

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
73a3a1c646 egl/wayland/sw: move dri2_wl_swrast_commit_backbuffer() directly into swapbuffers
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
81e5f9c398 egl/wayland/sw: move swrast_update_buffers() directly into swapbuffers
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Mike Blumenkrantz
fd6f7e3f16 drisw: plumb through a swapBuffersWithDamage interface
currently the same as regular swap

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27703>
2024-02-29 01:15:23 +00:00
Simon Ser
af41fad1e9 egl/wayland: explain why implicit modifier downgrade is allowed
We break the rule that an explicit modifier cannot be stripped.
Fixing this would require a bit of effort and wl_drm is reaching
its end of life anyways, so leave a TODO instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26346>
2024-02-28 21:30:55 +00:00
Simon Ser
35143febba egl/wayland: ensure wl_drm is available before use
Avoid crashing if wl_drm is unavailable. Instead, gracefully error
out.

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Fixes: c60fea8c22 ("Revert "egl/wayland: deprecate drm_handle_format() and drm_handle_capabilities()"")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26346>
2024-02-28 21:30:55 +00:00
Pierre-Eric Pelloux-Prayer
224ff11617 egl/wayland: use __DRI_IMAGE_PRIME_LINEAR_BUFFER in get_back_bo
Some drivers (radeonsi, iris) relies on this hint to detect DRI_PRIME
blits and implement a special path (eg: SDMA copy for radeonsi).

Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27719>
2024-02-28 12:47:54 +00:00
Derek Foreman
235144cf51 egl/wayland: Give names to our Wayland event queues
Named queues just add a little bit more debugging information.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27824>
2024-02-28 11:01:31 +00:00
Daniel Stone
832d814852 egl: Remove shifts/sizes from dri2_add_config argument
All the callers now do their own filtering on driver configs to decide
whether or not to add them.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
630fda2492 egl: Automatically set EGLConfig ID
There's no reason to make the users go through and count all their
configs; just set it ourselves in the core.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
bf7ebe6ff8 egl/wayland: Remove check for EGLConfig presence
We now check in the EGL core that we actually have some configs for the
display, so no need to do it in the platform.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
97c435c926 egl/wayland: Remove shift/size masks
We don't need these anymore.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
7889c9dc92 egl/wayland: Use pipe_format for format names
We don't need to carry our own strings.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
84bb6d0e0a egl/wayland: Remove WL_SHM_* format listings
We don't need to type all of these out, because they're exactly the same
as the DRM ones, with the exception of ARGB8888 and XRGB8888 which carry
their own format codes.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
5ac70182e8 egl/wayland: Simplify alternate-format fallback for configs
Rather than doing everything to add the config twice, we can simply
reuse the helpers to check if the different formats are supported, then
add the config only once.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
ee04cc5d2b egl/wayland: Eliminate double loop for configs
We used to loop like this:

foreach (config_supported_by_driver) {
   foreach (config_wl_knows_about) {
      dri2_add_config(wl_config.rgba_masks, wl_config.rgba_shifts)) {
         if (wl_config.rgba_masks != driver_config.rgba_masks ||
	     wl_config.rgba_shifts != driver_config.rgba_shifts) {
            return NULL; /* driver config != wl config */
         }
      }
   }
}

This is a pretty painful way to discover the relationship between the
different sets of configs, especially as we can just look up our Wayland
visual entry directly.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
f63e676370 egl/wayland: Use helper to look up visual
No functional change.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
ebdf9ad85c egl/wayland: Add helper to check server format support
Often when we look up a dri2_wl_visual, the only thing we want to do
with it is check whether or not the server supports it. Add a helper for
this common pattern.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
a34d3c290e egl/wayland: Use FourCC to look up wl_buffer support
No point in using a DRI_IMAGE_FORMAT, since we'll need to get a FourCC
for dmabuf/wl_drm support anyway.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
6a084e2b08 egl/wayland: Use pipe_format to look up configs
Instead of using the sizes and shifts to look up a dri2_wl_visual from a
config, just use the pipe_format we stash in the config.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
9ea9a963aa egl/wayland: Fix EGL_EXT_present_opaque
This extension has been broken ever since the initial commit. It created
an XRGB DRIImage for the driver to render to, so whilst the presentation
was opaque, the buffer also completely lacked an alpha channel.

Fix it by making sure we only modify the FourCC we send to the Wayland
server when creating a buffer.

Closes: mesa/mesa#5886
Fixes: 9aee7855d2 ("egl: implement EGL_EXT_present_opaque on wayland")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
c74f480391 egl/wayland: Add opaque-equivalent FourCCs
Add a mapping for the opaque version of an alphaful format (e.g.
ARGB8888 -> XRGB8888) to better support EGL_EXT_present_opaque.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00