This borrows heavily from the Mesa project's perfetto instrumentation, and
for now just adds perfetto to the build and a collection of useful macros
for adding trace points.
The atomics have been cargo culted in - Weston currently has no need of
such things, but I guess they're harmless for now and could be useful if
we consider threads in the future.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
I'll be adding perfetto instrumentation, which will want to know the
timepoint name without having to parse it.
For now, just pass an enum and add a helper function to convert to strings.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
It's currently assumed by backends that renderers discard
renderbuffers on resize. This commit introduces a new
weston_renderbuffer_discarded_func callback that must be passed at
renderbuffer creation in order to be notified of discarded events from
the renderer. This discarded event could potentially be reused later
by renderers on other occasions without having to change backends once
they get proper support for that.
On output resize, once a discarded event handler fails (returns false)
on a renderbuffer, all the remaining renderbuffers in the output list
go stale and weston_renderer_resize_output() ultimately returns false
for backends to be notified of the failure.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Renderbuffers currently have a libweston-internal base data structure
with a ref-counting system to handle their lifetime. The problem is
that renderers keep a ref to all renderbuffers in a list per output
(to deal with damages) and that it prevents backends from releasing
renderbuffer resources when not needed anymore. Renderbuffers are then
only released (last ref removed) when the output is destroyed or
resized. dma-buf renderbuffers even expose a dedicated function
remove_renderbuffer_dmabuf() to explictly request the release of their
resources.
This commit proposes to get rid of the ref-counting system by exposing
a single entry point to explicitly destroy all types of renderbuffers
from the renderer.
Instead of removing a renderbuffer from its output list and dropping
its ref when the output is resized, this commit also introduces the
concept of stale renderbuffers which consists in releasing the
resources of a renderbuffer when it's discarded by the renderer while
keeping it in the output list, with a stale state, until it's
explicitly destroyed.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
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>
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>
If the scene graph is empty at repaint the renderer will do nothing to the
buffer. On some platforms this results in displaying garbage, and on
platforms where we use frame buffer compression we can cause longer
lasting visual problems.
Make sure we never get here with an empty scene graph.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
A client can call get_xdg_output() at any time. If the output was destroyed,
then all output resources are orphaned. This includes clearing the user data of
the resource.
This can happen, for example, when a monitor or HDMI switch quickly toggles the
HDMI hotplug pin.
So check if a head is associated with the resource. If not, just create the
resource and then return immediately.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Doing these in the wrong order breaks content protection, and breaks
placing direct-display paint nodes on underlays.
Fixes: 827e2276 ("gl-renderer: Draw holes on primary plane for the view on underlay")
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
As weston_windowed_output_get_api needs ARRAY_LENGTH() move helpers to a
libweston/ so other users can re-use that instead of re-defining these
all over. Easier for other front-ends to make use of them.
With this change windowed-output-api.h also includes the helpers header.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
We can startup with the display already in type1 content protection mode.
When this happens, we call weston_output_dirty_paint_nodes() on a display
that hasn't yet been enabled. The paint node list isn't initialized yet,
so we crash.
We don't actually need to touch the paint nodes here anyway, as
weston_output_damage() ensures a repaint if the ourput is enabled, and
weston_output_dirty_paint_nodes() just forces calculation of things
unrelated to protection, and we'll override most of that in
maybe_replace_paint_node() if necessary when we get there.
Just drop the weston_output_dirty_paint_nodes() call to stop the
crash.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Since c4eb15d453 we keep a copy of
native mode parameters, however we forgot to initialize the
native mode parameters in some situations, which breaks the
output mirroring code when it sees uninitialized data.
Fixes c4eb15d453Fixes#949
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This would allow to screen-share a particular output like the
following:
[output]
name=vnc
same-as=DP-5
[output]
name=rdp-0
same-as=DP-4
[output]
name=pipewire
same-as=eDP-1
Both 'vnc', 'pipewire' 'rdp-0' remote outputs would then be a
screen-share 'DP-5', respectively, 'e-DP1', or the 'DP-4' DRM output.
Currently, this is intended only for VNC, RDP and PipeWire remote outputs.
This patch exports weston_output_set_position(), and uses that for
overlapping a remote output with a native DRM one, rather than using
weston_output_move() as that has a side-effect when reflowing outputs
from shells.
Further more creating this remote output is driven entirely by compositor
signal events such that enabling an DRM native output would enable the
remote output, while disabling the native would have the same outcome
for the remote one.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This avoids dereferencing a possible stale pointer, and allows
retrieving the modeline/refresh later on when one needs to retrieve
those values. This is a temporary band-aid.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
commit 5fe02dc68e partially resolved the issue in #937 by bringing back
the old band-aid solution for layer moves. However, since the events of
commit bf228370ff and following commits we have a problem with
subsurfaces leaving garbage behind when minimized - see #366 which was
probably fixed for a while then became broken again.
When we minimize a view that has subsurfaces, by moving it to a layer
outside of the scene graph, we need to be sure to handle the subsurface
views - which follow their parent's layer instead of having
weston_view_move_to_layer() explicitly called.
Do this by assuming layers with an empty link are not part of the scene
graph and unmapping views when they're moved to these layers. This will
recursively unmap the subsurface views.
We can now remove the band-aid paint node destroy, as the unmap process
will destroy paint nodes as appropriate.
Fixes 5fe02dc68eFixes#937Fixes#366
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
For the following sequence, weston will not trigger a repaint:
1. create the main surface
2. create another surface and attach it as a sub-surface to the main surface
3. set the sub-surface to desync
4. attach a buffer to the main surface and commit it
5. attach a buffer to the sub-surface and commit it
Step 5 should cause the sub-surface to become mapped. However, Weston fails to
schedule a repaint in that case, so the sub-surface will not appear until
something else causes a repaint on that output, e.g. the main window.
And sub-surfaces are special when it comes to mapping because
weston_surface_is_mapped() will not return true until the parent surface is
mapped as well. So right now, weston_surface_map() may be called multiple times
and it will send the map_signal each time.
So to fix all this and make it clearer:
1. define a separate weston_surface_start_mapping() function to make it clearer
that the (sub-)surface may not be fully mapped at the end
2. check surface->is_mapped explicitly to ensure that the sub-surface is only
mapped once.
3. call weston_view_update_transform() for all views of the sub-surface when the
parent surface is already mapped to ensure that a repaint for all relevant
outputs is triggered.
The new test checks this by waiting for a frame event for the first subsurface
commit. Without these changes, the test will block until it is killed by the
timeout.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
The main differences is the split of cm_surface functionality with
cm_surface and cm_feedback_surface.
There can only be one cm_surface to set, unset image descriptions. When
cm_surface is destroyed, the image description is automatically unset.
There can be multiple feedback_surfaces for one surface though.
Now the "preferred_changed" signal can be an initial event.
Creator params now have a new request: set_luminances.
Signed-off-by: Joan Torres <joan.torres@suse.com>
Commit f2486c8b96 removed some helper functions for layer changes, but
the loop to delete stale paint nodes was elided.
We need to delete paint nodes on a layer change to ensure damage is tracked
properly.
Fixes f2486c8b96Fixes#937
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This new public API is intended to deliver EDID etc. information to the
frontend. The use case here is display colorimetry, to help the frontend
craft output image descriptions (color profiles).
The frontend will need to link to and use libdisplay-info to make use of
this. This avoids having to replicate in libweston the high-level API
that libdisplay-info already has. The libdisplay-info API is also likely
to be extended, and it is not nice to play catch-up with it.
As a di_info can only be destroyed by calling into libdisplay-info,
libweston core can only ensure it has already been freed. There is not
enough reason to make libweston core depend on libdisplay-info, only the
DRM-backend is.
It will be up to DRM-backend to ensure display_info is updated and
device_changed is set only when necessary.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Instead of attaching and flushing damage when performing
weston_surface_copy_content, just return the contents as the renderer
currently knows them.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We've got output->scale, output->current_scale, output->original_scale and
output->native_scale.
output->scale is apparently just a weird temporary variable, and has led
to some confusing bugs.
Remove it entirely.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
commit 0f99e081c4 broke xwayland client
input regions. The xwayland window manager sets input regions in the
pending state without going through the function that sets the
WESTON_SURFACE_DIRTY_INPUT bit.
Just add the dirty bit to the xwm code.
Also, fix the whitespace error the same patch introduced.
fixes 0f99e081c4
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Whenever an output repaint fails, we leave the presentation-feedback
requests hanging. Requeue them back to the surface so the next repaint
attempt can collect them.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Fundamentally, the flags are a property of each paint node, rather than
each view as such. Move them over there so it gets a little less painful
to work with.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Add a boolean member named need_hole in weston_paint_node, which is used
to indicate whether the renderer should draw through hole on primary
plane when rendering.
For paint node whose view are placed on the underlay plane, this
member should be set to true, otherwise it is false.
Signed-off-by: Chao Guo <chao.guo@nxp.com>
This reverts f843ba34d1 ("drm-backend: limit
reset/restart to output of a failed commit") and actually solves the problem
correctly.
The pending_state is no longer valid at this point, so it cannot be used to
determine the outputs of the current commit. So only clear will_repaint when
starting to repaint, so it can be used to determine which outputs of a device
were actually repainted and use it to reset/restart those outputs.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
After c08a6ff8 moved attach to the render loop, we have a bad situation
when clients delete an attached shm buffer. We try to query the stride
at attach time, but the shm_buffer has been destroyed, and we crash.
Instead of carefully fixing that, I've instead stored the stride at
buffer creation time (as we already do with buffer width and height).
This lets attach succeed in the gl-renderer, keeping the old texture data
available for any upcoming rendering.
Fixes: #927
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Tested-by: Connor Abbott <cwabbott0@gmail.com>
We can skip posting damage beneath planes that are fully translucent,
but that doesn't mean we can skip posting damage beneath planes that
are not fully opaque.
Add a check for content that is entirely blended, and use that instead.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
weston_output_schedule_repaint() already checks the compositor state but
idle_repaint() is called asynchronously so the state may have changed.
Check the state again and abort if necessary.
Without this the DRM compositor might execute a modeset in
drm_output_start_repaint_loop() which should not happen while sleeping or
offscreen.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Currently only the return value of the last backend that implements
repaint_flush() is actually used. That only works because the drm backend is the
only backend that implements repaint_flush().
In the drm backend only the return value of the last device is used. And if a
failure is actually detected, then all repainted outputs of all backends are
reset. This can trigger asserts:
weston_output_schedule_repaint_reset() (or _restart()) will change the state of
the output but the backend that did not cause the failure will still call
weston_output_finish_frame().
The same thing can happen with multiple devices in the drm backend. Or outputs
get stuck if an error is dropped.
Since the drm backend is the only one that implements repaint_flush() anyways,
move the failure handling into the backend and make it device specific.
This way only the outputs that need it are reset.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
When a repaint is triggered then not all backends may have outputs that need to
be repainted.
Check which outputs will be repainted first and then repaint only the backends
that need it.
This way unnecessary repaint_begin() and repaint_flush()/repaint_cancel() can
be skipped and errors are handled for each backend separately.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Stop writing weston_buffer::shm_buffer when weston_buffer::type is not
WESTON_BUFFER_SHM. Instead, explicitly write to the union field
that corresponds to the buffer type.
Also add a comment why we clear the shm_buffer/dmabuf/legacy_buffer
pointer here.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
With attach only being called at render time, the dmabuf can be deleted
along with its private data before we attach for the first time.
Let's move the first-time logic into its own callback to call at
buffer setup time instead.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
By moving this here we can use the information to disable damage tracking
for placeholder surfaces, as well as render them entirely opaquely.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We'll be doing censoring via the paint node update code shortly, so
let's make sure we notice when protection changes.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Since we only call this from the paint node update code now, we can pass
the paint node directly.
A bit of internal refactoring is required to support copy_content.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Instead of doing this in several places, just do it when we're updating
the paint nodes in the repaint loop, or when we're about to copy
content via weston_surface_copy_content().
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
For now we're just continuing to make the view dirty, but there will be
more dirt in the future.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Currently we're passing in a surface, a buffer, and an output. All of
these things are available in the paint node.
Further, if we pass in the paint node directly, we don't have to walk
a list of paint nodes to figure out if the texture is used in the
upcoming repaint.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
There are no longer users of these two function. With the
weston_view_move_to_layer() helper being capable of doing this it is time
to retire these entirely to avoid users using them.
Release notes should mention that migrating to the newer helper will be
required when bumping to Weston 14.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This changes the callback frame list insertion after paint node late
update takes place in order for to the visibily region to be modified.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
When we lift planes entirely out of the scene graph, paint node visibility
calculations become "per plane". This means that when we lift something
onto a paint node, anything beneath it will be redrawn in response to
client side damage even if the lower surfaces are occluded.
Instead, keep the scene graph together and make the paint node visible
regions be their visibility within the global scene graph.
This has the side effect of plane motion causing redraws, to update
regions they've been obscuring. My assumption is that moving planes
is less frequent than damage being posted beneath an overlay, and
that we'll be more efficient for normal use cases this way.
An optimization is in place to prevent redraws when moving transparent
planes, as they haven't been occluding updates.
In addition to theoretically removing some wasteful rendering time, this
also simplifies damage accumulation.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We've forgotten to set this up in some backends, so let's just do it in
weston_compositor_init_renderer().
The headless backend used to fail out if linux_dmabuf_setup() failed, but
had no reason to do so, so just remove that to make the code common.
Suggested by cwabbott on irc.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This API is mostly for use by the DRM-backend. Colorimetry mode is is
the KMS connector property "Colorspace" which defines the video signal
encoding colorimetry. A video sink indicates the supported modes in EDID
or DisplayID.
This patch adds the libweston API that allows backends to indicate the
supported modes for the frontends, and frontends to set the mode to be
used by backends. Colorimetry mode does not directly affect color
management inside Weston, it is only metadata for the video sink. It is
the frontend's responsibility to set up an output color profile that
agrees with the colorimetry mode. (That API has not been implemented
yet.) eotf_mode will be the same.
There is only one reason to make this a libweston core API instead of
a backend-drm API: when wayland-backend gains color-management protocol
support, meaning it can forward WCG and HDR content correctly to a
host compositor, the supported colorimetry modes can be determined from
the host compositor's supported color-management features, allowing the
guest Weston to pick some other output image description than the host
compositor's preferred image description. This likely allows only a few
other choices from standard colorspaces, so it's possible this isn't
sufficient for that use case.
Either way, it is easy to just copy the eotf_mode API design, and since
colorimetry_mode and eotf_mode go together, let both have the same API
design. It is possible to convert this to backend-drm API later.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>