Commit graph

591 commits

Author SHA1 Message Date
Marius Vlad
f4ba4f49bb renderer-gl: Add Perfetto debug annotations for shader configs
This adds Perfetto debug annotations for printing optimizations, color
vision deficiencies, alpha.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-05 08:59:21 -05:00
Marius Vlad
b43cc0a5d4 renderer-gl: Add Perfetto debug annotations
This adds Perfetto debug annotations for printing and paint (damage,
blended, opaque) regions.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-05 08:59:21 -05:00
Marius Vlad
9a708994d5 renderer-gl: Don't compute rects if log scope is not enabled
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-05 08:59:21 -05:00
Marius Vlad
414e85c22d renderer-gl: Be consistent with Perfetto regarding GPU activity
Rename 'timeline' to  'activity' and 'elapsed' to
'active'.

Feels like this it would more familiar to people when analysing
traces and uses the Perfetto naming for consistency. Otherwise I'd
rename 'activity' to 'timeline' for Perfetto track names.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-05 08:59:21 -05:00
Derek Foreman
e17a219885 renderers/clients: Bump gbm version requirement to 21.3
Drop support for libgbm versions without gbm_bo_create_with_modifiers

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-05-04 12:00:10 -05:00
Marius Vlad
689f6bd9ba renderer-gl: Improve accurancy when printing elapsed time
This avoids truncation to zero, by using an explicit cast to float and
print out properly the last 2 digits.

43 / 1000 = 0.00
43 / 1000.0 = 0.04

Fixes: 2d70cbf037

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-01 15:39:21 +03:00
Marius Vlad
4e596fca83 renderer-gl: Fix duplicated begin/end timestamps
Fix trivial typo when printing out GPU timeline timestamps.

Fixes: 2d70cbf037

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-01 15:29:08 +03:00
Derek Foreman
7dcf887903 renderers: use pnode view_alpha everywhere
Don't look this up from the weston_view anymore.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
77eb13f499 drm,renderers: Remove some unnecessary indirection
pnode->view->surface is the same as pnode->surface, always.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
3ff456175a gl-renderer: Log paint node internal name instead of view
Continuing my quest to remove weston_view from backends and renderers,
drop gl-renderer's last use of weston_view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Derek Foreman
22bcfead57 compositor: Add a weston_coord_global_to_surface_for_paint_node and use it
Add compositor code to handle this so the gl-renderer can reference just
the paint_node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-09 08:58:15 -05:00
Pekka Paalanen
a879fff2ec gl-renderer: skip test when fb-fetch missing
Rather than fail the tests that require fb-fetch GL ES feature and it's
missing, mark them as skipped instead. This helps people who run the
test suite manually.

In CI, a skip is marked as failure anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-09 14:21:54 +03:00
Pekka Paalanen
b8b8daacf2 gl-renderer, tests: use both blending implementations
This ensures that both blending implementations will be tested. The AUTO
mode, which was the only mode before this patch, would not test the
fixed-function blending a.k.a GL-renderer shadow framebuffer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Pekka Paalanen
599adea6df renderer-gl: create shader blender state and use it
This creates the fragment shader state needed for in-shader blending.
In-shader blending is always enabled if supported:
- GL supports the necessary features, and
- the blend-to-output color curve is exactly invertible.

The exact inverse is required, because the compositor will do repeated
decode-encode cycles per destination pixel, one for each non-opaque
source. Roundtrip errors through decode-encode might accumulate
otherwise. For now, identity, enumerated, and parametric curves are
deemed invertible while LUT is rejected without inspection.

Therefore to make use of this feature, outputs need to be configured with
a non-LUT type EOTF/TRC.

In-shader blending is always enabled, because it should be universally
more efficient than the use of a shadow buffer.

This feature was originally drafted for Weston by Sebastian Wick.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Pekka Paalanen
f639731c87 renderer-gl: refactor gl_renderer_color_transform_create_steps()
This is tidier.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Pekka Paalanen
d3f7a3be8f gl-renderer: refactor into gl_color_curve_init()
This will be needed for framebuffer decoder and encoder for in-shader
blending.

