Commit Graph

1073 Commits

Author SHA1 Message Date
Igor Matheus Andrade Torrente
bfcb1adc14 backend-drm: Drop support to non universal plane drivers
Remove all the backend code to support drivers without universal planes.

From[1]:

"The code needed to support kernels where DRM does not support uiniversal
planes makes the DRM-backend a little more complicated, because it needs
to create fake planes for primary and cursor. The lifetimes of the fake
planes does not match the lifetime of "proper" planes, which is surprising."

And since the universal planes left the experimetal flag in 2014[2] it is
safe to remove the support now.

[1] https://gitlab.freedesktop.org/wayland/weston/-/issues/427
[2] https://cgit.freedesktop.org/drm/drm-tip/commit/?id=c7dbc6c9ae5c3baa3be755a228a349374d043b5b

Signed-off-by: Igor Matheus Andrade Torrente <igormtorrente@gmail.com>
2021-06-01 17:25:20 +00:00
Samu Nuutamo
58a2faf716 libinput-seat: update leds when a new device is added
Fix an issue where the keyboard leds will go out of sync when a new
keyboard is connected.

The issue can be easily reproduced by connecting two keyboards, enabling
caps lock, and reconnecting one of the keyboards. Without the patch the
leds on both keyboards will turn off while the actual caps lock state
will stay enabled.

Signed-off-by: Samu Nuutamo <samu.nuutamo@gmail.com>
2021-05-31 11:31:22 +00:00
Lujin Wang
d4b46cdd3c libweston: Remove source repaint_timer in weston_compositor_shutdown
Fixes a definitely lost:
== 56 bytes in 1 blocks are definitely lost in loss record 16 of 45
==    at 0x48450F8: malloc (vg_replace_malloc.c:309)
==    by 0x4B55E93: wl_event_loop_add_timer (event-loop.c:197)
==    by 0x4126CF: weston_compositor_create (in /usr/local/bin/weston)
==    by 0x409997: main (in /usr/local/bin/weston)

Signed-off-by: Lujin Wang <luwang@nvidia.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Pekka Paalanen
8740037a93 libweston: add weston_layer_fini()
Layers did not have a fini sequence before, which means the compositor
layer list might have stale pointers temporarily when shutting down. A
bigger problem might be having views linger after the destruction of the
layer.

These problems were not observed yet, but if they exist, this patch
should help to find them and then fix them.

The check in weston_compositor_shutdown() is not an assert yet, because
it will trigger until all components call weston_layer_fini() correctly.
Some components do not even have a tear-down function to call it from at
all, like fullscreen-shell.

The same with the check in weston_layer_fini().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-28 13:38:28 +03:00
Pekka Paalanen
6551c09d63 libweston: comment places that cannot use paint node lists
These are all the remaining places that still use the global view_list,
and cannot avoid it. Add a comment to explain why in each.

Now all places that use view_list have been audited for paint node
lists.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:06:21 +03:00
Pekka Paalanen
aa2e0b2075 drm-backend: iterate paint nodes
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.

This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:06:21 +03:00
Pekka Paalanen
20ab6f88ec libweston: iterate paint nodes in accumulate damage
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.

This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:06:21 +03:00
Pekka Paalanen
6d6b36738f libweston: iterate paint nodes on output repaint
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.

This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:06:21 +03:00
Pekka Paalanen
29cdb34019 gl-renderer: iterate paint nodes
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.

This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:03:44 +03:00
Pekka Paalanen
e02dbf650b pixman-renderer: iterate paint nodes
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.

This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:03:44 +03:00
Pekka Paalanen
2fddc539c5 libweston: per-output z-ordered paint node list
This patch creates a per-output paint node list in the same z-order as
the global view_list in weston_compositor.

The next step is to switch output repaints and backends to use the
z-order list instead of view_list.

Having a per-output paint node list for repaints allows including only
those paint nodes that actually contribute to the output image, so that
completely occluded and out-of-screen views can be ignored in libweston
core already.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:03:44 +03:00
Pekka Paalanen
1a4f87dec5 libweston: introduce weston_paint_node
This new object is created for every surface-view-output triplet. As
there is always exactly one surface for a view and it does not change
during a view's lifetime, this is really for a view-output pair or a
surface-output pair.

The object is created on-demand as a part of preparing for an output
repaint, so it applies only to surfaces that are going through repaint.
A prerequisite for that is that the surface is mapped, which means it
has a mapped view.

