Commit graph

346 commits

Author SHA1 Message Date
Marius Vlad
207fed2710 Revert "shared/helpers.h: Migrate helpers.h to libweston"
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>
2025-01-17 10:18:26 +02:00
Loïc Molinari
4be294bd69 gl-renderer: Move list init after feature flags setup
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
8d21829f49 gl-renderer: Add GPU timeline feature flag
This flag ensures support for both the GL_ANDROID_native_fence_sync
and the GL_EXT_disjoint_timer_query extensions at run-time. The GL
features log now reports that flag so the warning log has been
removed.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
169bb00bbd gl-renderer: Add color transforms feature flag
Replace gl_supports_color_transforms with a feature flag.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
7f01f9e18e gl-renderer: Add async read-back feature flag
Replace has_pbo with a feature flag.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
090c01da87 gl-renderer: Load GL function pointers with GET_PROC_ADDRESS()
Use the same macro than for the EGL function pointers.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
d7dcc2eaa7 gl-renderer: Remove GL extension booleans
Now that the GL extensions are stored in the gl_extensions bitfield,
there's no need to use booleans anymore.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
0026986cce gl-renderer: Check for GL_OES_EGL_image support
This commit ensures GL_OES_EGL_image is available before setting up
dma-buf renderer functions because it's not implied by the presence of
the EGL_EXT_image_dma_buf_import extension.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
aaf968bf58 gl-renderer: Slightly improve color transforms check
GL_OES_texture_3D isn't used because of the complexity implied for
correct OpenGL ES 2 support (see commit 734c2278), so there's no need
to check for it. The check also now avoids checking for
GL_EXT_color_buffer_half_float on OpenGL ES 3.2 which includes support
for 16-bit FP renderbuffers by default.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
02b4eccd05 gl-renderer: Add EGL_KHR_get_all_proc_addresses checks
The GL renderer supports OpenGL ES from version 2.0 to 3.2. It's meant
to correctly link on systems with only OpenGL ES 2, so OpenGL ES 3
symbols can't be used directly. eglGetProcAddress() is currently
defined to not support the querying of non-extension OpenGL ES
functions. Support for that is exposed by the
KHR_get_all_proc_addresses extension. This commit ensures OpenGL ES 3
function addresses can be retrieved by eglGetProcAddress() by checking
for that extension at run-time.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4ae493ff25 gl-renderer: Store GL extensions as flags
A new gl_extensions bitfield is added to the renderer to store the
flags supported by the GL implementation. This allows the GL renderer
to easily check for extension support whenever needed.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
db5c06bd16 gl-renderer: Remove branch never taken
Don't flag EGL_PBUFFER_BIT to get the EGL config if the
EGL_KHR_surfaceless_context extension isn't available. The branch is
never taken because the extension is required and if it isn't
available, the function would have already returned.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4f7f888d6c gl-renderer: Improve EGL_WL_bind_wayland_display extension handling
Get the EGL_WL_bind_wayland_display extension function addresses after
checking for extension availability.

Let the EGL display setup end before trying to bind the Wayland
display in gl-renderer.c. The EGL features log will now report the
extension as supported even if the bind subsequently fails, in which
case a warning is logged.

This commit also avoids calling query_buffer() if the display isn't
bound in fill_buffer_info(), it would otherwise fail or even segfault
if the EGL_WL_bind_wayland_display extension isn't available.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
94ca770c2a gl-renderer: Add explicit sync feature flag
This feature flag is for explicit sync support.

We replace the explicit sync warning by logging supported fence syncs
along with the report EGL features report.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
3d0d850980 gl-renderer: Add swap buffers with damage feature flag
This second feature flag ensures that either the
EGL_EXT_swap_buffers_with_damage or EGL_EXT_swap_buffers_with_damage
extension is available.

Some function pointer addresses are currently retrieved depending on
the availabilty of their associated extension and some others are
retrieved unconditionally. For consistency reasons, we'll try from now
on in this commit set to first load function pointers depending on the
associated extension availability and then flag features once all the
addresses are retrieved.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
4a4a9b94d6 gl-renderer: Add no config context feature flag
This commit introduces feature flags. While an extension flag only
ensures the availability of an extension at run-time, a feature flag
ensures the availability of a minimal OpenGL ES version and/or
extensions in order to easily check for the availability of a specific
feature at run-time.

This first feature ensures the availability of either the
EGL_KHR_no_config_context or EGL_MESA_configless_context extensions.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
c56c104f7a gl-renderer: Remove EGL extension booleans
Now that the EGL extensions are stored in the egl_*_extensions
bitfields, there's no need to use booleans anymore.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
00f7bf91d8 gl-renderer: Add extension flag parser
This new utility parses extension strings and fills a bitfield of
matched flags. This will be used to store EGL and GL extension flags.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Loïc Molinari
39a199293e gl-renderer: Move versioning utils to internal header
Next commits will need this outside of gl-renderer.c.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-01-14 13:24:39 +00:00
Tomek Bury
b14461b13b gl-renderer: make DMABUF allocator optional
The dmabuf allocator pulls in libgbm which lives inside Mesa and is built
as a non-standalone part Mesa. This makes gl-renderer hard-wired to Mesa.

