Commit Graph

8087 Commits

Author SHA1 Message Date
Derek Foreman c8db957a0b rdp: Add audio support
Allow the front end to register audio setup and teardown functions. These
functions should use FreeRDP's rdpsnd_server_context or
audin_server_context and set up their own handler threads.

The backend remains mostly ignorant to any audio details beyond setting up
and tearing down.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-05-26 19:06:19 +00:00
Derek Foreman f8ca784737 rdp: Fix some accidental style errors in new clipboard code
I missed a few things when this was initially merged.

No functional changes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-05-26 12:43:18 -05:00
Derek Foreman 2df71c6dd7 rdp: Make thread checks unconfigurable
Instead of a meson option or hidden define, just run these checks always.

It is not Weston's style to add build options for specific asserts, and
currently weston's codebase is expected to always run with asserts
enabled.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-05-24 07:29:45 -05:00
Robert Mader 572ad2d8a9 clients/simple-dmabuf-*: Use gbm_bo_create_with_modifiers2
It is used in Mesa. Lets switch to it as well in order to provide
good examples and encourage proper API usage.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-23 13:25:34 +00:00
Robert Mader 46a6b5b448 clients/simple-dmabuf-feedback: Support multi-tranche feedbacks
Compositors may choose to send multiple scanout or non-scanout
tranches. So instead of assuming that the first respective tranche
contains the format/modifier we're looking for, check all tranches.

While on it, make sure that in case a compositor sends scanout
tranches on the initial feedback, `pick_format_from_scanout_tranche()`
does not unintentionally pick `INITIAL_BUFFER_FORMAT`.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-23 13:21:38 +00:00
Daniel Stone a55bd6798e clients: Delete gears
It doesn't and can't build, because it depends on cairo-gl. We already
have simple-egl which shows how to use EGL/GLESv2 on Wayland.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-23 13:45:57 +01:00
Daniel Stone dfaba9f107 gl-renderer: Use common value for maximum plane index
Most everything else only supports 3 planes, and we don't support any
four-plane YUV formats, so.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone c3d84293b9 gl-renderer: Fix plane count for legacy YUV420 images
It's three planes, not two.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: 8b167a1703 ("gl-renderer: Store EGL buffer state in weston_buffer")
2022-05-20 11:24:41 +00:00
Daniel Stone f36d77a199 gl-renderer: Don't use TEXTURE_EXTERNAL for multi-planar formats
There's just no good reason to do this.

The query entrypoints already tell us if we need to use
GL_TEXTURE_EXTERNAL_OES for a particular format/modifier. We also have
RGB -> YUV fallbacks which should be able to work well with TEXTURE_2D.

TEXTURE_EXTERNAL pessimises quite hard, forcing GPU-side reloads as well
as bad filtering. Allowing multi-planar formats to use TEXTURE_2D should
thus result in performance and quality improvements.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 67fc71214d gl-renderer: Add comment for yuv_format_descriptor
Try to describe this and yuv_plane_descriptor as well, since they're not
blindingly obvious.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 18a31a6af8 gl-renderer: Remove special-cased YUV SHM formats
Now that we can pull everything we need from pixel-formats, go one step
further and reuse the same YUV format descriptors we use to emulate
dmabuf/EGLImage imports for SHM.

This eliminates all special-case YUV/SHM handling.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 1a86963d51 gl-renderer: Get YUV subsampling from pixel-formats
We already have the subsampling levels in pixel-formats - no need to
type it out again here.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 1654813903 gl-renderer: Get YUV plane count from pixel-formats
We already have this elsewhere.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 727c4ef6fb pixel-formats: Add R8 and GR88
These formats are used within gl-renderer to do YUV -> RGB colourspace
conversion.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 1db2fbef61 pixel-formats: Add internal-only format flag
Add a new hide_from_clients flag which, if set, specifies that the
format is only for internal information and processing, and should not
be advertised for clients.