Pure refactoring in gl_renderer_color_transform_create_steps().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Pekka Paalanen
fd8a71b311 renderer-gl: make resize_output() logging more accurate
Discriminate between renderbuffer discard and shadow allocation
failures. While at it, let's pring the shadow pixel format rather than
hardcoding it in a string.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Pekka Paalanen
9d2fbd5455 renderer-gl: compress shader descriptions
Make the shader description strings easier to read. Before they looked
like this:

  Compiling shader program for: SHADER_TEXCOORD_INPUT_ATTRIB
  SHADER_VARIANT_SOLID SHADER_COLOR_EFFECT_NONE SHADER_COLOR_CURVE_LINPOW
  SHADER_COLOR_MAPPING_IDENTITY SHADER_COLOR_CURVE_IDENTITY
  +input_is_premult -tint -shader_blending (SHADER_COLOR_CURVE_IDENTITY,
  SHADER_COLOR_CURVE_IDENTITY)

Now they look like this:

  Compiling shader program for: attr tc, solid tex, no effect, CP{
  linpow, I, I }, +premult_in -tint -shader_blending (I, I)

Turn the switches into arrays for easier handling.

This is different from weston_enum_map, because we need two different
strings for each value: a symbol for the shader code, and a description
for the debug logs.

Unknown enum values will abort(), but they should be asserted anyway.
Unfortunately getting a weston_compositor here would be inconvenient for
using weston-assert macros.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Pekka Paalanen
aaed41798f renderer-gl: implement blend shader
This prepares the fragment shader for blending in-shader instead of
using the fixed-function blending.

This is not yet used, but it will allow avoiding the 16F shadow
framebuffer in the future.

TEX_UNIT_LAST is actually a count rather than the index of the last
unit. Fix the off-by-one in the check.

The FB fetch/store curves push our potential texture count beyond 8, so
implement a runtime check.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-04-08 21:55:45 +00:00
Leandro Ribeiro
c092f500e0 gl-renderer: add support for dma-buf screenshots
This adds support for dma-buf screenshots in our GL-renderer.

For now it only supports GLES >= 3.0, as it depends on
glBlitFramebuffer(). In the future we'll add support for older GLES
versions as well, using a shader to do the blit.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-04-02 14:34:19 +00:00
Leandro Ribeiro
366e045b54 gl-renderer: split create_capture_task() for sync fence and timer
For now this doesn't bring any benefits besides making
gl_renderer_do_read_pixels_async() easier to read. But in the next
commits this will be important.

This allows callers to decide if they want to use a timer when they fail
to get a sync fence for a capture task. For SHM tasks we always fallback
to a timer, but for dma-buf we will not allow the fallback path.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-04-02 14:34:19 +00:00
Leandro Ribeiro
25bb9d32b1 gl-renderer: allow to create gl_capture_task of dma-buf type
For now we support creating gl_capture_task only for SHM buffers. This
is used when the GL renderer pulls an output capture task from the
queue and its buffer type is SHM.

In the next commits we'll add support to allow output capture tasks to
be created with dma-buf buffers, so we need to extend gl_capture_task to
support that as well.

Differently from the SHM case, for dma-buf we don't have to do any copy.
The gl_capture_task is created just to wait for the blit to finish, and
then retire the output capture task.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-04-02 14:34:19 +00:00
Daniel Stone
d46135705e gl-renderer: Fix memory leak for mixed opaque/blended views
transform_damage() returns an allocated set of quads; if a surface had
both opaque and blended regions, we were overwriting the
previously-allocated set of quads for the blended region.

Luckily, transform_damage() doesn't need to be called twice anyway, so
we can fix this by only calling it once in the first case.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2026-04-01 08:01:44 +03:00
Robert Mader
27fd323478 gl-renderer: Assume all YUV formats are external-only
On drivers without explicit modifier support we can't use
eglQueryDmaBufModifiersEXT() to check the correct texture target. We
already hardcode GL_TEXTURE_EXTERNAL_OES for various YUV/YCbCr formats -
let's assume it applies to all of them.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-03-19 17:54:46 +01:00
Pekka Paalanen
e0066a8038 libweston: remove weston_renderer::read_pixels
Unused.

Nowdays renderers use weston_output_pull_capture_task().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-17 17:31:48 +02:00
Pekka Paalanen
9b177e381a libweston: store format modifier name in weston_buffer
This should cut the cost of debug_scene_view_print_buffer() in half on
ARM A55 CPU. Debug printing is quite expensive on such platform.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-10 16:40:40 +02:00
Leandro Ribeiro
32d0bd3d0e compositor: add grayscale output color effect
This adds a new output color effect: grayscale. It takes RGB color as
input and computes a gray pixel color using the luminance formula for
linear sRGB:

Y = 0.2126 * R + 0.7152 * G + 0.0722 * B

Just like the other color effects we have, this only works for sRGB and
are not enabled when color-management is on.

