Commit Graph

1512 Commits

Author SHA1 Message Date
Pekka Paalanen
c217453c85 backend-drm: forward HDR metadata
Forward the HDR Static Metadata Type 1 to the video sink. This makes the
sink aware of our video content parameters and may be able to produce a
better picture. This type of metadata is used only with the ST 2084 HDR
mode a.k.a PQ.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen
c4fedd503f backend-drm: move code to kms-color.c
This creates a new file for KMS related color code, to avoid making
drm.c even longer.

The moved code was just added in 5151f9fe9e
so the new file copyrights are written based on that.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen
ccb4c383d7 tests: add color-metadata-errors test
'color_characteristics_config_error' test ensures that all code paths in
parse_color_characteristics() and wet_output_set_color_characteristics()
get exercised.  The return value and logged error messages are checked.

Other cases test the weston_hdr_metadata_type1 validation.

These are for the sake of test coverage, but also an example of how to
test a function from main.c, and how to capture messages from
weston_log().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen
e108c1a2fe color-lcms: color characteristics into HDR metadata
This is the beginnings of creating composited content HDR metadata for
the ST2084 HDR mode. The immediate goal is to allow essentially setting
the HDR metadata from weston.ini, so that it can be experimented with.

Setting an output ICC profile will stop weston.ini metadata from taking
effect, but using an ICC profile in HDR mode is an open question anyway.

maxDML, maxCLL, and minDML are set based on the assumption that we want
to make use of the full sink/monitor dynamic range.

This also adds several TODOs about how we should handle output profiles,
basic output color characteristics, and HDR metadata. Implementing these
properly will take more thought and effort.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen
cea53a90d4 libweston: add HDR metadata to weston_output
This adds hdr_meta field in weston_output_color_outcome. This field is
intended to be set by color manager modules, and read by backends which
will send the information to the video sink in SMPTE ST 2084 mode a.k.a
Perceptual Quantizer HDR system.

Such metadata is essential in ST 2084 mode for the video sink to produce
a good picture.

The validation of the data and the group split is based on the HDR
Static Metata Type 1 definition in CTA-861-G specification.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
Pekka Paalanen
3696d9b6a1 libweston: add basic output color characteristics API
This adds color_chracteristics field in weston_output. This field is
intended to be set by compositor frontends and read by color managers.
Color managers can use this information when choosing the output color
space and dynamic range, particularly when no ICC profile has been set.

This is most useful for HDR outputs, where the HDR static metadata for
PQ mode or the display luminance parameters for HLG mode can be based on
color_characteristics.

The fields of weston_color_characteristics mirror the information
available in EDID. However, using EDID information as-is has several
caveats, so the decision to use EDID for this is left for the frontend
and ultimately to the end user.

There are no defined ranges or validity checks for this data. The color
manager will have to validate the values against whatever it is using
them for.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
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
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
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
Daniel Stone
21c65d7c9b gl-renderer: Remove gl_buffer_state.buffer_type
We can just get this from the weston_buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:25 +01:00
Daniel Stone
5fdb5fdd90 gl-renderer: Don't match texture width to input pitch
This was only used for what was presumably an attempt at an
optimisation, to force the texture's pitch in pixels to match the SHM
buffer. This is really unlikely to have ever made a difference, given
the alignments GPUs demand.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
907c9d1ffd gl-renderer: Clarify comment
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
90dbf4522d gl-renderer: Remove gl_buffer_state.y_inverted
It's just a shadow of weston_buffer.buffer_origin, which also has a
slightly more descriptive name.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
c6af9c8581 gl-renderer: Remove gl_buffer_state.height
Low-hanging fruit: just get this from the weston_buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
70874428d6 gl-renderer: Make attach_shm return early on cache hit
If we can reuse the textures we already have, just return early, rather
than putting all the work in a large indented body.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
1a65c1b8b1 gl-renderer: Shift buffer reference later in attach
Allow the various attach handlers to access the existing buffer, only
referencing the new buffer when they have successfully attached.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
77e1a04220 gl-renderer: Remove extraneous parameters from attach
The handlers can chase the details of the buffers themselves.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
0cdf576c92 gl-renderer: Convert attach to flat-return style
Deduplicate the no-buffer and the import-fail case, and try to fall
through where we can. This will make it easier to shift the buffer
reference change later, so the attach subhandlers can reference the old
buffer when checking for compatibility.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
428ae215e8 gl-renderer: Add return value to attach handlers
It's good to know if we succeeded or failed to import our buffers. This
will also later make for a more smooth transition when we start
returning a gl_buffer_state from them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
bb624754f1 gl-renderer: Don't leak EGLImages on import fail
This only happens for the legacy renderer, but still, might as well
clean up after ourselves when we can't import a secondary plane.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
4519461439 gl-renderer: Move EGL buffer error checks into attach_egl
Makes it more consistent with the others, and also easier to return
success/fail.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
8f56743590 gl-renderer: Change surface_set_color to attach_solid
No functional change.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
72fc647a96 gl-renderer: Split buffer state away from surface state
gl_surface_state has a bunch of members which are tied to the input
buffer, rather than the surface per se.

Split them out into a separate gl_buffer_state member as a first step
towards sanitising its use and lifetime.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Daniel Stone
0c65b23848 libweston: Move renderer interface to internal header
No-one should be implementing an external renderer, so move the
interface out of the public header.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-16 13:51:00 +01:00
Robert Mader
564828fb96 rdp: Silence compiler warning
This value is always `NULL`.

Silences:
`warning: ‘%s’ directive argument is null [-Wformat-overflow=]`

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-16 09:41:29 +00:00
Robert Mader
2a2eeb6a33 libweston: Silence compiler warning
Silences:
`warning: ‘fourcc’ may be used uninitialized [-Wmaybe-uninitialized]`

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-16 09:41:29 +00:00
Marius Vlad
9b0b5b57dd noop-renderer: Remove volatile and use compiler attribute
clang-13 complains about bitwise xor assigments like the following:

../libweston/noop-renderer.c:62:25: warning: variable 'unused' set but
not used [-Wunused-but-set-variable] volatile unsigned char unused = 0;

Use the __attribute__((unused)) instead.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-16 08:24:59 +00:00
Marius Vlad
bd8314078d libweston, desktop-shell: Add a wrapper for weston_surface reference
Similar to how we do it with drm_fb ref counts, increase a reference
count and return the same object.

Plug-in in desktop-shell when we map up the view in order to survive a
weston_surface destruction.

Astute readers will notice that this patch removes weston_view_destroy()
while keeping the balance between removing and adding a
weston_surface_unref() call in desktop_shell_destroy_surface().

The reason is to let weston_surface_unref() handle destruction on its
own. If multiple references are taken, then weston_surface_unref()
doesn't destroy the view, it just decreases the reference, with
a latter call to weston_surface_unref() to determine if the view
should be destroyed as well.  This situation happens if we have
close animation enabled, were we have more than one reference taken: one
when mapping the view/surface and when when the surface itself was created,
(what we call, a weak reference).

If only a single reference is taken (for instance if we don't have close
animations enabled) then this weston_surface_unref()
call is inert as that reference is not set-up, leaving libweston to
handle the view destruction.

Following that with a weston_view_destroy() explicit call would cause a
UAF as the view was previous destroyed by a weston_surface_unref() call.

A side-effect of not keeping the weston_view_destroy() call would
happen when tearing down the compositor. If close animations are enabled,
weston_surface_unref() would not destroy the view, and because
weston_view_destroy() no longer exists, we would still have the
view in the other layers by the time we check-up if layers
have views present.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:53:34 +03:00
Marius Vlad
d3ed2eb345 libweston: Assert if ref-count balance is wrong
Calling weston_surface_unref() one time too many could be a sign we
haven't correctly increased the ref count for it.

Also, if we don't have a surface being passed, do no attempt to
use it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:46:32 +03:00
Marius Vlad
0d8e94af61 libweston: Rename weston_surface_destroy() to weston_surface_unref()
Make it obvious that weston_surface has a reference counting happening
and destruction of the weston_surface happens when the last
weston_surface reference has been accounted for.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-12 16:46:31 +03:00
Robert Mader
53a221ccaa libweston/linux-dmabuf: create surface feedback on demand
Unconditionally creating a surface feedback for each surface
creates unnecessary overhead and noise in the logs. Thus
create it when the first surface feedback resource for a
surface is requested and delete it again once all those
resources have been destroyed.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-12 11:53:04 +00:00
Robert Mader
29d480813a backend-drm: Add failure reasons for failing gbm_bo_import
And add it to the list of failures triggering a resend of
dmabuf feedback scanout tranches.

Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/614

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-05-12 11:53:04 +00:00
Hideyuki Nagase
8a776be925 rdp: Add US international keyboard layout
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-09 08:56:23 -05:00
Hideyuki Nagase
e3b95f2d27 rdp: Add hebrew standard layout
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-09 08:56:23 -05:00
Pekka Paalanen
e3b6d04017 color-lcms: refactor away setup_seach_param()
To me, the use of setup_search_param() makes the code harder to
understand than it needs to be. Replacing that function with open-coding
the struct cmlcms_color_transform_search_param initialization makes it
more clear that:

- get_surface_color_transform is the only one that actually uses a
  surface to initialize it

- get_blend_to_output does not use an input profile at all

- get_sRGB_to_output and get_sRGB_to_blend hardcode the sRGB profile
  like they should

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-06 09:33:35 +00:00
Pekka Paalanen
dfba19abde color: simplify color manager API with weston_output_color_outcome
I am going to need to add yet another output property to be set by a
color manager: HDR Static Metadata Type 1. With the old color manager
API design, I would have needed to add the fourth function pointer to be
called always in the same group as the previous three. This seemed more
convoluted than it needs to be.

Therefore collapse the three existing function pointers in the API into
just one that is resposible for setting up all three things.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-06 09:33:35 +00:00
Pekka Paalanen
6c0524fd80 libweston: add struct weston_output_color_outcome
This new struct collects all the things that a color manager needs to
set up when any colorimetry aspect of an output changes. The intention
is to make the color manager API less verbose.

In this first step, the new struct is added and replaces the fields in
weston_output.

The intention is for the following color manager API changes to
dynamically allocate this structure. Unfortunately, until that actually
happens, we need a temporary way to allocate it. That is
weston_output::colorout_, which will be removed in the next patch. This
keeps the patches more palatable for review at the cost of some
back-and-forth in code changes.

This is a pure refactoring, no functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-06 09:33:35 +00:00
Pekka Paalanen
e6a9e3c4ee backend-drm: default to XRGB2101010 for HDR
Trying to do HDR with XRGB8888 is a bit like using RGB565 on SDR: you
get visible color quantization and banding in gradients (without dithering
which Weston does not implement yet, and might not work too well for HDR
anyway).

Therefore, on any HDR mode, default output framebuffer format to 10 bpc
instead of 8 bpc.

Ideally we'd also optionally try 16F or 16 bpc formats, but automatic
fallbacks for those are more complicated to arrange. You can still
configure 16F or 16 bpc manually.

This patch also moves the default format setting from
drm_output_set_gbm_format() to drm_output_enable(), because setting the
default now requires eotf_mode. Frontends may call set_gbm_format()
first and set eotf_mode next. This does create an awkward situation for
outputs that a frontend disables and re-enables. This patch here makes
sure that the old output configuration remains, but changing eotf_mode
may not change the default format. One needs to call
set_gbm_format(NULL) to re-evaluate the default format. Resetting the
format on drm_output_deinit() would lose the current setting.

DRM_FORMAT_INVALID was introduced in libdrm 2.4.95 which we already
hard-depend on.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
5151f9fe9e backend-drm: program HDR_OUTPUT_METADATA
Program the connector property HDR_OUTPUT_METADATA based on the EOTF
mode of the output.

