Commit Graph

2279 Commits

Author SHA1 Message Date
Pekka Paalanen a16598b038 backend-drm: make libdisplay-info mandatory
Making libdisplay-info a mandatory dependency allows us to drop this old
code.

Future new features will require libdisplay-info to work, and would not
get fallback code anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-07-15 14:29:02 +00:00
Derek Foreman 0a4f50a072 libweston: Remove output->scale
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>
2024-07-15 11:50:49 +00:00
Derek Foreman d500dbd4e2 xwm: Fix input regions
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>
2024-07-12 12:16:20 -05:00
Daniel Stone 3b7ef70d3a repaint: Requeue presentation feedback on failed repaint
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>
2024-07-12 17:50:22 +03:00
Daniel Stone f5074f261a view: Move psf_flags from weston_view to weston_paint_node
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>
2024-07-12 17:50:21 +03:00
Derek Foreman b56d887e34 rdp-backend: Fix more scale that should be current_scale
Commit c3321d5819 tried to fix this, but
I didn't thoroughly look for other uses of the wrong scale variable.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-11 12:37:25 -05:00
Chao Guo 5ce486037e backend-drm: Improve the way to find plane for view
1. remove the restriction on underlay planes when finding plane.
Because the view on the underlay plane can be displayed by drawing
a through hole on primary plane, so we can try underlay planes.

2. Add step to check if the view is assigned on underlay plane, When
it is successfully placed on a HW plane. Because we need to set the
underlay view pnode->need_hole to true so that gl-renderer
will draw a hole for it  when repainting.

3. Avoid assigning views to underlay HW planes when the backend format
is opaque and avoid assigning views with alpha to underlay HW planes.

4. when overlay plane is not enough, try to find underlay plane on
platform with both overlay and underlay plane.

Signed-off-by: Chao Guo <chao.guo@nxp.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-11 10:53:30 +00:00
Chao Guo 1065d23406 backend-drm: Improve plane assignment for underlay platform
On underlay platforms, the HW planes can be placed below the primary
plane, so some views that intersect with the renderer region can try
to be placed on the underlay planes. In order to assign these views
to underlay planes, the improvement is as follows:

1. Add current_lowest_zpos_overlay. Record the current lowest zpos
   of the overlay planes.

2. Add current_lowest_zpos_underlay. Record the current lowest zpos
   of the underlay plane. It is initialized to scanout_plane::zpos.

3. Add need_underlay to indicate whether to find underlay plane for
   view.

4. The views that intersect with the renderer region and underlay
   views should be assigned to underlay planes.

Signed-off-by: Chao Guo <chao.guo@nxp.com>
2024-07-11 10:38:43 +00:00
Chao Guo a7bfecd541 backend-drm: Add some underlay plane helper elements
Add 'is_underlay' in drm_plane, which is used to indicate whether the
HW plane is below the primary plane at the Z position.

Add 'has_underlay' in drm_backend, which is used indicate that there
are underlay planes in drm backend.

Signed-off-by: Chao Guo <chao.guo@nxp.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-11 10:38:37 +00:00
Chao Guo 827e22761b gl-renderer: Draw holes on primary plane for the view on underlay
Signed-off-by: Chao Guo <chao.guo@nxp.com>
2024-07-11 09:47:32 +00:00
Chao Guo 99eff1276a compositor: Consider punch holes when flushing damage
Signed-off-by: Chao Guo <chao.guo@nxp.com>
2024-07-11 08:59:03 +00:00
Chao Guo 0000c491f4 backend-drm: make the renderer produce client format matched image
When users need to place view on underlay HW plane, they need to set
the output format to alpha format.

This will cause gl-renderer to output a transparent image, allowing
through holes to work.

Signed-off-by: Chao Guo <chao.guo@nxp.com>
2024-07-11 08:59:03 +00:00
Chao Guo e1594110f0 compositor: Add a new member to the weston_paint_node
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>
2024-07-10 13:17:21 +00:00
Michael Olbrich 1c7cf4796a drm-backend: really reset/restart outputs of a failed commit
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>
2024-07-10 00:47:04 +02:00
Derek Foreman 661a7142ca libweston: Defer animation destruction to idle loop
If the first tick of an animation finishes the animation, then the
animation is destroyed before its creation function even returns.