When any one of surface or view gets destroyed or output gets disabled,
all related paint nodes are destroyed.

In future, paint node will be useful for caching surface-output or
view-output pair dependent data:
- damage regions for overlapping outputs
- color transformations
- backend-specific bookkeeping (e.g. DRM KMS plane assigments)
- per-output repaint lists
- surface geometry transformed into output space

Suggested by Daniel Stone in
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/582#note_899406

PS. The call in weston_view_destroy() to
weston_compositor_build_view_list() might be so that if the view has
sub-surfaces, rebuilding the view list removes those those too and
automagically deletes their views.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-18 14:03:44 +03:00
ahe
c76cf48f3e libweston/renderer-gl/gl-renderer.c: use glDeleteTextures() and update gs->num_textures if num_textures is decrased
Signed-off-by: ahe <Andreas.Heynig@meetwise.com>
2021-05-15 16:03:42 +00:00
Michael Olbrich
7803e83a94 wayland-backend: forward seats with the correct name
Use the real name of the seat instead of calling each seat 'default'. This makes
it easier to identify the current seat in a multi-seat environment.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-05-15 15:57:18 +00:00
Jonathan Marler
d3223cc4b4 data-device: cleanup after touch drag
This change fixes the "touch-up" operation to clear "data_source"
by setting "seat" to NULL.  This operation is done in the mouse button
release operation, but seems to have been forgotten in the "touch up"
case.

Forgetting this operation causes weston to send a "premature finish
request" error to the client which causes the client to exit.

This issue can be reproduced with the "weston-dnd" program by performing
a drag-and-drop operation with a touch input device. Once the drag
is released, the weston-dnd program will exit with an error.

Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
2021-05-15 15:54:03 +00:00
Jonathan Marler
5ba5a86a7f launcher: remove unused enum value
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
2021-05-15 15:40:24 +00:00
Daniel Stone
3d9b73c9e5 drm/state-propose: Remove unnecessary check
If sprites_are_broken, then we will only ever arrive in renderer_only
mode, so this case will be caught by the checks above.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-05-15 15:24:12 +00:00
Marius Vlad
f722dc6f08 compositor: Prevent an invalid access against content protection
Avoids an user-after-free when destroying the surface, like in the
following ASAN message:

==25180==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060000589d8 at pc 0x7ff70a4f7102 bp 0x7fff8f7e13b0 sp 0x7fff8f7e13a8
READ of size 8 at 0x6060000589d8 thread T0
    #0 0x7ff70a4f7101 in weston_schedule_surface_protection_update ../libweston/compositor.c:1163
    #1 0x7ff70a4f743b in weston_surface_update_output_mask ../libweston/compositor.c:1212
    #2 0x7ff70a4f7a47 in weston_surface_assign_output ../libweston/compositor.c:1298
    #3 0x7ff70a4f7f44 in weston_view_assign_output ../libweston/compositor.c:1348
    #4 0x7ff70a4fa12f in weston_view_update_transform ../libweston/compositor.c:1589
    #5 0x7ff70a4ffc20 in view_list_add ../libweston/compositor.c:2657
    #6 0x7ff70a5000ee in weston_compositor_build_view_list ../libweston/compositor.c:2688
    #7 0x7ff70a4fd577 in weston_view_destroy ../libweston/compositor.c:2202
    #8 0x7ff70a4fd7df in weston_surface_destroy ../libweston/compositor.c:2239
    #9 0x7ff70a4fdbb0 in destroy_surface ../libweston/compositor.c:2285
    #10 0x7ff70a4a2d3e in destroy_resource ../src/wayland-server.c:723
    #11 0x7ff70a4a8940 in for_each_helper ../src/wayland-util.c:372
    #12 0x7ff70a4a8e1f in wl_map_for_each ../src/wayland-util.c:385
    #13 0x7ff70a4a3748 in wl_client_destroy ../src/wayland-server.c:882
    #14 0x7ff6fe04e866 in shell_destroy ../desktop-shell/shell.c:5004
    #15 0x7ff70a4ee923 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
    #16 0x7ff70a51598d in weston_compositor_destroy ../libweston/compositor.c:7903
    #17 0x7ff70a903a58 in wet_main ../compositor/main.c:3493
    #18 0x560de7b3b179 in main ../compositor/executable.c:33
    #19 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
    #20 0x560de7b3b099 in _start (/home/mvlad/install-amd64/bin/weston+0x1099)