Note: although the technique is designed to be applied in linear, it's
costly to convert to linear and then back to electrical. As doing the
conversion in electrical still gives a reasonable result, we do it this
way. When we add support for color effects with color-management on,
we'll apply the effect in linear.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-04 13:11:56 -03:00
Leandro Ribeiro
ed29f588e4 gl-renderer: log inversion color effect to paint node scope
This was logging the CVD correction effects, but not the inversion one.
This commit adds this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-03-04 13:09:14 -03:00
Marius Vlad
78d15a6f95 libweston: do not call weston_surface::get_label()
Use the new label field instead. The code becomes much simpler.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 09:40:29 +02:00
Marius Vlad
2d70cbf037 gl-renderer: Add a new gl-renderer scope to print repaint regions
Add a new gl-renderer scope (gl-renderer-paint-nodes) to print out
repaint (damage) regions, opaque and blended regions as well as other
optimizations we might be taking (clear region, color effects), and
skipping repaints.

It includes as well the elapsed time being used by GPU timeline
(GL_EXT_disjoint_timer_query) as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-03-03 13:24:22 +02:00
Marius Vlad
58a18e1a9f gl-renderer: Clarify gl-renderer-ext debug scope
Further clarify that is printing the GL/EGL-extension by renaming
the internal scope name to extensions_scope and the advertised name
is gl-renderer-ext.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-03-03 13:24:22 +02:00
Robert Mader
5c49563ef4 gl-shaders: Remove asserts relying on shader compiler behavior
yuv_coefficients and yuv_offsets should get optimized away by shader
compilers as the related code paths can never be reached. This seems to
work well on Mesa but not necessarily with other drivers.

While on it, assert that the uniforms *are* present, unless the
yuv-to-rgb conversion is handled by the driver.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2026-03-02 14:04:48 +01:00
Loïc Molinari
ba0cb38d0a gl-renderer: Disable texture validity checks by default
Texture storage formats and parameters validity checks are done using
glGet*() functions which can be pretty slow depending on the OpenGL
implementation. Wrap these checks around a define disabled by default
in order to get the best OpenGL renderer performance in release
builds.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2026-02-13 17:04:05 +00:00
Loïc Molinari
927386fa84 gl-renderer: Check texture storage parameters (GL <= 3.0)
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2026-02-13 17:04:05 +00:00
Marius Vlad
0201d5762e renderer-gl: Check for valid CVD uniform
We seem to initialize the uniform with -1 so check against as the test
branch will actually try to use the supplied matrix (although it is
zero in this case).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-01-28 07:48:28 +00:00
Leandro Ribeiro
3de7c52942 libweston: collapse CVD correction into single matrix multiplication
CVD correction is composed by a linear transformation, so we should be
able to collapse it into a single matrix multiplication:

Y = M * X

Where Y is the result, X is the original color, and M is the CVD
correction matrix.

As we need to perform CVD correction for every pixel, this can be
beneficial for limited hardware.

In this patch we do that, updating the libweston core code and also the
GL-renderer and its fragment shader.

Suggested-by: Christopher Healy <healych@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-01-22 18:24:29 +00:00
Leandro Ribeiro
10991a4c4a gl-renderer: do not compute straight alpha values for CVD correction
CVD correction have the following format. These are linear
transformations in which M is a 3x3 matrix and X is a RGB vector.

F(X) = M * X

It is well known that CVD simulation/correction is done using straight
alpha values. So when we have alpha premultiplied values, we compute
straight alpha values first, apply the correction and premultiply by
alpha again. But this is not necessary, as we can see mathematically:

a * F(X) = a * (M * X) = M * (a * X) = F(a * X)

So do not convert premultiplied alpha values to straight alpha values
before applying CVD correction. This saves a few operations per pixel.

Note that the same does not apply to color inversion:

F(X) = 1 - X
a * F(X) = a - a * X
F(a * X) = 1 - a * X
=>
a * F(X) != F(a * X)

Suggested-by: Christopher Healy <healych@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-01-22 18:24:29 +00:00
Leandro Ribeiro
d3fee82090 gl-renderer: do not skip output color effect for solid color buffers
When repainting a paint node, if the buffer is a solid color buffer we
may skip the rendering pipeline and directly call glClear() with the
solid color, for optimization purposes.

Currently there's a bug where if the output has an output color effect
set, it is skipped when we have a solid color buffer (as we don't go
through the rendering pipeline, where the effects are implemented).