Let's just defer that destruction to the idle loop so that can't happen.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-08 11:17:10 +00:00
Derek Foreman b3df77a627 libweston: Refactor deferred animation destruction
refactor the deferred animation destruction code into
defer_animation_destroy() so we can use it elsewhere later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-08 11:17:10 +00:00
Derek Foreman 05f199feea libweston: Move idle_animation_destroy to before frame handler
No functional change, we'll just need this function earlier in a
later commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-08 11:17:10 +00:00
Loïc Molinari dbf408791c gl-renderer: Move debug mode setup to dedicated func
This moves debug mode setup to a dedicated function because the
addition of new modes made it bigger.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari e512f5482d gl-renderer: Remove shaders debug mode
The shaders debug mode doesn't have much interest now that other more
specific debug modes show shaders too.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari b18a4948a3 gl-renderer: Add opaque debug mode
The opaque debug mode highlights damaged opaque surfaces with a blue
tint.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari a804ef00ee gl-renderer: Add damage debug mode
The damage debug mode highlights damaged surfaces with a red tint.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari a97307b19b gl-renderer: Add batches debug mode
The batches debug mode tints each batch of a repaint pass in a
different color in order to highlight batches.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari d1ee47361c helpers: Add FALLTHROUGH macro
Use gcc and clang's 'fallthrough' attribute instead of a comment to
fall through switch statements. This allows to request fall through
inside a block and prevents issues with preprocessed files.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari d11c72fee3 gl-renderer: Let debug modes request renderbuffer clear
The wireframe debug mode needs to clear the current renderbuffer in
order to clean up old wireframes lying around. This commit makes this
system generic for upcoming debug modes with similar needs.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari 6fe2221655 gl-renderer: Make wireframe a debug mode
In order to avoid the complexity of handling multiple debug modes at
the same time, this commit makes wireframe a proper debug mode. It
also uses the new tinting system to make the white wireframe pop over
a darkened damaged region.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari 42d68e9112 gl-renderer: Remove sub-mesh wireframe coloring
Don't color sub-mesh differently in wireframe mode. There's not much
interest in being able to distinguish the sub-meshes in a paint node
and this allows to simplify the logic by removing the color vertex
stream.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari fb03b825f2 gl-renderer: Add generic shader tinting support
Current green tint support is a hard-coded Porter-Duff premultiplied
blending of a green source (slightly skewed on the green channel) over
the updated damaged destination. This commit makes green tinting
generic by letting the shader user provide a custom tint color.

The goal is to reuse that system for the upcoming debug modes.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Loïc Molinari 6634849dd5 gl-renderer: Set up debug mode infrastructure
Set up debug mode initial infrastructure using a dedicated key binding
and make shaders debug a debug mode.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Marius Vlad f22ca6aecc backend-vnc: Remove the display when output is disabled
This prevents a potential abort yelling:

PANIC: ../subprojects/neatvnc/src/server.c: 2245: Multiple displays are not implemented. Aborting!

which happens because we never unregister the output, a mirror function
for nvnc_add_display().

Further more, we migrate nvc_close() to vnc_destroy() and check for
a valid output in vnc_client_cleanup(). Having a single caller in
vnc_shutdown() (which was migrated) we removed that entirely. Necessary
to avoid a use-after-free caused by nvc_close().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-04 14:07:41 +03:00
Derek Foreman 376b3952a0 libweston: Store shm buffer stride in weston_buffer
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>
2024-07-04 13:07:54 +03:00
Derek Foreman 0a483706d9 gl-renderer: Fix is_fully_opaque usage
is_fully_opaque takes precedence over opaque region, so we shouldn't
replace surface_opaque with the opaque region when is_fully_opaque is
true.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-03 08:26:06 -05:00
Derek Foreman bb0944c8be compositor: fix damage optimization
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>
2024-07-03 11:09:23 +00:00
Loïc Molinari 8c2d47f86d input: Fix release/debugoptimized build warning with gcc
Fix ‘old_sx’ and ‘old_sy’ used uninitialized.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-03 10:54:34 +00:00
Loïc Molinari 53cc781701 backend-headless: Fix release/debugoptimized build warning with gcc
Fix ‘ret’ used uninitialized.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-03 10:54:34 +00:00
Jeffy Chen 102b9a4de8 backend-drm: Support setting interlaced mode
Prefer using DRM mode with matched name.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-07-03 10:22:45 +00:00
Jeffy Chen 296b5975f3 backend-drm: Don't try to prepare a non-cursor view in renderer-only mode
Doing this might cause unnecessary DRM importing, which might result in
an error when the DRM's memory address mapping is nearly full.