For now, this changes only the EOTF. The colorimetry and luminance are
left undefined, to be filled in by later patches. This should still be
enough to put a video sink into HDR mode, albeit the response is
probably unknown.

drm_output keeps track of the currently existing blob id. If the blob
contents need to be re-created, this blob would be destroyed and the
field set to zero. In this patch, there is no provision for runtime
changing of HDR metadata, so there is no code doing that.

Destroying the blob at arbitrary times is not a problem, because the
kernel keeps a reference to the data as long as the blob id remains with
KMS.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
1d17e4991f backend-drm: check for HDR_OUTPUT_METADATA
Check whether HDR_OUTPUT_METADATA property exists on a KMS connector. If
yes, pretend that EDID claims support for all EOTF modes and update the
head supported EOTFs mask accordingly. If not, then only SDR is
possible.

Parsing EDID to take monitor capabilities into account is left for
later.

HDR mode cannot be set without HDR_OUTPUT_METADATA.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
6914064066 backend-drm: add HDR_OUTPUT_METADATA definitions
These are fallback definitions in case libdrm is not new enough.
They are copied from libdrm 2.4.107.

struct hdr_output_metadata defines the contents of the blob to be used
with the connector property "HDR_OUTPUT_METADATA".

This is needed for programming a HDR mode in KMS.

This headers need to be excluded from Doxygen, because Doxygen chokes on
the kerneldoc markup.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
271c11e9dc color-lcms: todo for eotf_mode
A reminder that this variable needs to be taken into account when
crafting color transformations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
46c0383c14 color-noop: supports only SDR EOTF mode
The no-op color manager will not support any other EOTF mode than SDR.
Other modes would require it to set up color transformations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
1e9b1a1047 backend-headless: support all EOTF modes
The headless backend does not display to anything, so it doesn't care
what the EOTF mode is. To allow testing compositor internal behavior,
claim to support all EOTF modes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Pekka Paalanen
5f9b68d68f libweston: introduce weston_eotf_mode
This is the switch to turn HDR mode on.

The values in the enumeration come straight from CTA-861-G standard.
Monitors advertise support for some of the HDR modes in their EDID, and
I am not aware of any other way to detect if a HDR mode actually works
or not. Different monitors may support different and multiple modes.
Different modes may look different. Therefore the high-level choice of
how to drive a HDR video sink is left for the Weston frontend to decide.

All the details like what HDR metadata to use are left for the color
manager.

This commit adds the libweston API for backends to advertise support and
for frontends to choose a mode. Backend and frontend implementations
follow in other commits.

The frontend API does not limit the EOTF mode to the supported ones to
allow experimentation and overriding EDID.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-02 12:19:24 +00:00
Marius Vlad
69a59359fa pixman-renderer: Unref the pixman image when wl_shm_buffer is gone
Even if the weston_buffer_reference is still alive in situations like
when we have closing animations, the underyling buffer (wl_shm_buffer)
is no longer available. Call the appropriate destroy handler to
invalidate the pixman image and avoid touch the shm_buffer.

Fixes: #613

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-04-29 11:48:08 +03:00
Hideyuki Nagase
b6fc6b2a8d rdp: sync keylocks on synchronize event
Synchronize events carry keylock status, so we should update it.

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-04-28 15:33:57 +00:00
Hideyuki Nagase
6515df1333 rdp: Support using Japanese layouts with US keyboards
When RDP indicates that a Japanese keyboard layout is used without
a Japanese 106/109 keyboard (keyboard type 7), use the "us" layout,
since the "jp" layout in xkb expects the Japanese 106/109 keyboard
layout.

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-04-28 15:33:57 +00:00
Hideyuki Nagase
5d939bc636 rdp: Korean keyboard support
Korean keyboards are keyboard type 8:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeyboardtype

While type 8 is not explicitly mentioned in the RDP documentation,
it can be sent over the wire. Let's support the variants we can.

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-04-28 15:33:57 +00:00
Hideyuki Nagase
4d5605b3a0 rdp: refactor xkbRuleNames code
This code will eventually be used by RAIL as well, so let's
split it out now.

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-04-28 15:33:57 +00:00
Hideyuki Nagase
a29bcb7031 rdp: change japanese keyboard input from kana to alphabetical
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-04-28 15:33:57 +00:00
Hideyuki Nagase
e3a4552ecc rdp: Fix Farsi keyboard map
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-04-28 15:33:57 +00:00
Hideyuki Nagase
08f5edfe78 rdp: Fix Brazilian keyboard map
Use the common abnt2 variant, instead of the niche nativo one.

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-04-28 15:33:57 +00:00
Hideyuki Nagase
d2a8165bb6 rdp: Add Persian keyboard map
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-04-28 15:33:57 +00:00
Derek Foreman
2eb5912960 rdp: Don't bother trying to pick an optimal keyboard model name
Nothing actually cares about this string, and pc105 will do just
fine.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-28 13:19:10 +00:00
Hideyuki Nagase
806e824809 rdp: Add horizontal scroll support
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-04-28 12:39:35 +00:00
Hideyuki Nagase
4e907a67e5 rdp: Add high precision scrolling
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-04-28 12:39:35 +00:00
Hideyuki Nagase
ce09c7835c rdp: refactor scrollwheel code
We move this into a function for when we add horizontal wheel support
later.

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-04-28 12:39:35 +00:00
Hideyuki Nagase
cf5ddd05cb rdp: Allow configuring the refresh rate
We currently hardcode a 60Hz update rate for the rdp backend.

In some cases it may be useful to override this to increase the rate
for a faster monitor, or to decrease it to reduce network traffic.

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-04-28 07:35:57 -05:00
Hideyuki Nagase
bd214edf26 rdp: Calculate frame times from mode refresh rate
Instead of hard coding a 16ms refresh interval, use the refresh rate
from the current mode to determine when the next frame should be.