0x6060000589d8 is located 56 bytes inside of 64-byte region [0x6060000589a0,0x6060000589e0)
freed by thread T0 here:
    #0 0x7ff70a9d3b6f in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xa9b6f)
    #1 0x7ff70a5167d2 in cp_destroy_listener ../libweston/content-protection.c:193
    #2 0x7ff70a4ee923 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
    #3 0x7ff70a51598d in weston_compositor_destroy ../libweston/compositor.c:7903
    #4 0x7ff70a903a58 in wet_main ../compositor/main.c:3493
    #5 0x560de7b3b179 in main ../compositor/executable.c:33
    #6 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308

previously allocated by thread T0 here:
    #0 0x7ff70a9d4037 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xaa037)
    #1 0x7ff70a5160aa in zalloc ../include/libweston/zalloc.h:38
    #2 0x7ff70a516cda in weston_compositor_enable_content_protection ../libweston/content-protection.c:329
    #3 0x7ff7070247e0 in drm_backend_create ../libweston/backend-drm/drm.c:3180
    #4 0x7ff707024cae in weston_backend_init ../libweston/backend-drm/drm.c:3250
    #5 0x7ff70a515d02 in weston_compositor_load_backend ../libweston/compositor.c:7999
    #6 0x7ff70a8fbcfb in load_drm_backend ../compositor/main.c:2614
    #7 0x7ff70a900b46 in load_backend ../compositor/main.c:3103
    #8 0x7ff70a902ecd in wet_main ../compositor/main.c:3380
    #9 0x560de7b3b179 in main ../compositor/executable.c:33
    #10 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: heap-use-after-free ../libweston/compositor.c:1163 in weston_schedule_surface_protection_update

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-05-12 17:51:49 +03:00
Pekka Paalanen
f48277b577 drm-backend: require DRM_CAP_TIMESTAMP_MONOTONIC
Weston internals and Wayland clients assume that output presentation
clock cannot go backwards. Therefore require unconditionally that KMS
uses the monotonic clock.

The kernel unconditionally supports DRM_CAP_TIMESTAMP_MONOTONIC. See:

commit 25e1a79874eb3821d93310c908cc0a81b47af060
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Oct 11 17:20:13 2017 +0200

    drm: vblank: remove drm_timestamp_monotonic parameter

That one removed the final possibility of DRM_CAP_TIMESTAMP_MONOTONIC
being false, by removing the module option. But even before that, all
drivers have been supporting monotonic, since

commit c61eef726a78ae77b6ce223d01ea2130f465fe5c
Author: Imre Deak <imre.deak@intel.com>
Date:   Tue Oct 23 18:53:26 2012 +0000

    drm: add support for monotonic vblank timestamps

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-11 09:07:46 +00:00
Pekka Paalanen
1ae3a25642 libweston: choose only monotonic software presentation clocks
This drops the software presentation clocks that could jump backwards.

See the previous commit "libweston: assert frame times never go
backwards" for the rationale.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-11 09:07:46 +00:00
Pekka Paalanen
98b4e20a68 libweston: assert frame times never go backwards
Adding this check was prompted by
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/609

There is no reason to allow frame times jump backwards, and apparently
we already have code that makes that assumption.

DRM KMS uses CLOCK_MONOTONIC as the vblank and page flip timestamps,
which by definition cannot go backwards. Other backends call
weston_compositor_set_presentation_clock_software().

Frame times are also reported directly to Wayland clients via
presentation-time extension, and clients too will not expect that the
timestamp could go backwards.

So make sure time can never go backwards.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-11 09:07:46 +00:00
Marius Vlad
bc7c8332df backend-wayland: Avoid spinning forever if dispatching failed
As observed in #420 (Running Weston under Weston's kiosk shell with
multiple outputs causes the scrollback to go nuts), not
being able to cope with (a correct) resize of the parent surface would
cause the client weston instance to spin forever.  If dispatching
failed, just exit.

