Commit graph

9776 commits

Author SHA1 Message Date
Leandro Ribeiro
432b9af0cd color: add getters to primaries_info and tf_info from protocol enum
This will be necessary in the next commit, so add that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Marius Vlad
43f7b7b3bb windowed-output-api.h: Provide ARRAY_LENGH() for windowed-output-api
We need this common helper as we don't have access to shared helper, so
just define one in-situ.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:28 +02:00
Marius Vlad
207fed2710 Revert "shared/helpers.h: Migrate helpers.h to libweston"
This is problematic as we don't have namespacing for these and some of
the macros can interfere with other defines.

This reverts commit 8634c7e349.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:26 +02:00
kang-sooyeon
c77a5d386a libweston/input.c: Fix weston crash with the mouse event
Fix weston crash when user click the mouse continuosly while
the video is playing.
Call weston_view_update_transform before calling
weston_coord_global_to_surface to update view->transform.dirty to 0.

Fixes #985

Tested-by: Sooyeon Kang sooyeon8979@gmail.com
Signed-off-by: Sooyeon Kang sooyeon8979@gmail.com
2025-01-17 07:54:59 +00:00
Leandro Ribeiro
eabc19bc3b drm: log more try_view_on_plane_failure_reasons
Up to now, we've been logging only the failures that we get from
drm_fb_get_from_paint_node(). So let's start logging the other failures
we get in drm_output_find_plane_for_view() as well.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:03:22 -03:00
Leandro Ribeiro
5c3067ad54 drm: print why dma-buf feedback is being updated
This may be helpful for debugging.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:03:22 -03:00
Leandro Ribeiro
306033616b drm: print try_view_on_plane_failure_reasons bitmask as string
This should help people to debug. Instead of printing an hex value,
print each enum value present in the bitmask as a string (comma
separated).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:03:22 -03:00
Leandro Ribeiro
4cc489c6af shared: move bits_to_str() to string-helpers.h
This function is useful across multiple components of the project, so
move it to a helper header.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:03:20 -03:00
Leandro Ribeiro
5fcedcf5ef drm: remove scanout tranche if we detect INADEQUATE_CONTENT_PROTECTION
Client won't be able to do direct-scanout with this surface, and the
format/modifier doesn't matter in this case. So let's remove the scanout
tranche from dma-buf feedback in such case.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:01:13 -03:00
Leandro Ribeiro
d3ead778de drm: avoid dma-buf feedback endless loop
Currently we have the following situation: we add a scanout tranche
because if the client re-allocates with another format/modifier, the
chances of being placed in a DRM/KMS plane is higher.

But then we run out of overlay planes. So we remove the scanout tranche,
because the format/modifier available in the renderer tranche are
optimal for rendering.

Now Weston detects again that the format/modifier is what may be
avoiding the view being place in a plane, re-adding the scanout tranche.
And we have an endless loop.

To avoid this, let's accumulate the reasons why placing the view in a
place failed. So if we detect that we don't have planes available, no
matter the format/modifier, we won't add the scanout tranche.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:01:13 -03:00
Leandro Ribeiro
8b83bb5ceb drm: fix issue with enum being wrongly used
FAILURE_REASONS_ADD_FB_FAILED is defined as (1 << 3), so when we are
accumulating "failure reasons" in a variable we don't need to do the bit
shift again.