Currently, we still hard code the refresh rate, so this will end up
with roughly the same value we've been using, but in the future
we'll allow setting it via command line.

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-04-28 07:35:04 -05:00
Brenton DeGeer
2f9319cef6 rdp: Allow specifying a listener fd on the command line
We already have a way for a single RDP client connection to be
passed from a parent process to a child using a combination
of environment variable (RDP_FD) and env var (--env-socket)

This patch allows a bound socket fd (as opposed to a client
connection) to be established in a parent process and provided
to the rdp backend. WSLg uses this to set up an AF_VSOCK
socket for communication between a Windows RDP client and a
weston compositor running under a hypervisor.

Co-authored-by: Hideyuki Nagase <hideyukn@microsoft.com>
Co-authored-by: Steve Pronovost <spronovo@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-04-28 12:27:56 +00:00
Hideyuki Nagase
13e62c9d18 rdp: validate button state
Discard and log duplicate release or press events. Log and discard
invalid button ids.

This prevents buggy clients from causing problems in weston's internal
state - like breaking idle inhibition button counting.

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-04-27 13:57:42 +00:00
Hideyuki Nagase
873ec15412 rdp: Fix up xf_extendedMouseEvent
These events carry the 4th and 5th mouse buttons, so
we should propagate them. We also need to use pointer
frames to ensure the buttons are properly paired with
the pointer co-ordinates.

Unfortunately, there is no way in RDP to determine if
a mouse event and an extended mouse event should be in
the same pointer frame, so this is the best we can do.

We also enable extended mouse events so they'll be used.

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-04-27 13:57:42 +00:00
Hideyuki Nagase
7f10997d92 rdp: add mouse input debug
Add extremely verbose mouse input debugging.

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-04-27 13:57:42 +00:00
Daniel Stone
b5605ccd26 libweston: Remove weston_surface_set_color
Don't do this; instead, create a solid-colour buffer and attach it to
the surface explicitly.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
4d426ab6b1 shell: Explicitly use solid weston_buffers
Rather than punching through to set the surface as a solid colour,
attach an actual weston_buffer to it instead.

This becomes the first user of attaching non-client-generated buffers
to a weston_surface. As a result, it is necessary to introduce a
function which will allow compositors and shells to attach a buffer to a
surface. weston_surface_attach_solid() is therefore introduced as a
special-purpose helper which will attach a solid buffer to a
weston_surface.

It is not intended as a general-purpose mechanism to allow compositors
to attach client-generated buffers to surfaces, as doing so would have
unknown effects on this core part of the compositor itself.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
82b646728c backend-drm: Handle solid-colour buffers in state propose
When we're checking to see if a view is suitable to go on a plane, check
for (and reject) solid-colour buffers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
b38b735e20 backend-drm: Remove Pixman conditional for keep_buffer
The Pixman renderer keeps its own reference to buffers when attached to
surfaces, through its surface state: just use that instead.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
493a4c013e noop-render: Allow solid-color buffers
Refactor the buffer-type check slightly so we can handle solid-color
buffers, which we do exactly nothing with.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
d82d74e713 pixman-renderer: Support solid-colour weston_buffers
Just implemented via the same mechanism as surface_set_color.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
465f4a250c gl-renderer: Support solid-colour weston_buffers
Same as surface_set_color.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
43715ff0c0 weston_buffer: Add solid buffer type
Currently solid-colour displays (e.g. the background for fullscreen
views) is implemented by a special-case weston_surface which has no
buffer attached, with a special punch-through renderer callback to set
the colour.

Replace this with a weston_buffer type explicitly specifying the solid
colour, which helps us eliminate yet more special cases in renderers and
backends.

This is not handled yet in any renderer or backend, however it is also
not used by anything yet. Following commits add support to the renderers
and backends.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
7a27f6cbe4 compositor: Downgrade rather than drop buffer reference when copied
When the renderer/backend indicate that they do not need a surface's
buffer content to be preserved, most often because they have copied it,
simply downgrade the buffer reference to 'will not access', rather than
drop the buffer reference altogether.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
a42908204f weston_buffer: Separate buffer release from lifetime
In the original conception, a weston_buffer_reference indicated that the
underlying contents of the wl_buffer would or could be accessed, so
wl_buffer.release must not be sent until the last reference was
released, as the compositor may still use it.

This meant that renderers or backends which copied the buffer content -
such as the GL renderer with SHM buffers - could only send a buffer
release event to the client by 'losing' the buffer reference altogether.
The main side effect is that `weston-debug scene-graph` could not show
any information at all about SHM buffers when using the GL renderer, but
it also meant that renderers and backends grew increasingly exotic
structures to cache information about the buffer.

Now that we have an additional buffer-reference mode (still referring to
the weston_buffer/wl_buffer, but not going to access its content), we
can allow the weston_buffer_reference and weston_buffer to live as long
as the buffer itself, even if we do send a release event.

This will enable a bunch of backend and renderer deduplication, as well
as finally making scene-graph more useful.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
fdc7b9c352 weston_buffer: Add mode to weston_buffer_reference
Add a mode argument to weston_buffer_reference which indicates whether a
buffer's storage may/will be accessed, or whether the underlying storage
will no longer be accessed, e.g. because it has been copied. This will
be used to retain a pointer to the weston_buffer whilst being able to
send a release event to the client.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
7e90433079 weston_buffer: Hold lifetime for resource/backend usage
Keep the weston_buffer alive for as long as at least one of the
underlying wl_buffer or a backend usage exists.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
d2a858e879 gl-renderer: Prepare for buffer to outlive resource
Make sure we don't die if we're asked to flush the damage on a SHM
buffer which has subsequently been destroyed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
7b3efabd88 weston_buffer: Prepare for buffer to outlive resource
We currently allow a weston_buffer to outlive the underlying wl_buffer
iff the renderer/backend has cached it. Currently the 'is this buffer
valid?' test relies on looking for the validity of the weston_buffer
itself; shift these tests to looking at the validity of the underlying
resource.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
e9c792ed64 backend-drm: More failure reasons
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
231a67ff8c drm-backend: Refactor unpleasant keep_buffer if tree
Break a giant if statement out into a more legible grouping.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
2dcfe723be backend-drm: Make use of weston_buffer format and type
Just pull it from the structure rather than pulling it in externally.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
1d9c62b50d weston_buffer: Print more buffer information in scene-graph
Try to print out as much information as we can about the buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
0a8802404c scene-graph: Use weston_buffer's format/modifier info to print
Now that we have this generically available, use it rather than calling
into per-buffer getters.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
7506cf5240 gl-renderer: Simplify surface->is_opaque
We already have the format; no need to go chasing it again.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
4f88b2655e weston_buffer: Change y_inverted to explicit origin enum
y_inverted meant that the buffer's origin was (0,0), and non-inverted
meant that the buffer's origin was (0,height). In practice, every buffer
was 'inverted' into our natural co-ordinate space that we use
everywhere.

