Commit graph

354 commits

Author SHA1 Message Date
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
Daniel Stone
084fea1e7d egl/wayland: s/DRI_IMAGE_FORMAT/pipe_format/g
All the DRI_IMAGE_FORMATs we use are now pipe_formats, so eliminate the
old type names.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
ba3b867552 egl/wayland: Query image FourCC for linear copies
This entire pattern really wants to be a shared helper, to allocate a
shadow linear image from another device and then import it across into
the rendering GPU. Querying the FourCC from the DRIImage makes it easier
to pull out into shared code.

This temporarily makes the implementation more ugly, however it's
already pretty hard on the eyes, so probably no great loss.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27709>
2024-02-27 10:51:03 +00:00
Daniel Stone
303b935dbd egl/wayland: Remove format-query fallback
The DRI2 frontend should always be responsible for answering a FourCC
query, so just remove one use of DRI formats here.

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
Michel Dänzer
7a6836611e egl/wayland: Flush after blitting to linear copy
We need to flush after blitting to the linear copy, or the Wayland
compositor may not see the correct linear buffer contents.

v2:
* Keep blitImage call in the same place (Daniel Stone)
* Add second flush for the blit to linear copy

Fixes: 58f90fd03f ("egl/wayland: fix glthread crashes")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9816
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27718>
2024-02-23 08:43:54 +00:00
Mike Blumenkrantz
198719e80e drisw/egl: delete unused buffer age handling
age is never used here

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27554>
2024-02-20 15:12:38 +00:00
Mike Blumenkrantz
81ecb21d50 drisw: hook up EXT_buffer_age
drisw only has a single drawable, which means the buffer age is always 1

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27554>
2024-02-20 15:12:38 +00:00
Derek Foreman
2fa1979c66 egl/wayland: Fix possible buffer leak
If we have to wait for a buffer to be released in swrast_update_buffers(),
we can leak it.

Take care to reuse the existing buffer if one is still available.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26761>
2024-01-12 15:16:31 +00:00
Michael Tretter
d9fd4d7c0d egl/wayland: fix formatting and add trailing comma
Commit 659bace01a ("egl: add a few trailing commas") added a few
trailing commas to the last item in a struct to avoid that commit
e85983d772 ("egl: re-format using clang-format") moves the closing
brace into the previous line.

The wl_callback_listener was missing the comma and the brace was moved
to the previous line, which makes it harder to read the code.

Add the comma and fix the formatting.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26902>
2024-01-06 02:19:02 +00:00
Pierre-Eric Pelloux-Prayer
5119e0adc3 egl/wayland: set the correct modifier for the linear_copy image
linear_copy_display_gpu_image is created using DRM_FORMAT_MOD_LINEAR,
so use createImageFromDmaBufs3 to be able to pass the modifier when
importing it on the render GPU.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9282
Reviewed-by: Simon Ser <contact@emersion.fr>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26337>
2023-12-04 11:03:41 +00:00
Simon Ser
9b70096f5e egl: move dri2_setup_device() after dri2_setup_extensions()
dri2_setup_device() will depend on the extensions being set up in
the next commit.

None of the code in-between depends on disp->Device AFAIU.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Tested-by: Iago Toral Quiroga <itoral@igalia.com>
Tested-by: Alejandro Piñeiro <apinheiro@igalia.com>
Backport-to: 23.3
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26205>
2023-11-18 13:19:05 +01:00
Simon Ser
b4ec0b51ce egl: extract EGLDevice setup in dedicated function
Extract the logic responsible for populating disp->Device via
_eglFindDevice(). This isn't much for now but will grow in a
following commit.

No functional changes.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Tested-by: Iago Toral Quiroga <itoral@igalia.com>
Tested-by: Alejandro Piñeiro <apinheiro@igalia.com>
Backport-to: 23.3
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26205>
2023-11-18 13:19:04 +01:00
Mike Blumenkrantz
e36e9bd392 egl/wayland: only add more registry listeners for hardware devices
these extensions shouldn't be exposed for pure software drivers

fixes #9948

Fixes: 1b4e877def ("egl/wayland: use more registry listeners to better handle device init")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25817>
2023-10-19 21:10:43 +00:00
Mike Blumenkrantz
1d149575ea egl: unify dri2_egl_display creation
this is the same for all platforms