The allocator is only used by an optional pipewire backend so make
the allocator optional too.

Signed-off-by: Tomek Bury <tomek.bury@gmail.com>
2024-12-03 13:41:50 +00:00
Marius Vlad
bf7b2311e7 gl-renderer: Take direct-display into consideration
The buffer_init function added with commit 83b37c0ac4, "renderers: pull
dmabuf initial setup out of attach", doesn't take into consideration the
the buffer's direct-display property.

Previously, gl_renderer_attach_dmabuf, wasn't being called when dmabuf's
direct-display  was turned on, but with commit 83b37c0ac4 this has been changed.

So with commit 83b37c0ac4, linux_dmabuf_buffer_get_user_data will never
return a valid gb (gl buffer state), causing a crash using
direct-display extension. This adds an explicit check to return early
when this happens.

Fixes: 83b37c0ac4, "renderers: pull dmabuf initial setup out of attach"
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-12-01 23:17:50 +02:00
Marius Vlad
8634c7e349 shared/helpers.h: Migrate helpers.h to libweston
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>
2024-11-25 11:26:35 +00:00
Loïc Molinari
bb6abf3c33 gl-renderer: Clean up comments
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-08-12 10:44:55 +00:00
Loïc Molinari
0078a20f17 gl-renderer: Fix debug clear on shadow buffers
The shadow buffer must be blitted entirely when debug clear is on.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-08-12 10:44:55 +00:00
Loïc Molinari
c65284bf9d gl-renderer: Fix debug clear region
The debug clear region must be generated out of the current render
buffer's damage region, not out of the current damage region, unless
shadow 16F is enabled.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-08-12 10:44:55 +00:00
Loïc Molinari
215d552ce1 gl-renderer: Don't use eglSetDamageRegion() on surfaceless outputs
eglSetDamageRegion() requires a postable surface and shouldn't be
called with EGL_NO_SURFACE.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-08-12 10:44:55 +00:00
Loïc Molinari
fb4cccc290 gl-renderer: Assume default GL texture unit
Revert active unit to default value right after use so that other
functions can assume the default state. A best practices section is
added to the internal header for reference.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-29 14:20:43 +00:00
Loïc Molinari
b755345a46 gl-renderer: Assume fixed wireframe tex unit
The wireframe unit can only be used by the wireframe texture so
there's no need to bind it anymore before use.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-29 14:20:43 +00:00
Loïc Molinari
16390dbae1 gl-renderer: Avoid GL_ as a prefix for constants
Avoid prefixing constants with GL_ as it could be confused with OpenGL
constants.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-29 14:20:43 +00:00
Loïc Molinari
8a9fba9827 gl-renderer: Merge duplicated functions
Merge duplicated gl_renderer_attach_dmabuf() and
gl_renderer_attach_egl() functions into a single
gl_renderer_attach_buffer() one.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-29 14:20:43 +00:00
Loïc Molinari
95c3f96870 gl-renderer: Assume default GL_UNPACK_* states
Revert pixel store's GL_UNPACK_* changes to default values right after
use so that other part of the code can assume the default state.

Fixes: #928

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-24 09:00:38 +00:00
Loïc Molinari
84d83f5bf8 gl-renderer: Assume default GL_PACK_ALIGNMENT state
Revert pixel store's GL_PACK_REVERSE_ROW_ORDER_ANGLE changes to default
value right after use so that other part of the code can assume the
default state.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-24 09:00:38 +00:00
Loïc Molinari
1a0e450da5 gl-renderer: Assume default GL_PACK_REVERSE_ROW_ORDER_ANGLE state
Revert pixel store's GL_PACK_REVERSE_ROW_ORDER_ANGLE changes to
default value right after use so that other part of the code can
assume the default state.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-24 09:00:38 +00:00
Loïc Molinari
4fab505b96 gl-renderer: Prepare for reset to default pixel storage states
Prepare gl_renderer_do_read_pixels() so that the default pixel storage
states can be more easily reverted to default before return.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-24 09:00:38 +00:00
Derek Foreman
1fd99807ec renderers: Remove internal flush and attach
These were only necessary to allow surface_copy_content to return contents
that included recently attached (but not yet rendered) buffers.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-07-19 16:41:05 +00:00
Derek Foreman
0f8bd8dbc5 libweston: Don't change surface state in weston_surface_copy_content
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>
2024-07-19 16:41:05 +00:00
Michael Tretter
4815259164 gl-renderer: use existing gbm_device if possible
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
14e133e48e gl-renderer: add DMABUF allocator
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
5a779b7804 gl-renderer: add dmabuf renderbuffer support
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
c9c4549064 gl-renderer: add helper function for adding renderbuffers
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
cc926a4567 gl-renderer: don't flip outputs for FBO rendering
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
c2dbe17150 gl_renderer: respect y_flip in read_pixels
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
b57129f451 gl-renderer: allow to render y-flipped outputs
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>
2024-07-19 11:43:42 +02:00
Michael Tretter
b6075fd075 gl-renderer: use transformation matrix to flip damage
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>
2024-07-19 11:43:42 +02: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
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