Switch to using an explicit origin enum to make this more clear.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
6dcf3eac1f weston_buffer: Add pixel format and modifier info
Promote these to weston_buffer rather than burying them in the renderers
and backends.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
fef8bb275c weston_buffer: Make use of weston_buffer->type
Rather than calling accessors (wl_shm_buffer_get etc) to figure out
which type our buffer is, just look in the structure.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
34cd0d114f weston_buffer: Add type field
Rather than open-coding various resource -> type accessors, just stick a
type enum in the buffer struct.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
1d5f8af82e gl-renderer: Add hook to fill weston_buffer for EGL
Rather than only filling weston_buffer information when we first come to
use it, add an explicit hook so we can fill the dimensions the first
time the buffer's attached.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
f49d6f47f3 gl-renderer: Reject unknown-format dmabufs
Make sure we only import dmabufs where the underlying pixel_format is
known: if we can't reason about the buffer content, we're not entirely
likely to be able to display it well.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
ca9bb01fe6 renderers: Set buffer properties earlier
When we first see a buffer attached, we create a weston_buffer for it.
The weston_buffer doesn't contain any useful information in and of
itself; that's left to renderers to populate later.

Switch this to doing it in the core at the first opportunity, at least
for SHM and dmabuf buffers; EGL buffers will follow in the next commit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
fec0400886 gl-renderer: Drop unnecessary NULL check
All the callers of flush_damage guarantee we'll have a buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
12675ed19f renderer: Add buffer to flush_damage
We already have the buffer in the caller, and every no-op implementation
will want to access the buffer. So might as well pass it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Daniel Stone
f8ac6f940f gl-renderer: Remove outdated comment
The comment about needing to have destroyed images is somewhat less true
now that we actively avoid doing so.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: 0b51b02c5e ("gl-renderer: Don't re-import dmabufs")
2022-04-25 14:27:08 +00:00
Daniel Stone
efd6aae915 gl-renderer: Remove unnecessary dmabuf conditional
We can't try to attach a dmabuf that we never imported.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-04-25 14:27:08 +00:00
Hideyuki Nagase
6129cbd880 rdp: Improved rdp logging infrastructure
Add some logging helper functions along with two log scopes for debug
and extremely verbose debugging information.

Also add tangentially related logging for the synchronize event, so
the debug stream isn't empty right now. The vast majority of verbose
usage will come later.

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-04-21 07:33:27 -05:00
Derek Foreman
04e0558327 rdp: Allow disabling RemoteFX codec
There are currently compatibility issues between FreeRDP's implementation
of the RemoteFX codec and Microsoft's implementation.

Perhaps this will be fixed in the future and this option can go away,
but for now it's necessary to have a way to disable the codec if the
windows client is going to be connecting to a weston server.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-21 07:20:59 -05:00
Marius Vlad
3bedb70454 touch-calibration: Clean-up if touch calibrator has been enabled
Seems that we're still missing layer clean-ups, with the touch
calibrator being one of them. Call the appropriate function when
shutting down the compositor instance.

Fixes: #603

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-04-20 08:27:17 +00:00
Hideyuki Nagase
8fb529bc31 input: Fix bug in idle inhibition
Server generated key repeats are ignored - and they don't generate
matching release events. We early return to avoid generating events
for them.

We also need to push the idle inhibition counting after that early
return to prevent breaking idle inhibition with unmatched events.

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-04-18 12:10:20 +00:00
shierote
f2d6d21eec libweston: correct argument name in the handler of wl_data_source.accept
Signed-off-by: Taishi Eguchi <taishi2060@gmail.com>
2022-04-14 12:05:57 +00:00
Hideyuki Nagase
87bded8b54 rdp: split off rdp.h
Refactor some of rdp.c into a header file.

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-04-14 12:02:12 +00:00
Hideyuki Nagase
516d2c0207 rdp: fix leak when listener implantation fails
We've already allocated the listener by the time we hit this failure,
so we must exit through the path that frees it.

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-04-14 11:57:29 +00:00
Derek Foreman
0ff4e478cd rdp: Fix comment regarding meaning of 120
This URL has changed

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-04-12 09:26:13 -05:00
Sören Meier
edef874696 libbacklight: Fix backlight never gets initialized
In 913d7c15f7 stricter error checking was
introduced to the strtol call, which broke reading backlight values.
Since every sysfs backlight file ends with a newline.

As noted in a comment in the previous MR to prevent damaged pointers
after calling asprintf, replace every asprintf call with str_printf.

Previous-MR: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/543

Signed-off-by: Sören Meier <soerenmeier@livgood.ch>
2022-04-11 08:38:00 +03:00
Michael Tretter
6ee6e76a0c compositor: remove repaint_data from compositor
The repaint_data is entirely backend specific. Moreover, it is only used by the
drm backend, while other backends ignore the repaint data.

There will always be only one repaint active, thus, there is no need to pass the
repaint data from the outside.