no functional changes

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25640>
2023-10-19 17:41:42 +00:00
Mike Blumenkrantz
78f3db760d egl: don't set ForceSoftware for all zink loading
sometimes this is desired, other times it isn't

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25526>
2023-10-09 18:43:09 +00:00
Ian Douglas Scott
1950481d08 egl/wayland: Don't segfault if create_wl_buffer returns NULL
Normally, this shouldn't fail, but it has various cases where it returns
`NULL`. Without this change, it would result in a segfault when
`wl_buffer_add_listener` is called.

This instead makes `EGLSwapBuffers` return a `EGL_BAD_ALLOC` error.

The other place `create_wl_buffer` is called already checks the return
value, and the Vulkan WSI code doesn't seem to have an issue like this.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24915>
2023-10-06 18:31:29 +00:00
Mike Blumenkrantz
548d088c26 egl/wayland: return sooner from swrast_update_buffers() if zink
Fixes: 0f50cc03ef0 ("egl/wayland: don't block in swrast when updating buffers for zink")

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24700>
2023-10-06 04:53:40 +00:00
Mike Blumenkrantz
8aa43d70e1 egl/wayland: don't block in swrast when updating buffers for zink
this is broken, let vulkan wsi handle buffer management

Fixes: 74451ed3f0 ("egl/wayland: wait for compositor to release shm buffers")

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24700>
2023-10-06 04:53:40 +00:00
Mike Blumenkrantz
e213623a8c Revert "egl/wayland: Add image loader extension for swrast"
This reverts commit 45b9b0ba32.

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24700>
2023-10-06 04:53:40 +00:00
Mike Blumenkrantz
d6748c72d8 egl/wayland: enable WL_bind_wayland_display for zink
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24975>
2023-09-19 02:47:31 +00:00
Mike Blumenkrantz
1b4e877def egl/wayland: use more registry listeners to better handle device init
this handles globals like dmabuf and wl_drm and also enables creating
egl devices with valid fds

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24975>
2023-09-19 02:47:31 +00:00
Mike Blumenkrantz
7ac0dbd73b egl/wayland: split out wl drm extension init
no functional changes

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24975>
2023-09-19 02:47:31 +00:00
Mike Blumenkrantz
e0e812f34a egl/swrast: expose EXT_swap_buffers_with_damage and EXT_present_opaque
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24975>
2023-09-19 02:47:31 +00:00
Daniel Stone
0b976bd48d egl/wayland: Assume modern DRI interface versions
We know what version the DRI_IMAGE extension is, and it's higher than 7.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24347>
2023-07-28 12:25:19 +00:00
Daniel Stone
b3ec7c2a9e egl/wayland: Never use DRI2_LOADER extension
We don't need this anymore; the image loader extension does everything
we want it to and more, and is mandatory when we load.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24347>
2023-07-28 12:25:19 +00:00
Daniel Stone
45b9b0ba32 egl/wayland: Add image loader extension for swrast
It doesn't hurt to have it here, so might as well.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24347>
2023-07-28 12:25:19 +00:00
Daniel Stone
449e5bad7c egl/wayland: Always initialise fd_display_gpu
Set it to an invalid value, rather than leaving it to be stdout or
something.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24347>
2023-07-28 12:25:19 +00:00
Daniel Stone
00aa095d53 dri: Support 1555/4444 formats
Add support for 1555 and 4444 formats, both in RGB/BGR ordering, with
and without alpha.

These are already supported by Gallium and drivers, but not yet for
winsys surfaces. Adding these is enough to make them renderable when
using Weston on iris.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24331>
2023-07-28 12:44:01 +01:00
Robert Mader
74451ed3f0 egl/wayland: wait for compositor to release shm buffers
Some Wayland compositors, notably Exo, do not always release buffers
fast enough, and not in sync with their frame callbacks, to guarantee
that a free buffer is available the next time a client calls
`eglSwapBuffers()`.

This currently leads to a crash in `dri2_wl_swrast_get_backbuffer_data()`
with the swrast backend. To avoid this, simply block until the
compositor releases a buffer eventually.

While arguably compositors should release buffers they don't need any
more for the next frame, this can be quite complex depending on
the architecture - notably multi-process/IPC in case of Exo.

cc: mesa-stable

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24091>
2023-07-19 15:11:46 +00:00