This results in an issue, because (1 << FAILURE_REASONS_ADD_FB_FAILED)
results in (1 << (1 << 3)) == (1 << 8).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:01:13 -03:00
Leandro Ribeiro
3210cec531 drm: fix a few dma-buf feedback failure reasons
There are a few points in the code where we are wrongly using
FAILURE_REASONS_ADD_FB_FAILED, probably because we didn't have so many
"failure reasons" previously. This update such cases to use enum's that
make sense.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:01:13 -03:00
Leandro Ribeiro
b347af2ce0 drm: try other planes that may support fences
Do not skip all the planes if a single one of them do not support
fences. The other may do.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-16 10:01:13 -03:00
Loïc Molinari
a2dba7ff00 gl-renderer: Add extensions and features section to guidelines
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4be294bd69 gl-renderer: Move list init after feature flags setup
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
8d21829f49 gl-renderer: Add GPU timeline feature flag
This flag ensures support for both the GL_ANDROID_native_fence_sync
and the GL_EXT_disjoint_timer_query extensions at run-time. The GL
features log now reports that flag so the warning log has been
removed.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
169bb00bbd gl-renderer: Add color transforms feature flag
Replace gl_supports_color_transforms with a feature flag.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
7f01f9e18e gl-renderer: Add async read-back feature flag
Replace has_pbo with a feature flag.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
090c01da87 gl-renderer: Load GL function pointers with GET_PROC_ADDRESS()
Use the same macro than for the EGL function pointers.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
68a70bf9c4 gl-renderer: Order GL function pointers by extensions
Storing GL function pointers along with their associated extension
name allows to better track the function pointers declared.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
d7dcc2eaa7 gl-renderer: Remove GL extension booleans
Now that the GL extensions are stored in the gl_extensions bitfield,
there's no need to use booleans anymore.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
0026986cce gl-renderer: Check for GL_OES_EGL_image support
This commit ensures GL_OES_EGL_image is available before setting up
dma-buf renderer functions because it's not implied by the presence of
the EGL_EXT_image_dma_buf_import extension.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
aaf968bf58 gl-renderer: Slightly improve color transforms check
GL_OES_texture_3D isn't used because of the complexity implied for
correct OpenGL ES 2 support (see commit 734c2278), so there's no need
to check for it. The check also now avoids checking for
GL_EXT_color_buffer_half_float on OpenGL ES 3.2 which includes support
for 16-bit FP renderbuffers by default.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
02b4eccd05 gl-renderer: Add EGL_KHR_get_all_proc_addresses checks
The GL renderer supports OpenGL ES from version 2.0 to 3.2. It's meant
to correctly link on systems with only OpenGL ES 2, so OpenGL ES 3
symbols can't be used directly. eglGetProcAddress() is currently
defined to not support the querying of non-extension OpenGL ES
functions. Support for that is exposed by the
KHR_get_all_proc_addresses extension. This commit ensures OpenGL ES 3
function addresses can be retrieved by eglGetProcAddress() by checking
for that extension at run-time.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4ae493ff25 gl-renderer: Store GL extensions as flags
A new gl_extensions bitfield is added to the renderer to store the
flags supported by the GL implementation. This allows the GL renderer
to easily check for extension support whenever needed.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
db5c06bd16 gl-renderer: Remove branch never taken
Don't flag EGL_PBUFFER_BIT to get the EGL config if the
EGL_KHR_surfaceless_context extension isn't available. The branch is
never taken because the extension is required and if it isn't
available, the function would have already returned.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4f7f888d6c gl-renderer: Improve EGL_WL_bind_wayland_display extension handling
Get the EGL_WL_bind_wayland_display extension function addresses after
checking for extension availability.

Let the EGL display setup end before trying to bind the Wayland
display in gl-renderer.c. The EGL features log will now report the
extension as supported even if the bind subsequently fails, in which
case a warning is logged.

This commit also avoids calling query_buffer() if the display isn't
bound in fill_buffer_info(), it would otherwise fail or even segfault
if the EGL_WL_bind_wayland_display extension isn't available.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
0361ddf13e gl-renderer: Require EGL version >= 1.2
OpenGL ES 2 and some attributes like EGL_RENDERABLE_TYPE are supported
by EGL from version 1.2.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
94ca770c2a gl-renderer: Add explicit sync feature flag
This feature flag is for explicit sync support.

We replace the explicit sync warning by logging supported fence syncs
along with the report EGL features report.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
c29e2a7928 gl-renderer: Get function pointer addresses after extension check
Trying to follow the principle presented previously, this commit
ensures extension function addresses are retrieved once their
associated extension has been checked for availability.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
d38f45c6b6 gl-renderer: check for EGL_KHR_image_base extension
Get eglCreateImageKHR() and eglDestroyImageKHR() function addresses
depending on EGL_KHR_image_base availability.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
3d0d850980 gl-renderer: Add swap buffers with damage feature flag
This second feature flag ensures that either the
EGL_EXT_swap_buffers_with_damage or EGL_EXT_swap_buffers_with_damage
extension is available.

Some function pointer addresses are currently retrieved depending on
the availabilty of their associated extension and some others are
retrieved unconditionally. For consistency reasons, we'll try from now
on in this commit set to first load function pointers depending on the
associated extension availability and then flag features once all the
addresses are retrieved.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4a4a9b94d6 gl-renderer: Add no config context feature flag
This commit introduces feature flags. While an extension flag only
ensures the availability of an extension at run-time, a feature flag
ensures the availability of a minimal OpenGL ES version and/or
extensions in order to easily check for the availability of a specific
feature at run-time.

This first feature ensures the availability of either the
EGL_KHR_no_config_context or EGL_MESA_configless_context extensions.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
9d9d09a04d gl-renderer: Load EGL function pointers with a new macro
A new GET_PROC_ADDRESS() macro is added to get a function address at
run-time using eglGetProcAddress() and to assert() the address isn't
NULL at once.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
2852c92d89 gl-renderer: Order EGL function pointers by extensions
Storing EGL function pointers along with their associated extension
name allows to better track the function pointers declared.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
c56c104f7a gl-renderer: Remove EGL extension booleans
Now that the EGL extensions are stored in the egl_*_extensions
bitfields, there's no need to use booleans anymore.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
54dfa0743e gl-renderer: Store EGL display extensions as flags
The egl_display_extensions bitfield is added to store the display
extensions supported by the EGL implementation.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
12b9c65011 gl-renderer: Store EGL device extensions as flags
The egl_device_extensions bitfield is added to store the device
extensions supported by the EGL implementation.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
14d5406a90 gl-renderer: Store EGL client extensions as flags
A new egl_client_extensions bitfield is added to the renderer to store
the client flags supported by the EGL implementation. This allows the
GL renderer to easily check for extension support whenever needed.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
00f7bf91d8 gl-renderer: Add extension flag parser
This new utility parses extension strings and fills a bitfield of
matched flags. This will be used to store EGL and GL extension flags.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
39a199293e gl-renderer: Move versioning utils to internal header
Next commits will need this outside of gl-renderer.c.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Paul Pu
ddb6225338 desktop-shell: support disallow-output-changed-move
With this, when unplugging an extended display, the view displayed on
the extended display won't be re-positioned to other displays.