The repaint_data breaks with the multi-backend series, which calls repaint begin
for all backends to get the repaint_data. The repaint_data of the last backend
will then be passed to all other backend. At the moment, this works, because the
drm backend is the only backend that implements the begin_repaint call.

Another option would be to track the repaint data per backend in the compositor,
but actually, it the backend needs to track state across the calls, it's its own
responsibility.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-04-06 12:47:05 +02:00
Michael Tretter
c448b938f7 backend-drm: always get pending_state from backend
The pending_state is already stored in the backend and can be directly retrieved
from there.

This avoids involving the compositor in passing state between the repaint
phases for a single backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-04-06 12:47:05 +02:00
Daniel Stone
c8a2fb7a40 pixel-formats: Add XYUV8888 format
XYUV8888 support was added to gl-renderer in 30104bd89a, but not to
pixel-formats. Oops.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-03-31 17:15:55 +00:00
nerdopolis
cdfe94b105 launcher-logind: Don't check wl->vtnr before returning it.
Signed-off-by: n3rdopolis <bluescreen_avenger@verizon.net>
2022-03-16 13:12:20 +00:00
Pekka Paalanen
b3ba1becba libweston: remove fbdev backend
Fbdev backend was deprecated in the Weston 10.0.0 release with
6338dbd581. Before that, I suggested
already in 2019 to remove it, but it was too soon then. Now it seems the
final voices asking for fbdev to be kept have been satisfied, see the
linked issue.

Fbdev-backend uses a kernel graphics UAPI (fbdev) which is sub-par for a
Wayland compositor: you cannot do GPU accelerated graphics in any
reasonable way, no hotplug support, multi-output support is tedious, and
so on. Most importantly, Linux has deprecated fbdev a long time ago due
to the UAPI fitting modern systems and use cases very poorly, but cannot
get rid of it if any users remain. Let's do here what we can to reduce
fbdev usage.

I am doing color management related additions to libweston which require
adding checks to every backend. One backend less is less churn to write
and review.

Libweston major version has already been bumped to 11, so the next
release will be Weston 11, without fbdev. enum weston_compositor_backend
entries change their numerical values.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/581

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-15 11:32:46 +02:00
Robert Mader
f81aacdf2f pixel-formats: Add support for 64bbp float RGB formats
These are supported by some other compositors already.
Add them to the list so `weston-simple-dmabuf-feedback`
reports them correctly.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-03-11 13:55:19 +01:00
Marius Vlad
c19cf3d684 libweston: Enable logging for libseat launcher
The built-in backend of libseat requires users to enable a logging
level in order for libseat to start writing out log messages.  For that
to happen we split out the info and error log level messages into the
compositor's log scope, while debug level messages go into a dedicated
scope.

With that, this patch brings in a new scope, called libseat-debug, which
users need to explicity create a subscription for it as to retrieve/have
access to debug message coming out of libseat. Note that by default we
have a subscription for the log-scope so any errors/info from libseat
would be displayed to the user.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-03-10 17:13:16 +02:00
Marius Vlad
e9fe66a91c weston-log: Extract helper for generating a time stamp
As we might be needing it for other scopes extract the time stamp
genration into a helper.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-03-10 17:11:31 +02:00
Derek Foreman
7cae2a1fb0 backend-wayland: Stop supporting wl_shell
This has been deprecated for a long time, so let's stop supporting
it entirely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-03-08 15:12:56 +02:00
Michael Olbrich
78c94d0719 libweston: explicitly cancel start_drag if no matching input device is found
Otherwise, the client will assume that dragging is in progress and remains in
that state forever.
This can happen when weston processes the mouse up event just before the
start_drag() arrives.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-03-04 11:51:01 +00:00
Derek Foreman
2c91c70250 launchers: Remove --tty option
This doesn't work with any of the launchers we've kept. Remove the option
and all the bits that handle it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-03-03 17:00:15 -06:00
Derek Foreman
a96dfc7098 launchers: remove launchers
Moving forward we're going to be supporting libseat and logind as our
only launchers. We're doing this to reduce our maintenance burden,
and security impact.

Libseat supports all our existing use cases, and seatd can replace
weston-launch so we no longer have to carry a setuid-root program.

This patch removes weston-launch, and launcher-direct, leaving only
libseat and logind.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-03-03 16:54:14 -06:00
Vitaly Prosyak
87f2d09f18 color-lcms: Always use cmsContext for LCMS API which has THR suffix
Fix a typo. No CM functional change, just redirect LCMS error
into  created cmsContext which output into weston log.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-03-01 22:49:39 -05:00
Pekka Paalanen
e2ee2b56f9 tests: make vertex-clip use WESTON_EXPORT_FOR_TESTS
This is probably the simplest case to demonstrate how to use
WESTON_EXPORT_FOR_TESTS.

Previously, vertex-clip test re-built vertex-clipping.c for itself. Now
it directly links in gl-renderer.so instead as that is where
vexter-clipping.c gets built into for actual use. This probably will not
work for any installed program, but luckily tests are never installed,
so Meson makes sure the DSO is found.

Unfortunately we cannot remove the definition of dep_vertex_clipping
yet, because clients/cliptest.c needs it.

This makes vertex-clip test depend on GL-renderer, but that is where the
code is really used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-03-01 13:32:15 +00:00
Takuro Ashie
351e6a4b21 Don't send compositor's global key bindings to the input method
Although weston_compositor_run_key_binding() is called when the current
keyboard grab is default_grab or input_method_grab, swallowing the key
event is processed only on default_grab. As a result key events that
should be swallowed are sent to the input method unexpectedly.

