clang 17 complains that `fourcc` in `gl_renderer_fill_buffer_info()` is
uninitialized in the default case, because it fails to recognize that
if hit, that case will `assert(0)`. To get rid of this complaint, we can
just apply clang's suggestion and initialize the variable with 0 when
declaring it.
Signed-off-by: Max Ihlenfeldt <max@igalia.com>
After freeing the renderer, clear the compositor->renderer pointer to
avoid use-after-free errors.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Translate damage extents used to calculate glReadPixels rectangle from
global to local coordinates.
Fixes: b1606a9f2c ("gl-renderer: support automatically downloading FBO renderbuffers")
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
clip_quad() is a dedicated clipping function for quads that doesn't
depend on any GL renderer internal structures. It can be moved out to
the clipper to be called by both the renderer and the clipping test
client without having to duplicate code.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Since both the surface rect and the transformed quad are axis-aligned
in the simple clipping path, non-zero area detection can more
efficiently be checked post-clipping by comparing opposite edges.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Add a basic check to let the clipper take the simple axis-aligned path
when nodes are solely transformed with a translation and/or a scaling.
That makes some nodes like sub-surfaces (which always have their
transform enabled) take the fast path in the common case.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Move vertex clipper back to single-precision floating point
intermediates. Since positions are sent down the graphics hardware as
single-precision values, this prevents useless conversions between
single and double precision values and lets compilers fit twice as
much data into vector registers. It also removes a copy by letting the
clipper store vertices directly into the vertex buffer.
This is mostly reverting the conversion to double-precision that
happened along with the switch to the weston_coord struct for vertex
coordinates (commit 10e70bf23c).
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Let the graphics hardware handle the transformation from surface
position to texture coordinates. Paint nodes now have a single vertex
position attribute from which texture coordinates are derived. A new
vertex shader variant handles the transformation.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
The clipper transforms dirty rects to surface space before clipping.
Each dirty rect is transformed by the same matrix for each surface
rect. This change decouples the transformation and the clipping code
to transform and compute the bounding box of dirty rects just once.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Clip dirty rects to surface rects in surface coordinate space.
Dispatch vertices in surface coordinates and let the graphics hardware
handle the transformations. Clipping in global coordinate space
implies a useless roundtrip on the CPU to get the clipped polygons
back in surface coordinates for the buffer transformation. Clipping in
surface coordinate space prevents that.
This might seem counter-intuitive at first because in surface space
it's the dirty rects that are clipped to axis-aligned surface rects,
while it's the opposite in global space.
The projection matrix now combines the view and the output transforms.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
For software backends like VNC, support downloading the FBO renderbuffer
contents via glReadPixels automatically at the end of repaint_output.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Add support for creating surfaceless outputs and rendering to FBOs.
The backend has to create FBOs with the create_fbo API and pass the
resulting weston_renderbuffer handles to repaint_output.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Remove the now unused previous/total_damage regions and the
buffer/border_damage arrays, as well as the output_get_damage and
output_rotate_damage functions.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Create dummy renderbuffers to track surface buffer damage on
demand. The renderbuffer representing the surface buffer that
is currently rendered to is inferred using buffer age.
This aligns damage tracking with the Pixman renderer and will
simplify adding FBO rendering support.
The previous/total_damage regions and the buffer/border_damage
arrays are now unused except for validation.
They can be removed next.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Split the buffer age query out into a separate function.
The following patches will replace the remainder of the
output_get_damage function.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Output repaint uses a pair of fence syncs to profile GPU execution by
retrieving their timestamps once signalled. While the end timestamp
can be rather inaccurate in some cases (drivers reusing sync objects
from previous command buffers), the begin timestamp is never correct
because fence syncs are signalled on command buffer completion.
Get rid of the begin fence sync and use the EXT_disjoint_timer_query
extension to measure the actual repaint duration and extrapolate the
begin timestamp from the end one.
Fixes#342
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Remove the independent x, y floats from the clipping code and replace them
with struct weston_cord. This includes the polygon8 structure as well.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Whilst GLSL requires highp for the vertex shader stage, highp is
optional for the fragment shader.
Make sure that we work in highp by default during the vertex shader
stage, using either highp or mediump for the texcoord varying according
to what the fragment shader supports.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Update users of the old coordinate space conversion functions that take
x, y pairs to the new weston_coord versions.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Use struct pixel_format_info pointers instead of uint32_t drm fourcc
values at the API surface for output and image creation.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Let weston_output_update_capture_info() take a uint32_t drm_format
parameter directly instead of const struct pixel_format_info *format.
No other fields apart from the format were used from this structure.
Without this, callers may have to unnecessarily look up the pixel
format info in cases where the DRM fourcc is already available.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Add a struct weston_renderbuffer parameter to repaint_output and make
backends set the pixman image renderbuffer through this parameter
instead of using pixman_renderer_output_set_buffer()
Turn pixman_renderer_output_set_buffer() static.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
The blit_shadow_to_output() function leaves the generic vertex attrib
arrays 0 and 1 enabled. This commit disables them for consistency with
the other drawing calls of the renderer.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Generic vertex attrib arrays 0 and 1 are constantly enabled across the
entire renderer. This commit enables them:
- once per output repaint instead of once per view repaint,
- once for the 4 borders instead of once for each border,
- once for all the shadow regions instead of once for each region.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
The blending func is constant across the entire renderer. This commit
sets it once per output repaint instead of once per view repaint.
Signed-off-by: Loïc Molinari <loic.molinari@gmail.com>
Move the struct gl_renderer_interface pointer from the backends into
the weston_renderer structure. The interface struct only contains
function pointers that never change, so make it const.
Load and initialize the GL renderer in libweston instead of in the
backends, using the new weston_compositor_init_renderer() function.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
It should harmlessly fail or do nothing, but seeing attempts to set
uniform -1 can be confusing when looking for real shader issues.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
The import_simple_dmabuf() function does not modify the contents of its
struct dmabuf_attributes parameter, so make it const.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Move this code from headless-backend to a helper library, so it can be
shared with wayland-backend.
gl-renderer.h was missing #pragma once, which made the build fail.
Unfortunately gl-borders needs gl-renderer.h which will attempt to
include EGL headers if gl-renderer is enabled in the build, so we must
get the EGL build flags too, just for the headers.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Move the renderer type from struct headless_backend into struct
weston_renderer to store the chosen renderer type in a unified manner.
This will later allow secondary backends to determine the renderer type
chosen by the primary backend.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This services output capture tasks for the 'framebuffer' and 'full
framebuffer' pixel sources.
Both pixel sources come from the same source: the EGLSurface. The only
difference is the area. The EGLSurface contains the borders used for
output decorations, hence 'full framebuffer' is possible to capture.
We use GL_ANGLE_pack_reverse_row_order extension to make glReadPixels
return the image data in the layout we need for wl_shm buffers directly.
Without the extension we have to flip manually.
Another extension to the same effect is MESA_pack_invert, but this is
not specified for GL ES. It also uses a different token value, so it
cannot be directly substituted even if supported.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Instead of basing this on simple checks, we can test the matrix. This
should result in more opportunistically picking fast nearest neighbour
filtering when it won't result in visible distortion.
For now we only use this in the gl renderer, as paint nodes aren't
plumbed into the pixman renderer yet.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Add matrix in color.h
Matrix is used as an optimized method for
color mapping vs 3DLUT.
Nothing sets color mapping to matrix yet.
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Add post-curve support in color.h.
Pre-curve and post-curve describe color pipeline components
in a single GL shader invocation.The GL shader is supposed
to match struct weston_color_transform exactly.
We have the following color pipeline:
shader A -> blending -> shader B -> KMS. Both A and B shaders
using the same source file :fragment.glsl.
Each shader has pre and post curve.
The typical color pipeline with 3DLUT:
Shader A: pre-curve identity->3DLUT->blending->post-curve identity
Shader B: pre-curve->3DLUT identity->post-curve identity->KMS
The typical color pipeline with matrix (in next commits):
Shader A: pre-curve->matrix->blending->post-curve identity
Shader B: pre-curve->matrix identity->post-curve identity->KMS
The pre-curve plays role of EOTF (shader A) or INV_EOTF
(shader B) becouse we are stiching the shaders.
We assume that someone in the future may use both pre-curve
and post-curve, for example, when it is not possible to combine
these curves into 3DLUT and we will do mapping elements based on
their location in ICC profile.
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Replace all the remaining weston_output::current_mode and borders[] uses
with the fb_size and the compositing area. The result is the same, but
we stop depending on weston_output, and border texture sizes which may
not be the same as border sizes.
This is more correct, semantically.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Do not use border texture size when we have the area stored. This
decouples border texture size further.
We also have buffer_height available directly from fb_size, so do not
reverse-engineer it.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Pure refactoring to make the code easier to read.
Also drop the redundant all-clean check.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Compute the border area from the framebuffer size and composited area
only.
Now the border textures can be freely sized while they will be stretched
to fill the respective border areas. In fact, this was already made use
of by having left/right image height=1 as special cases. Now all the
texture dimensions behave the same.
No change in behavior, the values are the same, just computed
differently.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This moves the identical code from draw_output_borders() and
output_get_border_damage() into a new shared function. Reduces code
duplication.
This is a pure refactoring, all the computations stay the same.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>