Fixes #420

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-05-10 12:01:46 +00:00
Marius Vlad
529fae91f7 backend-wayland: Avoid iterating over un-intialized lists
As an in-flight resize call might cause a call to
wayland_output_destroy_shm_buffers() to go over a list of free_buffers
list. Just initialize the lists before attempting to create the parent
surface to avoid it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-05-10 12:01:46 +00:00
Bastian Krause
d8b861766c backend-drm/state-propose: print format instead of *pixel_format_info address
fb->format is *pixel_format_info, whereas fb->format->format is the
actual DRM/wl_shm format code we want to see here. Fix the drm_debug()
call accordingly.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
2021-05-06 14:12:32 +02:00
Leandro Ribeiro
b4cf450ce1 shared/helpers: use ARRAY_COPY where possible
In "backend-drm: simplify compile time array copy", ARRAY_COPY was
introduced to be used by the DRM-backend.

In this patch we expand its usage to other code where hardcoded arrays
are being copied.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-28 12:17:24 -03:00
Leandro Ribeiro
3193ab5807 backend-drm: simplify compile time array copy
In drm_fb_get_from_dmabuf() we have some compile time array copies, and
multiple static_assert() calls are needed (for safety). This makes the
code unpleasant to read.

Add ARRAY_COPY macro, to simplify the code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:00:38 -03:00
Leandro Ribeiro
bdb37b30b3 gl-renderer: always add DRM_FORMAT_MOD_INVALID to EGL formats
EGL implementations have no way to tell that implicit modifiers are not
supported. So Weston must consider that implicit modifiers are
supported. Always add DRM_FORMAT_MOD_INVALID to formats that we query
from EGL.

The implication is that clients using dmabuf extension may pick
DRM_FORMAT_MOD_INVALID to allocate their buffers, and so these buffers
will not be directly imported to KMS and placed in planes. See commit
"backend-drm: do not import dmabuf buffers with no modifiers to KMS" for
more details.

But we should not avoid advertising DRM_FORMAT_MOD_INVALID in the dmabuf
protocol just because we hope that the client don't choose it, it's not
our choice.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
1b403263d4 gl-renderer: do not expose query_dmabuf_formats and query_dmabuf_modifiers
In commit "libweston: add struct weston_drm_format" struct
weston_drm_format and its helper functions were added to libweston.

The functions query_dmabuf_formats and query_dmabuf_modifiers are very
specific to GL-renderer and its internals. So instead of exposing them
in libweston, query and store DRM formats and modifiers internally in
GL-renderer. Also, add a vfunction to struct weston_renderer in order
to retrieve the formats.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
a5560d6dbe backend-drm: document that we allow to import wl_drm buffers to KMS with no modifiers
In commit "backend-drm: do not import dmabuf buffers with no modifiers
to KMS" we've stopped to import dmabuf with no modifiers to KMS.

In this patch we document why we can still import wl_drm buffers with no
modifiers to KMS.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
5aea1bc522 backend-drm: do not import dmabuf buffers with no modifiers to KMS
We can't tell the layout of a buffer that has been allocated with no
modifiers. Although usually drivers use linear layouts to allocate in
these cases, it is not a rule. It can use a tiling layout, for instance,
under the hood.

So it is not safe to import a buffer with no modifiers to KMS, as it
can't tell the buffer layout and this may result in garbage being
displayed. In this patch we start to require explicit modifiers to
import buffers to KMS.

In most cases things just work as expected, but just because both sides
(display and render driver) usually end up using the linear layout when
modifiers are not exposed. It also works on systems where the display
and render devices are tied (desktops with Intel or AMD, for instance),
as there's only one driver and it knows the layout of the buffer (no
need to guess).

But in SoC's where the display and render device are split, things can
go wrong. It is better to lose performance and not break things. To
solve the problem, drivers should be updated to expose modifiers (even
if only DRM_FORMAT_MOD_LINEAR), as the concept of implicit modifiers is
the root of the problem.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
98101e88cc backend-drm: ignore formats without modifiers from IN_FORMATS
In commit "backend-drm: add DRM_FORMAT_MOD_INVALID to modifier sets when
no modifiers are supported" we've changed the code that iterates through
the IN_FORMATS blob property. Now it adds DRM_FORMAT_MOD_INVALID for
formats exposed without modifiers.

But the thing is that there shouldn't be formats in the IN_FORMATS blob
exposed without modifiers, as the blob has been added after the
introduction of the explicit modifiers API in the kernel. For now,
there's nothing in the kernel to ensure this correct behavior. So
instead of adding DRM_FORMAT_MOD_INVALID in this case, ignore these
formats, as userspace can't do much in this case.

In the future this may be fixed by the kernel. Or maybe the following MR
in libdrm, which adds an iterator API for the IN_FORMATS blob:

https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
567cc92797 backend-drm: add DRM_FORMAT_MOD_INVALID to modifier sets when no modifiers are supported
From now on, when we can't know the modifiers supported for a certain
format, we add DRM_FORMAT_MOD_INVALID to its modifier set.

There is some parts where nothing is being added an others where
DRM_FORMAT_MOD_LINEAR is being added, so fix them.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
f767302729 backend-drm: fix slightly wrong comment about allocating with no modifiers
In create_gbm_surface() we may allocate with no modifiers in the
following situations:

1. old GBM version, so HAVE_GBM_MODIFIERS is false;
2. the KMS driver does not support modifiers;
3. if allocating with modifiers failed, what can happen when the KMS
   display device supports modifiers but the GBM driver does not, e.g.
   the old i915 Mesa driver.

The comment was only stating the third situation, so add the other two.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
3459bad63d backend-drm: move code that creates gbm surface to a separate function
The function drm_output_init_egl() is too big, so move the code to
create the gbm surface to a separate function: create_gbm_surface().

Also made some minor style changes to the code that has been moved, in
order to improve readability.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Scott Anderson
7466309c12 backend-drm: start to use weston_drm_format in drm_plane
In commit "libweston: add struct weston_drm_format" struct
weston_drm_format and its helper functions were added to libweston.
Also, unit tests for this API have been added in commit "tests: add unit
tests for struct weston_drm_format".

Start to use this API in the DRM-backend, as it enhances the code by
avoiding repetition and ensuring correctness.

Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Co-authored-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
78f01927b6 libweston: add struct weston_drm_format
Add struct weston_drm_format, which contains a DRM format and a list of
modifiers. The patch also adds struct weston_drm_format_array and some
helper functions to handle these two new structs: init/fini, find
elements, add elements, etc.

This will be useful in the next commits in which we add support to
dmabuf-hints. It also allows a cleanup in the DRM-backend, where we
currently have a similar struct in drm_plane but with no helper
functions, so the code to handle it is scattered throughout the
functions and there is a lot of repetition.

This patch is based on previous work of Scott Anderson (@ascent).

Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
4b5df8b39f backend-drm: move check that skips cursor planes for views that don't use wl_shm buffer
In drm_output_prepare_plane_view() we iterate the list of planes and add
them as candidates to promote the view to one of them.

Cursor planes do not support buffers other than wl_shm (at least for
now). So when we have a dmabuf or an EGL buffer in the view, the
function drm_output_plane_cursor_has_valid_format() returns false and
the cursor plane is not added to the candidate list.

In this patch we move the responsibility of doing this from
drm_output_plane_cursor_has_valid_format() to
drm_output_prepare_plane_view() itself, as the incompatibility between
other types of buffers and cursor planes is different from the
incompatibility between formats. This makes the code easier to read
and also documents the current incompatibility between cursor planes
and buffers that are not created through wl_shm.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Leandro Ribeiro
2984f36c72 backend-drm: set plane format to gbm_format at the appropriate time
In the absence of universal planes support,
drm_output_find_special_plane() sets the plane format to zero as a
placeholder. Then in drm_output_init_planes() it sets the format to
output->gbm_format.

As output->gbm_format is already set by the time we call
drm_output_find_special_plane(), simply set the plane format to it
directly in this function. This makes the code clearer, as there is no
reason to use the placeholder.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-04-27 19:56:38 +00:00
Kenny Levinsen
97d421a7e8 libweston/launcher: Allow VT switch without get_vt
get_vt is used to check if VTs are enabled, by verifying that a VT greater than
0 is returned.

libseat always implements switching, with switch to an active session
currently being a noop in all backends. libseat does not currently have
a get_vt implementation. Make get_vt errors more explicit, and allow VT
switching anyway if the error is ENOSYS.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2021-04-14 09:22:17 +00:00
Kenny Levinsen
6c4a993a99 libweston/launcher: libseat backend
This adds support for libseat as a seat backend. libseat provides seatd,
(e)logind and direct seat backends as compile-time and runtime options.

The backend is currently disabled by default. It can be enabled through the
launcher-libseat option.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
2021-04-14 09:22:17 +00:00
Jonathan Marler
669d5737fa launcher: remove unused field
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
2021-04-12 08:03:42 -06:00
Marius Vlad
7a465d855e backend-drm/state-propose: Check the surface buffer dimensions for cursor case
In some situations, like positioning a sub-surface that exceeds the
output's dimensions we would adjust the plane state dimensions to some
lower values to that of the buffer. That would ultimately trip the cursor
update function because the buffer itself actually exceeds the maximum
size/dimension of the cursor.