For example, when a user press `Super + s` on weston-editor to take a
screen shot, `s` will be unexpectedly entered to the text area.
I confirmed such behaviour with weston-simple-im and fcitx5-5.0.10.
It doesn't occur with weston-keyboard because it doesn't install
keyboard grab.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
2022-02-23 15:40:33 +02:00
Vitaly Prosyak
6099c0e24b color-lcms: LCMS transform for color mapping
Use 3D LUT for color mapping.
For category CMLCMS_CATEGORY_INPUT_TO_BLEND use transform which has
3 profiles: input, output and light linearizing transfer function.
For category CMLCMS_CATEGORY_INPUT_TO_OUTPUT use input and output profiles +VCGT.
For category CMLCMS_CATEGORY_BLEND_TO_OUTPUT use output inverse EOTF + VCGT.

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-12 23:19:00 -05:00
Vitaly Prosyak
c199aade3f color-lcms: linearization of an arbitrary color profile
Graeme sketched a linearization method there:
https://lists.freedesktop.org/archives/wayland-devel/2019-March/040171.html
Sebastian prototyped there:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/14/commits

Thanks to Pekka for great simplifications in implementation, like the xyz_dot_prod()
Quote: "should help untangle lots of the multiplications and summations by saying
we are computing dot products, etc".

The approach was validated using matrix-shaper and cLUT type of profiles.
If profile is matrix-shaper type then an optimization is applied.
The extracted EOTF is inverted and concatenated with VCGT, if it is availible.
Introduce function cmlcms_reasonable_1D_points which would be shared between
linearization method and number of points in 1DLUT for the transform.
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 13:06:11 -05:00
Vitaly Prosyak
37e0d54cc9 color-lcms: add matches parameters based on category
Use category, intent and output and input profiles
for comparison.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 12:58:02 -05:00
Vitaly Prosyak
19913366e8 color-lcms: add new fields for transform search parameter
Add to search parameter cmlcms_category, input and output profiles,
and render intent for output which would be used for both profiles.
Add common function setup_search_param for every category.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 12:58:00 -05:00
Vitaly Prosyak
19f318692e color-lcms: introduce sRGB stock profile
The stock profile would be used when client or output
do not provide any profile or unaware of color management.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-11 12:56:57 -05:00
Vitaly Prosyak
a92fa34d1d color-lcms: add wrapper API for refcounting cmlcms_color_profile
It is used for convenience when profile is cached.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak
494ff5b23b color-lcms: introduce cmlcms_category, EOTF and INV EOTF
1. The cmlcms_category is used to identify the purpose of transform:
   - CMLCMS_CATEGORY_INPUT_TO_BLEND
   - CMLCMS_CATEGORY_BLEND_TO_OUTPUT
   - CMLCMS_CATEGORY_INPUT_TO_OUTPUT

2. Added following fields to cmlcms_color_profile:

   - output_eotf - If the profile does support being an output profile and it
     is used as an output then this field represents a light linearizing
     transfer function and it can not be null. The field is null only if
     the profile is not  usable as an output profile. The field is set when
     cmlcms_color_profile  is created.

   - vcgt - VCGT tag cached from output profile, it could be null if not exist

   - output_inv_eotf_vcgt - if the profile does support being an output profile and it
     is used as an output then this field represents a concatenation of inverse
     EOTF + VCGT, if the tag exists and it can not be null.

3. Added field cmsHTRANSFORM to cmlcms_color_transform.
   It is used to store LCMS optimized pipeline.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak
93c6180c71 gl-renderer: shaders implementation of color mapping function
The following GL extensions provide support for shaders CM:
 -GL_OES_texture_float_linear makes GL_RGB32F linear filterable.
 -GL ES 3.0 provides Texture3D support in GL API.
 -GL_OES_texture_3D provides sampler3D support in ESSL 1.00.

If abovesaid is supported then renderer sets flag WESTON_CAP_COLOR_OPS
which means that all fields in struct weston_color_transform are
supported, for example, 1DLUT and 3DLUT.

Use GL_OES_texture_3D to implement 3DLUT function which
uses trilinear interpolation for pixel processing or bypass as is.
Quote from https://nick-shaw.github.io/cinematiccolor/luts-and-transforms.html
"3D LUTs have long been embraced by color scientists and are one of
the tools commonly used for gamut mapping. In fact, 3D LUTs are used
within ICC profiles to model the complex device behaviors necessary
for accurate color image reproduction".
Quote from https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/
chapter-24-using-lookup-tables-accelerate-color
is about interpolation: "By generating intermediate results based
on a weighted average of the eight corners of the bounding cube,
this algorithm is typically sufficient for color processing,
and it is implemented in graphics hardware".

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak
cda130e4b0 gl-renderer: add declaration of color mapping function
Introduce shader color mapping identity and 3D LUT.
Shader requirements struct uses union for color mapping
to prepare the place for 3x3 matrix.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Vitaly Prosyak
2e2ad02d5c libweston: add definition of color mapping function
Introduce 3D LUT definition as part of Weston
color transform struct. A 3D LUT is a LUT containing
entries for each possible RGB triplets.
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-09 20:42:50 -05:00
Marius Vlad
0b5c75f540 backend-drm/state-propose: Missing some newlines
It would look much better if the debug is printed separately.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-02-07 17:58:35 +02:00
Robert Mader
8b04534c76 libweston/compositor: Do not map subsurfaces without buffer
We can end in `subsurface_committed()` in different scenarios
without the surface having an attached buffer. While setting
the mapped state to `true` in that case doesn't matter for
that (sub)surface itself, it triggers its own child subsurfaces
to get mapped when they shouldn't.

Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/426

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-07 12:16:16 +00:00
Derek Foreman
83927bb0e6 launcher-logind: Remove systemd-logind support
Many years ago (2014) systemd-logind was brought into libsystemd.
We've supported old versions of systemd-logind ever since.

Let's remove support for old versions of systemd-logind before the
merge for a tiny code simplification.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-02-03 16:00:26 +00:00
Derek Foreman
66374d48f1 compositor: Remove desktop zoom
Zoom is a neat trick, but in its current form it's very hard to test
and maintain.

It also causes output damage to scale outside of the output's boundaries,
which leads to an extra clipping step that's only necessary when zoom
is enabled.

