Commit Graph

1426 Commits

Author SHA1 Message Date
Michael Tretter c4685d9463 backend-drm: attach device to pending state
The commits happen per device instead of per backend. The pending state is
therefore per device as well. Allow to retrieve the device from the pending
state.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:14:11 +02:00
Michael Tretter 615a37dc88 backend-drm: make dma-buf feedback device specific
The scanout format for the dma-buf feedback are specific to the kms device that
is used for scanout. Therefore, we have to pass the device of the output when
retrieving the scanout formats.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:13:55 +02:00
Michael Tretter 101c0f6b8b backend-drm: get the fb using the device instead of the backend
The fbs are specific to the device on which they will be displayed. Therefore,
we have to tell which device shall be used when we are creating the fb.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:13:40 +02:00
Michael Tretter d89fcf10cb backend-drm: pass device through atomic commit handler
The atomic commit is device specific. If we have multiple kms devices, we need
to know which device was used for the atomic commit.

Pass the device instead of the backend through the atomic commit.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:13:23 +02:00
Michael Tretter 0d967bd7f4 backend-drm: extract device from backend
Extract the kms device from the backend to allow a better separation of the
backend and the kms device. This will allow to handle multiple kms devices with
a single drm backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:12:57 +02:00
Michael Tretter 2860933ded backend-drm: cleanup debugging
Get the backend at the beginning of the function instead of retrieving it from
another object in the debug statement. This simplifies refactoring, as the debug
statement is not affected by changes how the backend is retrieved.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:04:29 +02:00
Michael Tretter 00b74293e8 backend-drm: use pixel format to print gbm format
The gbm_format is the same as the drm format used by the pixel format.

Print the format name using the pixel format in the error message to make the
error message easier to understand for humans.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:04:29 +02:00
Michael Olbrich 83d1eafd81 backend-drm: virtual: use the DRM fd from the fb
The fb already contains a DRM fd for later use. So just use that one instead of
fetching it from the backend.

This is necessary if the fbs are allocated on different devices, since otherwise
the wrong device might be used to get the fd of the passed fb.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:04:29 +02:00
Derek Foreman c0cafde80f drm: Remove destroy listener from list when fired
Looks like we missed this one during the conversion to
weston_signal_emit_mutable.

Found by running weston under valgrind and running/killing
weston-simple-dmabuf-egl

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-06-03 09:58:09 +03:00
Hideyuki Nagase 8508f93f2b rdp: Update cursor position on most mouse messages
The RDP spec says we can trust x, y position on all messages except
PTR_FLAGS_WHEEL and PTR_FLAGS_HWHEEL, so let's do that to ensure
proper sync with the RDP client.

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-06-01 12:16:37 +00:00
Marius Vlad b0257e0ffc backend-drm: Add GBM_BO_HANDLE as a failure reason
And use it to get a feedback event for when adding scanout tranche.

With this change, I get back a feedback event for dmabuf-feedback
on VC4:

���� tranche: target device /dev/dri/card0, scanout
�   ���� format ABGR2101010, modifier LINEAR (0x0)
�   ���� format XBGR2101010, modifier LINEAR (0x0)
�   ���� format ARGB8888, modifier LINEAR (0x0)
�   ���� format ABGR8888, modifier LINEAR (0x0)
�   ���� format XRGB8888, modifier LINEAR (0x0)
�   ���� format XBGR8888, modifier LINEAR (0x0)
�   ���� format RGB565, modifier LINEAR (0x0)
�   ���� format YUV420, modifier LINEAR (0x0)
�   ���� format YUV422, modifier LINEAR (0x0)
�   ���� format YVU420, modifier LINEAR (0x0)
�   ���� format YVU422, modifier LINEAR (0x0)
�   ���� format NV12, modifier LINEAR (0x0)
�   ���� format NV12, modifier BROADCOM_SAND128 (0x700000000000004)
�   ���� format NV16, modifier LINEAR (0x0)
�   ���� end of tranche

Besides that, it can place a fullscreen state of simple-egl on the
primary plane, which without this change wasn't possible.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-06-01 07:38:17 +00:00
Pekka Paalanen e67a0cb57c gl-renderer: fix double-alloc of gl_buffer_state
Obviously the first allocation is always leaked, there is a second
zalloc() right below. Fix the leak.

Found by code inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-31 13:08:01 +03:00
Marius Vlad 7412a01437 backend-drm: Retrieve reason if dmabuf import failed
As we could have situations where dmabuf import failed when attempting
to figure it the framebuffer is scanout-capable, make sure we also have
a way to store that information. Otherwise, we could end up
NULL-dereferencing, as we don't provide a valid storage for it.

Further more, with this, we also print out the reason why it failed, to
aid in further debugging.

Observed on platforms where GBM_BO_HANDLE failed + in combination w/
direct-display proto extension.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-05-30 16:22:35 +03:00
Pekka Paalanen 8ebebb20ef drm-backend: add color_outcome / HDR metadata serial
Output color profile may be changed in flight. Output basic color
characteristics and EOTF mode cannot yet be changed in flight, but it is
reasonable to assume they could in the future. Therefore the color
outcome data may change in flight as well, which is the basis for HDR
metadata, which needs to be updated as well.

Track the changes to color outcome data with a serial number.
DRM-backend checks the serial number to see if it needs to re-create the
HDR metadata blob. This allows the changes to propagate all the way to
KMS.

The code added here is more of a reminder of what should happen than a
tested path.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-05-27 10:30:35 +00:00
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