This will be used for formats like R8 and GR88, which are not useful for
client buffers, but are used internally to implement YUV -> RGB
conversion.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 32ee42d261 gl-renderer: Remove useless texture_type enum
This was just a duplicate of shader variants, for historical reasons.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 820f3ae866 gl-renderer: Add support for WL_SHM_FORMAT_YUV444
We support this as an explicit YUV fallback path in gl-renderer's dmabuf
EGLImage import path, so might as well support it in the SHM path, given
it's just YUV420 with no subsampling.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone c2cfadfce9 gl-renderer: Use hsub and vsub from pixel-formats
No need to open-code everything here.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 742f10f32c gl-renderer: Use vsub for y offset in SHM
If we're doing partial uploads from SHM buffers, we need to use the
vertical subsampling factor rather than the horizontal for secondary
planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 4161948da9 pixel-formats: Add hsub and vsub helpers
We already had these with effective width and height, but they're useful
externally as well. Pull them out to a helper.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone e08df66bd3 gl-renderer: Use pixel-formats data for RGB formats
No need to open-code bits per pixel and shader variants.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 2ade128ae2 pixel-formats: Fill in bpp everywhere
Doing this allows us to get rid of some open-coded per-format
calculations inside gl-renderer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone c54eace91d pixel-formats: Rename addfb_legacy_depth
'depth' isn't actually used to determine the bit depth of meaningful
components generally, but specifically to determine whether we can use
the legacy drmModeAddFB (pre-AddFB2) with those formats.

Rename the member to make it more clear what it's used for.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone d37d73a9a0 gl-renderer: Use DRM format codes instead of SHM
Since the buffer now has a pixel_format hook, just use that consistently
instead of the SHM code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 2c40260397 gl-renderer: Remove unsupported-SHM-format fallback
Clients can't reach this because libwayland-server already checks
whether the format is supported.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone badd774c28 gl-renderer: Use pixel-formats GL format for single-planar formats
pixel-formats already stores the gl_format, at least for single-planar
formats; use that instead of storing our own copies.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 38f933dd46 gl-renderer: Move GL compatibility workarounds out of per-format
Instead of checking for each format whether we need compatibility
workarounds for GL implementations not supporting ES3.x or when
GL_EXT_texture_rg isn't present, have each format declare the ideal case
and fix it up later.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 2e6827d70e gl-renderer: Ensure SHM buffer format stays the same
Rather than checking all the pixel-format components which are currently
duplicated inside gl-renderer, just check for equality of the pixel
format itself, which will become useful as we remove some of the
duplicate content.

This means that the texture storage will now be reallocated when clients
switch between pixel formats which could've had compatible GL storage
(e.g. XRGB <-> ARGB) on the same surface. However this does not seem
like a case worth optimising, and simplifies the code somewhat.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone d696f8df1f gl-renderer: Use ARRAY_COPY for buffer state
We've got a nice shiny ARRAY_COPY macro, so use it rather than memcpy or
hand-unrolled assignments.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Daniel Stone 89d0d90306 pixel-formats: Add GL types for 16bpc formats
Carried over from gl-renderer's equivalent code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Hideyuki Nagase 297ad403d6 rdp: Add clipboard redirection support
Allow clipboard pasting in and out of an RDP session.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-05-19 14:31:59 +00:00
Hideyuki Nagase 252771d9aa rdp: add virtual channel support
RDP exposes certain features (audio, clipboard, RAIL) through a facility
called "virtual channels". Set up the communications framework for using
these.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-05-19 14:31:59 +00:00
Hideyuki Nagase 3bdc29b934 rdp: Add cross thread work queues
FreeRDP has some features that start new threads and run
callback functions in them.

We need a way to punt work from these threads back to the
compositor thread.

Co-authored-by: Steve Pronovost <spronovo@microsoft.com>
Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com>
Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com>
Signed-off-by: Steve Pronovost <spronovo@microsoft.com>
Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
2022-05-19 14:31:59 +00:00
Pekka Paalanen e884e7c7b8 gl_renderer: log EGL features
Log EGL features similar to how GL ES features are logged: listing just
the ones weston tests for.

This replaces some log messages from gl-renderer.c that become
redundant or belong with EGL better.

has_native_fence_sync and has_wait_sync are not logged, because missing
them already logs warnings.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 14:18:53 +03:00
Pekka Paalanen 2f115047de gl-renderer: log rendering device
Feels like this might be nice to log.