Return before attempting to create drm_fb to avoid that, since it will
fail in the later check anyway.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-07-03 10:22:45 +00:00
Marius Vlad a7dad91d8f backend-drm: Do not create a head for invalid blacklight values
This most likely is a driver fail, as we shouldn't be getting a zero
value for max_brightness. Later on, this will be used to compute a
normalized brightness which would trip a with a division by zero.
Rather than fixing that up, just don't enable backlight support and
reportat that to the user that we have an invalid max_brightness value
and not backlight support.

Fixes: #878

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 09:57:49 +00:00
Derek Foreman 08c7015a32 pixman-renderer: Check if the shm_buffer is gone during attach
Moving attach to the render loop in c08a6ff8bd
caused this to crash if the shm buffer is destroyed between being committed
to a surface and being rendered.

Since we don't keep a reference to the buffer pool anyway, we might as well
just skip the attachment here.

Fixes: #922

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-03 09:53:12 +00:00
Michael Olbrich 08386229ad compositor: don't try to repaint while offscreen or sleeping
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>
2024-07-03 09:34:45 +00:00
Marius Vlad c6aa8c9b17 backend-pipewire: Nuke band-aid
With commit a1f8c49d5b 'compositor: repaint backends separately'
we will be repainting outputs independently so there's no need to keep
this band-aid on. Further more, the comment was most likely wrong.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 09:30:08 +00:00
Marius Vlad e271b2ed99 backend-headless: Nuke band-aid
With commit a1f8c49d5b 'compositor: repaint backends separately'
we will be repainting outputs independently so there's no need to keep
this band-aid on.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 09:30:08 +00:00
Loïc Molinari 4566eae245 gl-renderer: Improve wireframe rendering
Render wireframe within paint nodes instead of drawing lines in a
second pass. The wireframe is blended over the node in a single draw
call. This slightly simplifies the logic by removing the computation
of a second set of indices and enables wireframe anti-aliasing using
Celes and Abraham's "Fast and versatile texture-based wireframe
rendering" paper from 2011.

Celes and Abraham use a one-dimensional set of texture coords for each
triangle edge, 1.0 for the 2 vertices defining the edge and 0.0 for
the other vertex, which basically define barycentric coords. Texture
mapping and the mip chain is then exploited to give a constant-width
edge. The main drawback of the technique is that contour edges of
node's damage mesh are drawn half as thick as interior lines since
each triangle draws half of each line's thickness.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-27 20:40:37 +00:00
Loïc Molinari 0729ffbdb8 build: Add generic compiler builtins support
Wrap compiler builtins into shared functions with proper generic
implementations. __builtin_clz() isn't wrapped for now because its use
by screenshooter is pretty specific. It will be properly wrapped in
the next commit which needs a round up to the next power of 2
function.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-06-27 20:40:37 +00:00
Michael Olbrich f843ba34d1 drm-backend: limit reset/restart to output of a failed commit
When a commit fails, then only the outputs that where part of this commit should
be reset or restarted.

Otherwise an unrelated output that has another successful pending commit may be
restarted incorrectly. Then the output is in an inconsistent state and will
trigger an assertion:

weston: ../libweston/backend-drm/state-propose.c:627: drm_output_propose_state: Assertion `!output->state_last' failed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 21:39:32 +02:00
Michael Olbrich ef175c8ed4 backend-drm: handle commit failures correctly
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>
2024-06-21 15:35:30 +02:00
Michael Olbrich e8166e854d backend-drm: skip building atomic state and logging for "empty" repaints
With multiple backends or devices repaint_begin/repaint_flush may be called even
if no outout of a device will be repainted. This results in an "empty" drm state
without any output.
The actual commit to the kernel is already skipped but the drm-backend log is
still filled with "Beginning repaint"/"repaint-flush" messages and the scene
graph.

Use the new prepare_repaint() callback to determine if a backend needs to be
repainted and only create the pending_state if necessary.
Exit early in repaint_flush()/repaint_cancel() when no pending_state was created.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2024-06-21 15:35:30 +02:00
Michael Olbrich a1f8c49d5b compositor: repaint backends separately
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>
2024-06-21 15:35:30 +02:00
Philipp Zabel 060f010c35 compositor: access correct weston_buffer union field according to type
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>
2024-06-20 14:18:50 +00:00
Derek Foreman c3321d5819 rdp: Use current_scale instead of scale for input translation
current_scale appears to be the only one of the two updated on mode switch.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-06-20 06:28:37 -05:00
Marius Vlad 3184f5a2df backend-drm: Print out planes IDs that have been excluded
Makes things clearer which planes we have been skipped due to fmt/modifier.
All other debug sites print out the plane id, and the assumption might
be that we retried the same plane when it fact is a different one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-20 13:26:23 +03:00