When we have color-management and the paint node contains a color xform,
we've opted for skipping this optimization and going through the
rendering pipeline for now. However, output color effects are simple,
so let's add the logic to apply them on CPU when we have a solid color
buffer.

Reported-by: Christopher Healy <healych@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-01-12 12:55:49 +00:00
Robert Mader
104cd2e813 gl-renderer: Enable support for color representation protocol
All required features were implemeneted in previous commits - enable the
capability.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-12-19 17:08:39 +01:00
Robert Mader
e8b7997223 gl-renderer: Add coefficients and range support to EGLImage paths
`EGL_YUV_COLOR_SPACE_HINT_EXT` and `EGL_SAMPLE_RANGE_HINT_EXT` have
to be set at image import, which again happens on wl_buffer creation.
This is problematic because in Wayland (and Vulkan) those values are
surface attributes and thus only known once the buffer gets attached
to a particular surface.

We solve that by first importing the dmabuf with default values and,
when attaching a buffer to a surface, creating additional EGLImages
as needed.

Note that we ignore `EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT` and
`EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT` for now, which are neither
required by the Wayland color-representation protocol nor supported by
Mesa shaders (as of 25.3).

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-12-19 17:08:39 +01:00
Robert Mader
b736066dc9 gl-renderer: Simplify EGLImage paths
Unlike EGL image import, texture creation and binding is quite fast and
cheap. Thus, instead of doing it as early as possible in various places,
do it right before we actually need it in prepare_textured_draw().

This will follow-up changes easier and includes some preparations for
them.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-12-19 17:08:29 +01:00
Robert Mader
2613db2426 gl-renderer: Add coefficients and range support to internal shader
Add matrix-coefficients and range tracking to more gl-renderer structures
and get the relevant values from the color-representation implementation
instead of hard-coding them in the shader.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-12-19 17:08:29 +01:00
Derek Foreman
c9a6e2721a gl-renderer: Fix up solid buffer attachments
We've been clobbering non-solid buffers with solid buffer attachment in
situations where we override the real buffer with a placeholder.

If the reason (punch hole, censor) that led to the placeholder is no
longer in effect, and new buffer is attached, we won't render what we should.

Instead, let's not attach anything for the paint node draw_solid case, and
allow gl_buffer_state be NULL when the real buffer is solid. gl_buffer_state
can then always be the correct state for the real buffer, even if we don't
use it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-21 13:56:30 -05:00
Derek Foreman
37a427e4e0 gl-renderer: Set up solids in config_init
Instead of overriding solid draws later on, just set them up in the
init function.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-21 13:54:59 -05:00
Derek Foreman
727d976e3c gl-renderer: Make prepare_solid_draw stand alone
Currently it uses some values from the existing sconf, instead let's make
it calculate everything on its own

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-21 13:54:59 -05:00
Derek Foreman
095f511d53 gl-renderer: split out textured draw setup
Refactor textured draw setup into a separate function, preparing for a
future where we set up solid draws from init_for_paint_node as well.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-21 13:54:21 -05:00
Derek Foreman
37db081f82 gl-renderer: Set texture filters before setting input textures
Turns out gl_shader_config_set_input_textures is what adds the filter
parameters to the sconf, so we must set the filters before calling it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-21 13:53:37 -05:00
Pekka Paalanen
33ee2c9fb4 color: make 3x1d.fill_in populate a vec3 array
This removes the API impedance mismatch between
weston_color_curve_sample() and weston_color_curve_to_3x1D_LUT() that
was temporarily introduced in the previous commit. That mismatch is now
limited to gl_color_curve_lut_3x1d().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-21 14:23:37 +03:00
Pekka Paalanen
e87eb19877 color,gl-renderer: handle neg. in linpow/powlin
We can handle the mirroring for negative input without conditional this
way. Maybe it's faster, maybe it's not, but I like this style better.

In color-operations we need only one call to the elementary function
rather than two. This helps a lot with code clarity, when we get a vec3
at a time to handle in the future, doing three trivial calls instead of
six with an if-else hassle.

fragment.glsl sheds one layer of function wrapping, which is nice.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-21 14:23:37 +03:00
Robert Mader
e9fc189189 paint-node: Consider view-alpha for is_fully_opaque
In order to be more in line with weston_view_is_opaque() - which we
use in most cases to set the value - and ensure the expectations of
existing places in the code are honored, see usages in both
draw_paint_node() implementations.

An exception here are holes - these always need to get painted as fully
opaque in the renderer path.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-17 15:06:11 +02:00