The failure case is not fatal, so say it's a warning only.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 14:18:53 +03:00
Pekka Paalanen f3bf7a0d5a gl-renderer: add error messages for missing EGL platforms
Found by inspection, looks like these cases could use an explicit error
message.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 14:18:53 +03:00
Pekka Paalanen b383f52d31 gl_renderer: print more GL ES feature flags
This is a human readable replacement for printing out the list of all
available GL extensions that doesn't happen anymore by default.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 14:18:53 +03:00
Pekka Paalanen 092115786e gl-renderer: move extension lists away from log
Print all EGL and OpenGL extension lists into a new log scope
"gl-renderer" instead of the usual log.

These lists cluttered the log while they were very rarely actually
useful. Sometimes they might be interesting, so make them still
available through the new log scope.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 13:45:53 +03:00
Pekka Paalanen ccb0d4f7ce gl-renderer: pass gr to gl_renderer_log_extensions()
Plumb struct gl_renderer all the way through to
gl_renderer_log_extensions(). In the future, the extension lists will be
printed into a debug scope specifically, and it will get the debug scope
from gr.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-18 13:45:53 +03:00
Marius Vlad 2327daf96b desktop-shell: Handle weston_curtain destruction
This fixes the following leaks for
weston_curtain/weston_buffer_create_solid_rgba when shutting down the
compositor:

        #0 0x7f9170372987 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f915bfeb8b7 in zalloc ../include/libweston/zalloc.h:38
        #2 0x7f915bfec71d in weston_curtain_create ../shell-utils/shell-utils.c:150
        #3 0x7f915bfd9e51 in shell_ensure_fullscreen_black_view ../desktop-shell/shell.c:2082
        #4 0x7f915bfda2a9 in shell_configure_fullscreen ../desktop-shell/shell.c:2118
        #5 0x7f915bfdc72d in desktop_surface_committed ../desktop-shell/shell.c:2538
        #6 0x7f915bfa3ef5 in weston_desktop_api_committed ../libweston-desktop/libweston-desktop.c:159
        #7 0x7f915bfae778 in weston_desktop_xdg_toplevel_committed ../libweston-desktop/xdg-shell.c:746
        #8 0x7f915bfb0d45 in weston_desktop_xdg_surface_committed ../libweston-desktop/xdg-shell.c:1374
        #9 0x7f915bfa7382 in weston_desktop_surface_surface_committed ../libweston-desktop/surface.c:174
        #10 0x7f916fe628a6 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
        #11 0x7f916fe7c0e2 in weston_surface_commit_state ../libweston/compositor.c:4062
        #12 0x7f916fe7c161 in weston_surface_commit ../libweston/compositor.c:4068
        #13 0x7f916fe7c6ef in surface_commit ../libweston/compositor.c:4146
        #14 0x7f916fc847e9  (/usr/lib/x86_64-linux-gnu/libffi.so.8+0x77e9)

        #0 0x7f9170372987 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x7f916fe62aa3 in zalloc ../include/libweston/zalloc.h:38
        #2 0x7f916fe7398d in weston_buffer_create_solid_rgba ../libweston/compositor.c:2603
        #3 0x7f915bfec879 in weston_curtain_create ../shell-utils/shell-utils.c:162
        #4 0x7f915bfd9e51 in shell_ensure_fullscreen_black_view ../desktop-shell/shell.c:2082
        #5 0x7f915bfda2a9 in shell_configure_fullscreen ../desktop-shell/shell.c:2118
        #6 0x7f915bfdc72d in desktop_surface_committed ../desktop-shell/shell.c:2538
        #7 0x7f915bfa3ef5 in weston_desktop_api_committed ../libweston-desktop/libweston-desktop.c:159
        #8 0x7f915bfae778 in weston_desktop_xdg_toplevel_committed ../libweston-desktop/xdg-shell.c:746
        #9 0x7f915bfb0d45 in weston_desktop_xdg_surface_committed ../libweston-desktop/xdg-shell.c:1374
        #10 0x7f915bfa7382 in weston_desktop_surface_surface_committed ../libweston-desktop/surface.c:174
        #11 0x7f916fe628a6 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
        #12 0x7f916fe7c0e2 in weston_surface_commit_state ../libweston/compositor.c:4062
        #13 0x7f916fe7c161 in weston_surface_commit ../libweston/compositor.c:4068
        #14 0x7f916fe7c6ef in surface_commit ../libweston/compositor.c:4146
        #15 0x7f916fc847e9  (/usr/lib/x86_64-linux-gnu/libffi.so.8+0x77e9)

