Commit graph

11083 commits

Author SHA1 Message Date
Leandro Ribeiro
bf00fef07d frontend: add output-straight-alpha config option
This introduces a new .ini config option: output-straight-alpha. It's
currently only supported by the headless backend, and it forces
renderers to produce straight alpha framebuffers for headless backend
outputs.

For now, only the GL renderer supports creating straight alpha
framebuffers (the support was introduced in "backend-drm: add support
for KMS devices with only coverage blend mode").

This is useful mostly for testing, and the main motivation to add such
support in our DRM-backend and GL-renderer was to be able to support KMS
devices that only supports straight alpha framebuffers.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
56f1793f76 backend-drm: add support for KMS devices with only coverage blend mode
The majority of KMS devices support pre-multiplied encoded framebuffers.
But a few of them don't. This adds support for such devices.

In-shader blending is required for this, and it shouldn't work on
devices that don't support it. For now this works only with the
GL-renderer.

Note: this should never work with test quirks
gl_force_full_redraw_of_shadow_fb and blending_impl ==
WESTON_BLENDING_IMPL_FF.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
b71ff0f24a gl-renderer: return early when skipping test
In setup_shader_blending_or_shadow(), we can have a test quirk forcing
usage of in-shader blending. But not all devices support that.

Weston currently handles this by skipping the test on these devices
rather than taking the failure paths in
setup_shader_blending_or_shadow(). Otherwise, people would not be able
to locally run the test suite on devices that don't support in-shader
blending.

After deciding to skip the test, simply return from the function instead
of falling back to shadow buffer usage. Neither in-shader blending or
shadow buffer are going to be used, as
weston_compositor_exit_with_code(RESULT_SKIP) was already called.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
db68886cf4 gl-renderer: rename needs_fb_curves to has_blend_to_output
In function setup_shader_blending_or_shadow(), needs_shadow is a hard
requirement, while needs_fb_curves isn't.

When needs_fb_curves is true, we try to create an in-shader blender
(which makes use of fb curves) and, if that fails, we fallback to a
shadow buffer (avoiding fb curves completely).

The term "need" makes things a bit confusing, as the fallback path is
allowed. So rename needs_fb_curves to has_blend_to_output, making the
fallback path more natural.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
963ceeab5e gl-renderer: refactor into setup_shader_blending_or_shadow()
No behavior changes.

Function gl_renderer_output_create() currently has a bunch of code to
setup an in-shader blender or a shadow buffer. This moves such code to a
specific function setup_shader_blending_or_shadow(), improving
readability.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
9033fe18c1 backend-drm: select the best blend mode for plane
Before "backend-drm: add support for blend mode plane property", we had
no way to specify the blend mode for a plane on Weston, so we'd always
use the default one (PREMULT).

Instead, let's choose BLEND_MODE_NONE if possible (opaque content),
allowing the KMS driver to skip blending and being more efficient.

We add the support for using BLEND_COVERAGE in the next commits.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
339c8eef1f backend-drm: add support for blend mode plane property
This is used in the next commits.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
21126325a8 backend-drm: do not init color encoding and range props with __COUNT
Let's follow the code design of the other properties: init them with
_DEFAULT. In the setter function we ensure they are >= 0 and < COUNT,
just like we do with other properties.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
772635aba7 shared: add weston_assert_enum_ne()
Add an assert macro to check that two enums are not equal. Also adds the
respective test_assert_enum_ne().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Leandro Ribeiro
f013aa4125 shared: rename weston_assert_enum() to weston_assert_enum_eq()
In next commit we'll add weston_assert_enum_ne(), so let's rename the
existing weston_assert_enum() to weston_assert_enum_eq() to make the
names consistent.

This also renames the test asserts (test_assert_enum() to
test_assert_enum_eq()).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-16 16:45:20 +03:00
Derek Foreman
950534d617 output-capture: Don't validate width and height for writeback
Allow width and height to be different than the real screen size
when performing a writeback screenshot.

If the writeback device automatically scales to buffer size, this
will let us use that feature.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-16 01:03:52 +00:00
Derek Foreman
79c55e2dbd drm: Don't validate writeback buffer size
Just let whatever happens happen - it could be EINVAL.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-16 01:03:52 +00:00
Derek Foreman
3c902866fc clients/screenshot: Allow forcing a buffer size from the command line
This doesn't currently have any defined behaviour, and could result in
client termination.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-16 01:03:52 +00:00
Derek Foreman
8c4a7de679 clients/screenshot: Remove temp vars from struct buffer_size
These don't really need to be here, they can be local variables instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-16 01:03:52 +00:00
Derek Foreman
79896a521b trace: Fix paint node skipping annotations
We've built up the annotation, but skipped the commit for it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-15 11:32:20 -05:00
Derek Foreman
c3af35c977 compositor: Fix "empty" frame callbacks
Firefox and EFL applications use surface commits with no state change other
than a frame callback.

The dirty-bit based repaint skipping optimization in commit
73e0bb2829 stopped that from working.

Add a new dirty bit for frame callbacks so these clients schedule something
to fire the callback again.

Fixes 73e0bb2829
Fixes #1114

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-15 10:18:09 +03:00
Pekka Paalanen
fe46e43c36 drm: program color pipeline with plane_add_prop()
Drop the open-coding of plane_add_prop() in
drm_color_pipeline_program().

The debug print ordering changes, but one can see the beginning of the
colorops in the pipeline by looking for the colorop whose ID gets
programmed into WDRM_PLANE_COLOR_PIPELINE.

struct drm_plane::pipeline_props_id becomes unused and is removed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
7fbf121043 drm: swap debug format for KMS request builders
The values were printed as "name (hex)", but the property IDs were
printed as "dec (name)". This started to look really funny with the enum
names.

Let's just do "prop-name (raw id) -> fancy-value (raw value)" instead.
Looks much nicer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
d493e2519f drm: drop colorop_program()
Simplify the code by calling colorop_add_prop() directly. The reported
error details remain the same.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
d9d32576df drm: store WDRM curve in drm_colorop_state_object
This allows to use colorop_add_prop_enum() for WDRM_COLOROP_CURVE_1D,
reducing the code complexity.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
374649cd8d drm: split colorop_program()
Enforcing the colorop, that is, ensuring it is not bypassed, is common
to all colorops, so we can pull it into front.

The aim is to get rid of colorop_program(), because it assumes that
every colorop has only one property to program. This makes using
colorop_add_prop_enum() difficult.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
e84fa5fd86 drm: add colorop_add_prop_enum()
This is a specialized alternative to colorop_add_prop() for setting
enumerated property values. The debug print will print the value name
which helps humans to make sense of it.

set_interp() is replaced with this, colorop_add_prop_enum() does the
same checks and more while not being any less type-safe.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
e1a4c07b95 drm: add plane_add_prop_enum()
This is a specialized alternative to plane_add_prop() for setting
enumerated property values. The debug print will print the value name
which helps humans to make sense of it.

This corrects an UAPI confusion by doing a proper dynamic mapping
from property strings into integers used in the KMS UAPI.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Pekka Paalanen
dcce0a2737 drm: add connector_add_prop_enum()
This is a specialized alternative to connector_add_prop() for setting
enumerated property values. Using it will save some code in the callers
and the debug print will print the value name which helps humans to make
sense of it.

The bounds checking is concentrated into the new function too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-12 13:45:10 +00:00
Leandro Ribeiro
c36ecb59dd backend-drm: ref count struct drm_color_pipeline_state
drm_plane_state_duplicate() currently shallows copy the pipeline_state
pointer. The problem is that later the duplicated plane_state gets
destroyed, and it ends up destroying the color pipeline state as well.

So let's ref count to the color pipeline state in
drm_plane_state_duplicate(), avoiding use-after-free crashes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-12 10:35:02 -03:00
Leandro Ribeiro
349d22f952 backend-drm: add ref_count to struct drm_color_pipeline_state
And also rename drm_color_pipeline_state_destroy() to unref().

In the next commit we'll make use of this. For now this has no behavior
change.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-11 17:20:39 -03:00
Robert Mader
90a3e2fd5a backend-drm: Add command-line option to disable state reuse
Add `--disable-drm-state-reuse`, forcing a DRM state rebuild on every
frame. This can be handy in for debugging with `weston-debug
drm-backend`.

In order to disencentivize usage as a workaround in case of bugs,
require `--debug` to be enabled as well.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-06-11 16:57:19 +03:00
Derek Foreman
b518c3bf1a man: Document 'color-format' entry in the output section
This is for configuring the 'color format' DRM connector property.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-06-10 18:32:22 +03:00
Derek Foreman
4615d2a779 backend-drm: Add support for the DRM connector property 'color format'
This is the last part to support the 'color format' DRM connector.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-06-10 18:32:22 +03:00
Pekka Paalanen
67f8d9d6a6 tests/image-description-query: verify descriptions
Set up a few different image descriptions on the output, and ensure that
the protocol delivers them as output and surface-preferred image
descriptions correctly.

Expands test coverage. Found one existing bug fixed by
	"color: fix sending power TF exponent".

I was lazy, and did not bother checking the ICC file contents.

This prepares for testing the surface-preferred parametric image
description, but first it will need the compositor implementation.

The config file formatting should be useful for future color managed
screenshot tests.

There is no need to test all the feature and rendering intent
advertisements, that's done in color-management-protocol-test.c and
protocol errors should catch lack of support anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
e900431b8e tests: add Display-P3 ICC profile
It will be nice to have an arbitrary but proper ICC profile for testing
ICC profile loading.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
e85ec39e4f tests: color parameters to color_util.h
These will be needed in more than one test program, probably three.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
a5b3a4a4aa tests/harness: expose enum image_descr_info_event
Some tests will want to verify that some optional events were actually
received.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
a13bd2c03f tests/harness: forbid image_descr_info_done twice
Catch if the compositor sends this twice.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
943c39ba8e tests/harness: fix double-closing ICC fd
image_description_info_destroy() closes it, and we might want to inspect
the fd in a test. Do not close it on 'done' event.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
770865205d tests/color-management-protocol: add unset_inert_surface_image_description
Extend test coverage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
f6fc4e8e5f tests/color-management-protocol: add unset_image_description
Extend test coverage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
24fbc9c8aa tests/color-management-protocol: add failed_image_description_get_info
Extend test coverage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
2f9cab2047 tests/color-management-protocol: add set_too_short_icc_fd
Extend test coverage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
0459808d6e tests/color-management-protocol: use no-op renderer
Never need to actually render here, so lets save the effort of
intializing GL.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
5fe82ab475 noop-renderer: claim all capabilities
Claim all renderer capability flags. Whether the renderer actually
implements these or not cannot be discovered, because the no-op renderer
never produces an image that could be checked.

I leave explicit sync out, because I believe that would need some stubs
to create phony fences that are externally observable.

With these flags, color management protocol tests won't need to
initialize GL-renderer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
5fa20c75ca coverage: exclude assert branches
Assertions have two branches, and the fail branch must never be taken,
so it does not make sense to count them in branch coverage. Ignore all
branches on lines matching weston_assert_ regular expression.

The RE must match from the beginning of the line, hence allow leading
whitespace. This is a Python 're' module usage thing. Unfortunately it
is impossible to pass a backslash in a meson.build file as an argument
to a command[1], so let's use a configuration file.

[1]: https://github.com/mesonbuild/meson/issues/1564

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Pekka Paalanen
73a57eba64 color: fix sending power TF exponent
Forgot to do the encoding for the wire. Found by a new test in
development.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 14:11:27 +00:00
Daniel Stone
4b67563783 drm-backend: Remove transparent-to-opaque FB substitution
When we want to scan out a transparent buffer, but know from the
view/surface opaque regions that it's in fact fully opaque, we can help
the hardware out by naming the framebuffer as opaque.

Unfortunately this optimisation has been unsound for a while now.

Firstly, drm_fb caching makes the optimisation racy. We need to cache
the drm_fb for performance reasons, because constantly mapping and
unmapping buffers from the display controller IOMMU can be
excruciatingly slow. But caching it means that our selection of format
is invariant across the buffer's lifetime; we can take an alphaful
buffer, see that it is currently opaque and map it to an opaque
framebuffer format. If the view later becomes non-opaque, we'll still
try to reuse the opaque framebuffer, which is wrong.

Secondly, modifiers may invalidate the optimisation. The observation
that XRGB and ARGB can be transposed for all(.a == 1.0) only holds true
for linear buffers. Non-linear formats such as AFBC and DCC may have
completely different representations for XRGB and ARGB, so it's unsound
to just flip between the two.

The fix for modifiers would be to make the optimisation conditional on
modifier == LINEAR, but since the fix to the temporal soundness issue
with caching is to delete what's there and maybe rebuild it differently
later, let's just do that for now.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2026-06-10 14:22:49 +03:00
Pekka Paalanen
ca8ff7acc9 gl-renderer: try to avoid shader swizzle on ES 2
From the bug report:

	We observed a significant performance regression on OpenGL ES
	2.0 hardware (NXP i.MX8M Mini, Vivante GC NanoUltra) after
	upgrading from weston 14 to 15 that glmark2-es2-wayland scores
	dropped by approximately 23%.

	We bisected this to commit be5c662b ("gl-renderer: Add OpenGL ES 2
	support to texture swizzles"). The texture2D_swizzle() function
	introduced in fragment.glsl uses dynamic vector component indexing
	which is very expensive on ES 2.0 GPUs that lack native support
	for it.

When the component re-ordering is identity, avoid the swizzle
index uniform completely by using a shader without it.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/work_items/1120
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-06-10 13:44:14 +03:00
Derek Foreman
f3e30e4692 surface-state: Fix assert firing when subsurfaces have no views
I've not been able to reproduce this, but have a report that this fires
when running Chromium on aarch64.

It seems plausible that we can get here when none of the subsurfaces have
views, and thus the flag won't be set.

Let's make the assert conditional on having views.

Fixes 6a280a8f
Fixes #1117

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-08 21:14:26 +01:00
Derek Foreman
54a5c59b09 drm: Display modifiers in the state dump
It can be useful to know what modifier is being used for a plane's content.

This can mostly be inferred from the paint node dumps in the scene graph,
but that still doesn't tell us what modifiers the renderer's buffer uses.

Dump it next to the format.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-08 21:48:56 +03:00
Derek Foreman
c7e8339b7b drm: Keep track of modifier names in drm_fb
Create the modifier name string at bo creation time and free it at end
of life.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-06-08 21:48:56 +03:00
Leandro Ribeiro
0a3324d0cd tests: add alpha modifier tests
This adds two new test files:

alpha-modifier-smoke-test.c: contains tests exercising the mechanics of
the protocol, expected errors for misbehaved clients, etc.

alpha-modifier-test.c: contains tests to ensure that the visual changes
from an alpha modifier surface are working as intended. It exercises all
renderers.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00
Leandro Ribeiro
c724914260 tests: move surface_commit_color() to test client helper
This function is duplicated all over the test files. This moves it to
weston-test-client-helper.c and removes the duplicated code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-06-08 16:59:34 +03:00