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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
In commit "libweston: add struct weston_drm_format" we've added an API
to store and manage DRM formats and modifiers. As it has a couple of set
operations that are not so obvious, this adds unit tests to ensure
correctness. In the future we may expand this API and also improve
performance, so it is important to have this.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
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>
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>
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>
Predictably, there was one thing I forgot with !600, which was to fix up
the CI rules for the transition. Oops.
Signed-off-by: Daniel Stone <daniels@collabora.com>
While the commonly used Weston launchers are weston-launch and launcher-logind,
the direct backend was used in CI out of convenience, and due to logind being a
bit cumbersome to get to work in a CI environment.
The new libseat launcher can be used with seatd as well as logind. seatd is easy
to start in a CI environment, allowing us to test the libseat launcher codepath
instead of the less user relevant direct launcher.
This also prepares us for the future intended removal of non-libseat launchers.
Signed-off-by: Kenny Levinsen <kl@kl.wtf>
Most of our stages take just a single minute to complete, while the standard
timeout on gitlab CI is 60 minutes.
Set a 5 minute timeout on quick stages, and a 30 minute timeout on the image
build step to ensure we fail fast and don't tie up CI resources.
Signed-off-by: Kenny Levinsen <kl@kl.wtf>
The standard style of LCOV HTML reports is a bit harsh to look at. This
commit replaces it with a new one.
The new CSS was written from scratch by looking at the HTML source code
of a generated LCOV report. The original gcov.css file was not used.
The color scheme is neutral, trying to avoid a Christmas tree effect.
The colors are intended to be calm while also distinguishable, and not
hamper text readability.
The font lists were taken from Gitlab with the hope that it will blend
in a little better when viewing from MR artifacts.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This installs libseat in the debian image build from source in order to enable,
build and test weston with libseat support.
Signed-off-by: Kenny Levinsen <kl@kl.wtf>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
These functions are related to shaders, so they are more at home in
gl-shaders.c. gl-renderer.c is too long already.
This allows making a couple functions static while the moved functions
become non-static. Future changes turn some of these functions into
static again, with the ultimate goal of making struct gl_shader opaque.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
desktop-shell's client is able to read-up from the config file, [shell]
section the background, but for kiosk-shell we don't actually have
client that does that, so instead allow the shell do that directly.
Seems to be a useful thing to have, as a default background color.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When using xwayland surfaces and multiple outputs we need to notify
xwayland surface that the surface position has changed, otherwise we're
going to end up with pop-ups being displayed on other outputs rather
than the one were the main surface resides.
Stolen from desktop-shell.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Tearing down the drm-backend when there are no input devices, would call
for the gbm device destruction before compositor shutdown. The latter
would call into the renderer detroy function and assume that the
EGLDisplay, which was created using the before-mentioned gbm device, is
still available. This patch re-orders the gbm destruction after the
compositor shutdown when no one would make use of it.
Fixes: #314
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
This allows to specify a custom DRM format. For instance, to test
XBGR2101010:
weston-simple-dmabuf-egl -f 0x30334258
Signed-off-by: Simon Ser <contact@emersion.fr>
This used a cargo-culted form of the ACTION check. Kernel is allowed to
invent new ACTIONs and IIRC there are already actions like bind and
unbind.
Udev events before rule processing always start with a clean property
list. This means that if you only match ACTION==add to add some value to
the event, then that value will not be present for ACTION==bind. Udev
event consumers do not accumulate values, so inconsistent value setting
may confuse them.
Therefore one needs to match ACTION!=remove, not ACTION==add|change, to
keep the device properties consistent for every event. It doesn't hurt
to set them on remove either, but it's a habit to try to avoid
processing when not strictly needed.
This issue came up in
https://gitlab.freedesktop.org/wayland/weston/-/issues/476#note_841430
For more information, see
https://lists.freedesktop.org/archives/systemd-devel/2020-November/045570.html
the part "KERNEL API INCOMPATIBILITY" near the beginning.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Since commit "libweston: add required_capabilities test suite quirk"
a new function that depends on test_data is being called in wet_main().
We should check if test_data is NULL before calling it, otherwise
we have a segfault when running outside the test suite.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In CI we should never get a skip, so turn them into failures to make
sure we notice.
This is enabled only for the configuration where we build everything. If
anything is disabled, skips are expected.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This will be useful in CI, where we do not want to see any skips. If
something starts to skip, that's a mistake somewhere, and want to catch
it.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
There is no case in pre-processor directives where would like to have
undefined identifiers be silently replaced with a zero. This warning can
discover typos and forgotten includes.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Everywhere else uses #ifdef, this used just #if. When the next commit
adds -Wundef to the compiler options, this #if here will start failing
as ENABLE_EGL is undefined.
It would be much better to use Meson's set10() for ENABLE_EGL and change
all #ifdef into #if, but I opted for the smaller change for now.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Code is using the form
#if ENABLE_JUNIT_XML
which is fine until we start using -Wundef. I think the existing code
would fail or at least warn if you disabled test-junit-xml with -Wundef.
Make sure ENABLE_JUNIT_XML is always defined so that -Wundef can be
added to build flags.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
If the compositor does not have the shadow buffer capability (implied by
the color ops capability bit), then trying to run the shadow buffer test
is useless, it would just fail. Let it skip instead.
Fixes: b1e56143c5
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This allows tests to skip when required capabilities are not present.
The output damage test for the shadow buffer case needs this.
required_capabilities is added to struct weston_testsuite_quirks which
is libweston public API just because there is no better place currently.
This is a little weird because the code to check it is in compositor,
not libweston.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The capability strings will be printed also in another occasion, where
the colon does not fit with the capability description.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This should not be necessary, but my testing with fd.o Gitlab 13.9.1
shows this is needed. Otherwise the coverage markings will not appear in
a MR diff view.
Apparently Gitlab has some problem with 'filename' attribute containing
"../" in Cobertura XML files, even when that does result in a correct
path. Or maybe the problem is is with the <source> path referring to the
build dir which from Gitlab perspective does not exist in the project,
even though builddir/../ is a good path.
This sed hack removes the "../" part and the last element in the
<source> path correspondingly.
See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/567
for my testing.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>