On some embedded devices, the views are often fullscreen displayed, even
on the extended displays. When disconnecting the extended displays, the
views are not desired to be moved onto the existing displays. Without
this change, we can see the view flash across the existing displays
even though the UI program hides the view as soon as it can, which is
unexpected.

Signed-off-by: Paul Pu <hui.pu@gehealthcare.com>
2025-01-14 08:05:14 +00:00
Leo Li
89f77176b6 backend-drm: Rename mm_has_underlay to mm_underlay_only
Now that secondary planes can be both underlay and overlay, this flag's
meaning also changed. Update it for correctness.

Signed-off-by: Leo Li <sunpeng.li@amd.com>
2025-01-13 16:05:31 +00:00
Leo Li
ca894ab44f backend-drm: Use plane's zpos_min to check for underlay ability
Previously, whether a KMS plane is underlay-able is determined by
whether it's zpos_max is < the primary plane's zpos_min. In other words,
a plane will only be considered underlay-able if its entire valid zpos
range is under the primary plane's lowest zpos.

This is too restrictive - it's possible for planes to have a valid zpos
range that spans below and above the primary's zpos range.

Therefore, allow planes to be used as underlays if their zpos_min is <
the primary plane's zpos_min.

In addition, force rendering on a view if it contains alpha, and is
occluded by a rendered view. If such a view is overlaid, it would render
with incorrect zorder. If it's underlaid, it would render with incorrect
alpha-blending due to hole-punching. Therefore, it must be rendered.

Force rendering prevents the view from going into
`drm_output_find_plane_for_view()`, which serves as an optimization, but
is also observed to prevent dmabuf feedback (derived from
`try_view_on_plane_failure_reasons`) from ping-ponging between two
values, causing some apps (like weston-simple-egl) to constantly
reallocate its buffers.

Because a plane can now - if supported - be used as an underlay, an
overlay, or both, add a `enum drm_plane_subtype` to differentiate
between them. Then, print it's subtype and underlay/overlay assignment
once a decision is made.

v2:
* Squash w/ patch to force rendering on alpha view occluded by rendered
  view
* Bring back plane subtype enum to be more expressive about plane
  capabilities
* Correct need_hole != false when a view's assignment changes from
  underlay to overlay

Signed-off-by: Leo Li <sunpeng.li@amd.com>
2025-01-13 16:05:31 +00:00
Colin Kinloch
5aae333bbb clients/window: Save pending allocation if mapping fullscreen
This means the window will appear at the set size when unsetting
fullscreen.

Signed-off-by: Colin Kinloch <colin.kinloch@collabora.com>
2025-01-13 17:03:48 +02:00
Colin Kinloch
0aeb8e5910 clients/fullscreen: Add option to map window fullscreen
Signed-off-by: Colin Kinloch <colin.kinloch@collabora.com>
2025-01-06 12:17:40 +00:00
Paul Pu
b2b8dd6215 libweston: fix crash when a client binds to a destroyed output
When the head is already destroyed, its global resource still can be
accessible by the client, which leads to a UAF crash.

This sets the head's global resource's user data to null before the
head is destroyed, and when the `bind` request is being handled but the
object's user data is null, do what we do when the the head's output is
null.

Signed-off-by: Paul Pu <hui.pu@gehealthcare.com>
2024-12-18 16:22:35 +08:00
Derek Foreman
5b35631545 desktop-shell: Fix background image
Commit 264c205add ignored the fact that a
background color of 0 should fall back to the background image, and
broke that case.

Fixes 264c205add
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-12-17 09:36:45 -06:00
Robert Mader
16e5406877 backend-drm: Add support for YUV plane color properties
The drm_color_encoding and drm_color_range enums are used for
YUV->RGB conversion and mirror what EGL_YUV_COLOR_SPACE_HINT_EXT
and EGL_SAMPLE_RANGE_HINT_EXT as well as our `yuva2rgba()`
shader func do. Add the necessary boiler plate for them.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-12-16 15:33:20 +00:00
Derek Foreman
264c205add desktop-shell: Make backgrounds fully opaque
Non-opaque backgrounds don't make sense, and cause rendering
problems.

Silently set backgrounds fully opaque, and remove any mention of
alpha from the man page.

Kiosk-shell already implicitly forces opaque backgrounds.

Old weston.ini with FF for alpha will always continue to work.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-12-11 10:03:37 -06:00