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>
The GL renderer allows the PipeWire backend to allocate DMABUFs that can be used
as renderbuffers and passed to PipeWire. This allows to avoid a copy of the
rendered output when using PipeWire.
PipeWire negotiates DmaBuf buffers using the SPA_FORMAT_VIDEO_modifier property.
Currently, the PipeWire-backend only announces and handles
DRM_FORMAT_MOD_LINEAR, which allows to share DmaBufs with consumers that have
modifier support for linear buffers. Consumers which could consume DmaBufs but
don't support modifiers (DRM_FORMAT_MOD_INVALID) are not supported. Moreover,
consumers that would benefit from other formats with modifiers, for example
tiled or compressed, aren't not supported, too.
Modifier negotiation can be added by extending the list of announced modifiers
and selecting and checking the proposed modifiers in param_changed.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Instead of letting PipeWire allocate the buffers, allocate them in the PipeWire
backend. This allows the PipeWire backend to define the type of the allocated
buffers, which will ultimately allow to allocate buffers that can be rendered
to.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Add a helper function for building the pod for the format.
This simplifies the creation of the EnumFormat params and to provide multiple
EnumFormats. Furthermore, it allows to optionally set add a Modifier to enable
DmaBuf negotiation.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The PipeWire backend is only able to render into renderbuffers and passing NULL
to the renderer is not valid. Don't try to use the renderbuffer if a buffer
without renderbuffer is dequeued from PipeWire.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
If the renderer uses the EGL_PLATFORM_GBM_KHR, the egl_native_display is already
a gbm_device and the renderer doesn't have to create another device.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The GL renderer is able to use a gbm_device to allocate gbm_bos, which can be
used as DMABUFs.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Support importing dmabuf buffers as renderbuffers and binding them to
FBOs. These can then be rendered to directly, or they can be blitted
into from the shadow render buffer.
How to best create those dmabuf buffers in the backend is an open
question and may vary depending on what external API the backend is
interfacing with.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The renderbuffer list is the reason for keeping a reference for the
renderbuffers in the gl-renderer. Add helper functions to make this explicit.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The GL renderer uses the bottom left corner as origin. Therefore, the buffers
must be flipped when using ReadPixels to have a image in the correct orientation
for screenshots. If the rendered buffers are directly passed to a different
application without going through ReadPixels, the rendered buffer appears upside
down.
Flip the rendered image in the FBO to fix the orientation when directly using
the rendered buffer. Update read_pixels to not flip the image in these cases.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
read_pixels may use the top left or bottom left corner as origin.
As the renderer may render the image upside down based on the y_flip variable.
read_pixels must read the image with the same origin as used by the renderer to
produce a correct image.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The GL renderer uses the bottom left corner as origin and several
transformations in the renderer assume this corner as origin.
Make this assumption explicit by introducing a y_flip variable that is used to
calculate transformation that are caused by this origin.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Avoid the calculation of the y-flipped coordinates when transforming the pixman
region to the vertex coordinates by initializing the projection matrix to
already include the y-flip.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Move the dep_gbm from the backend-drm specific meson.build to the common
libweston meson.build to be able to use it in other modules, too.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
image should be initialised to NULL in case image loading fails
between setjmp() and xzalloc().
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>