I'll be adding perfetto instrumentation, which will want to know the
timepoint name without having to parse it.
For now, just pass an enum and add a helper function to convert to strings.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Add asserts ensuring that outputs aren't created or destroyed twice
and that a valid pair of output/renderbuffer is passed to
repaint_output().
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Accumulate renderbuffer damages and select a GL renderbuffer for
repaint in a dedicated function.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Coalesce gl_renderer_create_renderbuffer_window() and
output_get_window_renderbuffer() into a single
gl_renderer_get_renderbuffer_window() function.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Use the term window instead of dummy to make it clear we're dealing
with buffers allocated by the window-system.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Although backends can create renderbuffers of any size, they always
request the output's current mode size (including decorations).
Letting backends ask for a different size than the output has a few
read-back related design issues like for instance weston_renderer's
read_pixels() API users, currently assuming the output size and
without knowledge of renderbuffers, can retrieve cropped images if a
backend asks for a smaller size. Same issue for the output capture
subsystem.
This commit proposes to fix these issues by simply, albeit perhaps
radically, removing the width and height parameters from
create_renderbuffer(), enforcing the current mode's size of the
associated output.
The VNC and PipeWire backends now also access the output size via the
current mode, not through the width and height variables. This has the
benefit of unifying the backends, as well as the renderers, in their
use of output sizes.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The Pixman renderer creates renderbuffers with the create_image() and
create_image_from_ptr() functions. The recent addition of the GL
renderer's create_fbo() function, which is pretty similar to the
Pixman ones, brings the opportunity to unify Pixman and GL renderers.
This commit proposes a common renderer function create_renderbuffer()
to create a renderbuffer of the specified format with an optional user
provided destination buffer.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This avoids having to re-bind them in functions that reuse them
immediately afterwards and does not affect any other parts of code.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit makes gl_fbo_texture_init() and gl_fbo_texture_fini()
consistent with the new FBO handling utilities by using the same
conventions: output parameters, variable names, descriptions.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Remove the glGetError() check from gl_fbo_image_init() after the call
to glEGLImageTargetRenderbufferStorageOES(). It would probably just
return a previous error queued by an unrelated GL call because the
error flags aren't cleared. So instead of obfuscating the code, this
commit removes that check and relies instead on the framebuffer
completeness check which will better report issues.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Add generic gl_fbo_init(), gl_fbo_image_init() and gl_fbo_fini()
utilities to the GL renderer and make use of these in the renderbuffer
creation functions.
This also fixes a framebuffer object leak on dma-buf renderbuffer
creation when the EGLImageTargetRenderbufferStorageOES() call fails.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
There's no need to render the surface content to a GL texture so make
it render to a GL renderbuffer instead.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Move gl_renderer_create_renderuffer_dmabuf() along with the other
renderbuffer creation functions, using a common naming pattern.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This makes type specific accesses more explicit and less verbose than
the container_of/base alternative which was needed when the base
renderbuffer type was exposed in libweston-internal.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
No backends currently create FBO or dma-buf renderbuffers on outputs
associated to a window. This is theoretically possible though and
should be allowed by the GL renderer. This commit prevents
output_get_dummy_renderbuffer() from mixing up renderbuffer types.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Stale renderbuffers are kept in the renderbuffer list until they're
destroyed by the backend. In the meantime, they shouldn't accumulate
damages since they won't be used anymore.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
It's currently assumed by backends that renderers discard
renderbuffers on resize. This commit introduces a new
weston_renderbuffer_discarded_func callback that must be passed at
renderbuffer creation in order to be notified of discarded events from
the renderer. This discarded event could potentially be reused later
by renderers on other occasions without having to change backends once
they get proper support for that.
On output resize, once a discarded event handler fails (returns false)
on a renderbuffer, all the remaining renderbuffers in the output list
go stale and weston_renderer_resize_output() ultimately returns false
for backends to be notified of the failure.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Renderbuffers currently have a libweston-internal base data structure
with a ref-counting system to handle their lifetime. The problem is
that renderers keep a ref to all renderbuffers in a list per output
(to deal with damages) and that it prevents backends from releasing
renderbuffer resources when not needed anymore. Renderbuffers are then
only released (last ref removed) when the output is destroyed or
resized. dma-buf renderbuffers even expose a dedicated function
remove_renderbuffer_dmabuf() to explictly request the release of their
resources.
This commit proposes to get rid of the ref-counting system by exposing
a single entry point to explicitly destroy all types of renderbuffers
from the renderer.
Instead of removing a renderbuffer from its output list and dropping
its ref when the output is resized, this commit also introduces the
concept of stale renderbuffers which consists in releasing the
resources of a renderbuffer when it's discarded by the renderer while
keeping it in the output list, with a stale state, until it's
explicitly destroyed.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Move the responsibility for damaging the entire area of new
renderbuffers from backends to renderers.
There's one little drawback: VNC damage logging can't log the
accumulated renderbuffer damage anymore, but I guess this should
somehow be done as an option in the renderers.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
eglSetDamageRegion() requires a postable surface and shouldn't be
called with EGL_NO_SURFACE.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
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>
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>