The plane state destination co-ordinates is the area of the view which
is visible on the output, which in some situations, would actually be
smaller than the original buffer dimensions (making it so that it will
pass the cropping/scaling check), but depending on of
how large is the surface buffer, it would tripping the assert wrt to
cursor width/height dimensions.

This hasn't been seen so far due to the fact that until recently we had
a cursor surface that always reached the cursor plane and that was
already being set-up by default (with desktop-shell, which is no longer
the case), and also because kiosk-shell, which doesn't set-up a cursor
surface, was not available.

This adds a check to skip placing the view in the cursor plane if the
buffer dimensions exceed the cursor permitted width/height.
(Suggested-by Daniel Stone).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-04-10 23:03:23 +00:00
Jonathan Marler
f153c49430 launcher: fix socket message race condition
fixes issue #484 (race condition with message to/from weston launch)

The race condition occurs after weston sends the WESTON_LAUNCHER_OPEN
message to weston-launch.  The race is between when weston-launch replies
with the fd handle versus weston-launch sending an activation message.  If
weston-launch sends an activation message before sending the fd handle,
then weston will be in an invalid state.

To fix this, I modified the fd handle reply that weston-launch sends to
include a message id at the beginning, which I called
WESTON_LAUNCHER_OPEN_REPLY.  Along with this, weston now inspects the
first part of any reply to determine whether it is an activation message
or a reply to the OPEN message.  In the newly handled case that it's an
activation message, it tracks whether the latest result is a deactivate
message and stores it in a flag to be handled once the open function has
completed.

Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
2021-04-10 22:29:30 +00:00
Pekka Paalanen
55f334cfdf gl-renderer: add note about fallback shader color
Now that pieces of color management implementation start to land, the
fallback shader becomes even more special than before. It is the only
case where the compositor ignores color management.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
0e1ddc4759 gl-renderer: remove redundant 'target'
The texture target can be uniquely inferred from the shader variant, so
do not store texture target separately.

Shortens the code a bit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
3ddcf07b4c gl-renderer: gl_surface_state has only shader_variant
Replace the shader_requirements with just shader_variant. The variant is
the only thing gl_surface_state will actually carry. All the other
requirements fields are always unused.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
0f52da6226 gl-renderer: rework uniform value assignments
This patch gathers all values to be loaded to shader uniforms into a new
struct gl_shader_config along with texture target and filter
information. Struct gl_shader becomes opaque outside of gl-shaders.c.
Everything that used or open-coded these are converted.

The aim is to make gl-renderer.c easier to read. Previously, uniform
values were loaded up in various places, texture units were set up in
one place, textures were bound into units in different places. Stuff was
all over the place.

Now, shader requirements and associated uniform data is stored in a
single struct. The data is loaded into a shader program in one function
only.

That makes it easy for things like maybe_censor_override() to replace
the whole config rather than poke only the shader requirements. This may
not look like much right now, but when color management adds more
uniforms and even hardcoded color need to go through the proper color
pipeline, doing things the old way would become intractable.

Similar simplification can be seen in draw_view(), where the RGBA->RGBX
override becomes more contained. There is no longer a need to "pre-load"
the shader used by triangle fan debug. Triangle fan debug no longer
needs to play tricks with saving and restoring the current shader.

The real benefit of this change will probably come when almost all
shader operations need to take color spaces into account. That means
filling in gl_shader_config parts based on a color transformation.

This is based on an idea Sebastian already used in his Weston color
management work.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
6d1a7df42f gl-renderer: move shader list destroy to gl-shaders.c
This paves way for making struct gl_shader opaque outside of
gl-shaders.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
83e4315e41 gl-renderer: pass 'gr' from draw_view()
Avoid looking up 'gr' from view->compositor by passing it explicitly
into the functions needing it.

Also fixes the whitespace in repaint_region() signature.

Clarifies code by removing local variables, but also future changes will
need 'gr' more.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
6e45fcc999 gl-renderer: move gl_renderer_send_shader_error() upwards
A future change will call this function from draw_view(), so move it
upwards to avoid adding a function declaration.

No functional or even cosmetic change.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00