We do not migrate the weston_curtain destruction from
desktop_surface_removed() to desktop_shell_destroy_surface() because
we'd want have the curtain removed before the animation starts.

If we were to move the black view destruction, *and* only handle it from
desktop_shell_destroy_surface() the animation runs but the black curtain
will be removed right at the end, effectively diminishing the effect of
the animations.

To this end, we keep both of the two worlds, if the client terminates on
its own, we keep the same animation effect, but if the compositor is
shutting down we destroy it immediately.

We remove wl_list_for_each_safe() and instead loop each time to avoid
using a stale pointer iterator which could cause a UAF as the shsurf
would be free'ed.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-18 09:46:37 +03:00
Daniel Stone 4815936630 gl-renderer: Allocate textures per-buffer, not per-surface
Now that the gl_buffer_state owns everything related to buffers, move
the textures from there rather than living on the surface, to join the
EGLImage and/or SHM params.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 62c0f1621c gl-renderer: Delete egl_image wrapper
Now that EGLImages are strongly associated with a gl_buffer_state, which
has a lifetime strictly bounded by a weston_buffer, we don't need to
have an egl_image wrapper having its own separate refcounting anymore.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 3297d10287 gl-renderer: Cache gl_buffer_state on the weston_buffer
... apart from SHM.

EGL and dmabuf buffers already have a gl_buffer_state created for them
when we first attach the weston_buffer. By turning
gl_surface_state::buffer into a pointer, we can just reference rather
than inline the gl_buffer_state.

SHM buffers are special, in that we don't keep individual copies of them
within the GL renderer. Instead, the GL surface has a texture allocated
with a shadow copy of the most up-to-date surface content. Handle this
by allocating and destroying gl_buffer_state every time we need to
respecify textures or somehow meaningfully change the parameters.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone acc3762506 gl-renderer: Store dmabuf buffer state in weston_buffer
Similarly to EGL buffers, store the gl_buffer_state for a dmabuf buffer
inside weston_buffer, rather than on the linux_dmabuf_buffer. This
slightly simplifies our gl_buffer_state handling, and will be used later
to eliminate the egl_image refcounting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 56dc4b8aaa gl-renderer: Remove unused dmabuf import_type
We don't need this now we don't try to reimport them on attach.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 8b167a1703 gl-renderer: Store EGL buffer state in weston_buffer
Introduce a renderer_private hook for weston_buffer, and use this to
store a copy of the gl_buffer_state for EGL buffers (i.e. non-dmabuf, via
EGL_WL_bind_wayland_display).

As part of this, we create the EGLImage along with the weston_buffer
information, and just take a reference to it each time it is attached.
If you have bisected a failure to update surface content to this commit,
it very likely means that your EGL implementation requires images to be
recreated rather than only rebound in order to have their content
updated, which is contrary to specification.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 8544a4d09b weston_buffer: Move direct_display out of gl-renderer
Just make it a generic buffer attribute, not hidden away in GL.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 57c34139d3 gl-renderer: Don't modify buffer_state in attach
At the moment, attach_shm() will modify the gl_buffer_state in place,
then compare it and see if it differs enough to require a new one. That
rather mixes up the old and new worlds, so quite explicitly build up a
shadow gl_buffer_state with variables first before we change the one
which already exists.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone c9253c0012 renderer: Set surface->is_opaque in the core
No need for the renderers to do this now that we know what all of the
formats are.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:42 +01:00
Daniel Stone 193de3c2cf renderer: Remove get_content_size hook
Now that we can reliably access buffer dimensions from weston_buffer,
and gl-renderer isn't doing strange things with buffer widths, just use
that. The renderer interface is now unused and can be deleted.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:41 +01:00