Remove it to simplify desktop-shell and compositor.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-02-03 15:51:20 +00:00
Robert Mader
933290e6ea libweston/compositor: Cache buffer damage for synced subsurfaces
The spec states:
> Because buffer transformation changes and damage requests may be
> interleaved in the protocol stream, it is impossible to determine
> the actual mapping between surface and buffer damage until
> wl_surface.commit time. Therefore, compositors wishing to take both
> kinds of damage into account will have to accumulate damage from the
> two requests separately and only transform from one to the other after
> receiving the wl_surface.commit.

For subsurfaces in sync mode, arguably the same is the case until the
cached state gets applied eventually. Thus, in order to keep complexity
to a sane level, just accumulate buffer damage and convert it only
when the cached state gets applied.

This mirrors how other compositors like Mutter implement cached damage
and what the spec arguably should demand.

Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/446

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2022-02-03 15:44:47 +00:00
Manuel Stoeckl
b0ed4a2e3b gl-renderer: add support for (a|x)bgr16161616 shm formats
These formats are useful because they are often easier to produce
on CPU than half-float formats, and abgr16161616 has both >= 10bpc
color channels and adequate alpha, unlike abgr2101010.

The 16-bpc textures created from buffers with these formats require
the GL_EXT_texture_norm16 extension.

As WL_SHM_FORMAT_ABGR16161616 was introduced in libwayland 1.20,
update Weston's build requirements and CI.

The formats also needed to be registered in the pixel format table,
and defined in a fallback path if recent libdrm is not available.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2022-02-02 11:58:58 +00:00
Daniel Stone
30de938624 backend-drm: Add more view-to-plane failure states
Specifically log if there were no suitable planes for us to use, or if
we tried to place it on a plane but were told no by the kernel.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
a2c5709e71 backend-drm: Pass paint node through to plane_state find
This lets us clean up a bit of code.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
0ace8b66af backend-drm: Unify overlay/primary view->plane code
There's no real reason for these to be separate now that the eligibility
checks have been moved up so we don't call them unless it makes sense.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
81e74ff334 backend-drm: Don't take buffer-release reference for cursor views
We just copy the SHM buffer straight into a separately-allocated GBM BO,
so no need to take a reference on the buffer itself or keep it from
being released.

All drm_output_try_view_on_plane really does at this point is to call
the prepare_*_view function for the requisite plane type, and take a ref
on the weston_buffer from the client. Given that we don't need to keep
the client buffer alive, we can short-circuit
drm_output_try_view_on_plane, and instead just call
drm_output_prepare_cursor_view directly when we have a cursor plane.

This also makes it easier to just remove drm_output_try_view_on_plane in
following patches when we merge the overlay/scanout plane path into one.
Doing so gives us two clearly-separated paths: one for copying a SHM
client buffer into a cursor, and another for directly scanning out
client content.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
873e32137e backend-drm: Remove unnecessary check for fb
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
e1114228f5 backend-drm: Remove unused enum
At some point this got hobbled, such that NO_PLANES and
NO_PLANES_ACCEPTED became the same thing, so we can just check if the
returned plane_state is NULL or not.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
2dd3af3c22 backend-drm: Move IN_FENCE_FD check to common code
No need for this to be specialised within both overlay and scanout plane
paths.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
1b34c5cd80 backend-drm: Remove unnecessary check in prepare_scanout_view
We already guarantee this from the caller.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
6b828c7b57 backend-drm: Don't try non-fullscreen views on the primary plane
You'd think this would go without saying, but no, we just sort of buried
that.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
dc0de9ee2b backend-drm: Move overlay vs. primary plane check earlier
For views which cover the entire output, we always attempt to place them
on the primary plane, to avoid a situation where we place a fullscreen
view into an overlay plane and then have to disable the primary plane,
which doesn't always work.

Move this check earlier, so we don't consider overlay planes to be
candidates for fullscreen views. This check should be changed in future
to only filter for opaque views, but that's for another time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
5e41b44b10 backend-drm: Change cursor checks to asserts
We shouldn't get down into trying to place a view on a cursor plane if
these checks are not met, so change them to asserts rather than early
returns.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
b3d7df5c3e backend-drm: Move plane-type-specific checks to switch statement
This makes it a bit more clear and easy to follow, rather than diving
through if nesting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
0ecd6c3d33 backend-drm: Move renderer-only vs. scanout_plane test earlier
No point trying to put something on the scanout plane in mixed mode.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
ae60745b61 backend-drm: Move cursors_are_broken test earlier
No point trying to place a cursor buffer on a plane when we can't do
cursor planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
e5ad3c8865 backend-drm: Remove separate zpos_plane list
When we introduced support for variable zpos, we did so by filtering the
list of acceptable planes and then creating a separate zpos-ordered
list. Now that the planes are already zpos-sorted in the backend list,
and we have more early filtering, we can replace this with a single
plane-list walk.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
23257c073f backend-drm: Minor comment rewording
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
26c2f9a65f backend-drm: Don't try cursor buffers for client planes
For better or worse, cursor planes can only be used by uploaded SHM
buffers right now, so ignore them when we're calculating the acceptable
plane mask for client dmabufs.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
9c6a069435 backend-drm: Early-out for non-SHM buffers in renderer-only mode
If we're in renderer-only mode, we can only use the renderer and the
cursor plane. Don't even try to import client buffers as it makes no
sense.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
6aec64b2f7 backend-drm: Early-out for too-large SHM/cursor buffers
We know what our limit is for cursor planes, so don't try to assign a
view which is too large.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
ca4c2865e9 backend-drm: Early-out for cursor plane format testing
If we have a SHM buffer, it can only go into a cursor plane - and only
then if it's of the right format.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
66244856e2 backend-drm: Don't try to import SHM buffers as drm_fb
It won't work.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00
Daniel Stone
d5ec9a1a1d backend-drm: Don't try to steal other-output special planes
Each output is hardcoded to the use of a single 'special' (primary or
cursor) plane; make sure we don't try to steal them from other outputs
which might not be happy to discover that we've taken it off them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-02-01 23:12:11 +00:00