If we are trying to use a NULL shader, it is likely that the shader
compilation failed for some reason. Since we are trying this for a view,
the failure was probably triggered by a client. If there is a client,
get rid of it by sending it a protocol error. Hopefully the compositor
can then continue operation after a glitch on screen.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This patch modifies the shader generation code so that the shaders are
stitched together based on the requirement instead of creating them
during initialization. This is necessary for HDR use cases where each
surface would have different properties based on which different
de-gamma or tone mapping or gamma shaders are stitched together.
v2: Use /* */ instead of // (Pekka)
Move shader strings to gl-shaders.c file (Pekka)
Remove Makefile.am changes (Pekka)
Use a struct instead of uint32_t for storing requirements (Pekka)
Clean up shader list on destroy (Pekka)
Rename shader_release -> shader_destroy (Pekka)
Move shader creation/deletion into gl-shaders.c (Pekka)
Use create_shaders's multi string capbility instead of
concatenating (Pekka)
v3: Add length check when adding shader string (Pekka)
Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
v4: Rebased, PROTECTION_MODE_ENFORCED converted.
Dropped unnecessary { }.
Ported setup_censor_overrides().
Split out moving code into gl-shaders.c.
Changed to follow "gl-renderer: rewrite fragment shaders",
no more shader source stitching.
Added SHADER_VARIANT_XYUV.
Const'fy function arguments.
Added gl_shader_requirements_cmp() and moved the early return in
use_gl_program().
Moved use_gl_program() before first use in file.
Split solid shader requirements by use case: requirements_censor and
requirements_triangle_fan.
Simplified fragment_debug_binding() since no need to force anything.
Ensure struct gl_shader_requirements has no padding. This allows us
to use normal C syntax instead of memset() and memcpy() when
initializing or assigning. See also:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/2071
Make it also a bitfield to squeeze the size.
v5: Move wl_list_insert() into gl_shader_create() (Daniel)
Compare variant to explicit value. (Daniel)
Change functions to gl_renderer_get_program,
gl_renderer_use_program, and
gl_renderer_use_program_with_view_uniforms.
Use local variable instead of gr->current_shader. (Daniel)
Simplified gl_renderer_get_program.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Do not change in setup_censor_overrides() and then put back gs->shader
in draw_view() when the shader needs to be something else than what the
surface content calls for.
This makes the logic simpler, and makes following changes simpler as
well.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is purely moving code as is with no changes other than making the
three functions non-static.
Originally this was part of "gl-renderer: Requirement based shader
generation" by Harish Krupo, but that patch made also big changes to the
code at the same time. Patches are easier to review when code movement
is separate from behavioral changes, therefore I introduced this patch.
Cc: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The main point here is to print "GL ES %d.%d" instead of "GL ES 2"
because GL-renderer can and will use GL ES 3 features when present.
Saying it's GL ES 2 renderer is not quite true.
To print that, I need to extract major, minor from gr->gl_version and
those didn't have ready made macros yet. While writing the extraction,
make all these trivial functions, so that the compiler might warn us if
one passes e.g. negative literal numbers to gr_gl_version(). Explicit
types help keeping the bit operations safe too.
The only purpose for GR_GL_VERSION_INVALID was to fall back to version
2.0. Moving the fallback and logging into get_gl_version() makes that
macro unnecessary.
Finally, just in case GL version string contained garbage, reject
negative version numbers.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This test ensures that client submitted damage goes to the screen
correctly, regardless of output scale or transform.
The added quirk is explained in the test that uses it.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
For a pbuffer EGLSurface, assume that EGL swap behavior is "preserved"
which means buffer age is always 1 (after the very first
eglSwapBuffers()).
EGL pbuffers are always single-buffered.
Mesa EGL Surfaceless platform does not seem to expose EGL_EXT_buffer_age
that could have told us the same. Hence all repaints to pbuffer surfaces
used to need to repaint the whole output always. This patch makes
repainting only the latest damage possible.
Repainting only the latest damage is required for a future test on
output damage regions: "tests: add output damage test".
Technically, setting buffer_age to 1 is not correct before the very
first eglSwapBuffers(), but to keep the code simpler I chose to rely on
a newly enabled output always having full damage anyway.
Checking that EGL_SWAP_BEHAVIOR is EGL_BUFFER_PRESERVED would do too.
Unfortunately, Mesa seems to return EGL_BUFFER_DESTROYED, so I cannot
fail the headless-backend in that check. Even so, the output damage test
actually succeeds.
See also: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4278
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Require GL_EXT_unpack_subimage unconditionally in GL-renderer. Without
this extension, it would take considerable effort in GL-renderer to
handle correctly images that contain row padding, either as a temporary
copy to remove padding or doing SubImage updates row by row.
I would guess that this path has gone long completely untested, and if
it was exercised, the rows never had padding thanks to 32-bit pixel
formats. Instead of writing tests to poke the corner cases and fixing
it, remove it.
This will make it easier to fix other problems in GL-renderer in this
area in the future - one less path to consider and many restrictions in
GL API gone.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
When there's neither configless nor surfaceless EGL extension
(i.e. not a Mesa driver), Weston falls back to a dummy pbuffer surface.
Weston attempts to find for that surface an EGL config but uses a NULL
array of pixel formats. This fails with the following messages:
EGL_KHR_surfaceless_context unavailable. Trying PbufferSurface
Found an EGLConfig matching { pbf; } but it is not usable because
neither EGL_KHR_no_config_context nor EGL_MESA_configless_context
are supported by EGL.
failed to choose EGL config for PbufferSurface
EGL error state: EGL_SUCCESS (0x3000)
Failed to initialise the GL renderer;
Signed-off-by: Tomek Bury <tomek.bury@broadcom.com>
Using the number of planes to determine if GL_TEXTURE_EXTERNAL_OES should be
used is incorrect with some modifiers: For example RGBA with a
I915_FORMAT_MOD_Y_TILED_CCS modifier has two planes.
Use eglQueryDmaBufModifiersEXT() to query if the current format/modifier only
supports GL_TEXTURE_EXTERNAL_OES.
Use the current code as fallback of modifiers are not supported.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
gl_rendererer's output_pbuffer_create has a lot of arguments now. Add a
structure for the options to make it more clear what is what.
This is in preparation for adding bare-integer arguments which are ripe
for confusion when passing positional arguments.
Signed-off-by: Daniel Stone <daniels@collabora.com>
gl_rendererer's output_window_create has a lot of arguments now. Add a
structure for the options to make it more clear what is what.
This is in preparation for adding bare-integer arguments which are ripe
for confusion when passing positional arguments.
Signed-off-by: Daniel Stone <daniels@collabora.com>
gl_rendererer's output_create has a lot of arguments now. Add a
structure for the options to make it more clear what is what.
This is in preparation for adding bare-integer arguments which are ripe
for confusion when passing positional arguments.
Signed-off-by: Daniel Stone <daniels@collabora.com>
This is to put more of the EGL client extension handling in the same
place. This also adds a boolean to check if EGL_EXT_platform_base is
supported, similar to other extensions we check.
Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
EGL client extensions are not tied to the EGLDisplay we create, and have
an effect on how we create the EGLDisplay. Since we're using this to
look for EGL_EXT_platform_base, it makes more sense for this to be near
the start of the GL renderer initialization.
Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
If gl-renderer fails its initialisation, we return to compositor
teardown, which will try to free the renderer if ec->renderer was set.
This is unfortunate when we've already torn it down whilst failing
gl-renderer init, so just clear the renderer member so we don't try to
tear down twice.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Emil Velikov <emil.velikov@collabora.com>
Commit adaf8c7410 ("renderer: change frame_signal emission to pass
previous_damage as data argument") missed updating all frame_signal
emissions. Later commit 2619bfe420 ("move frame_signal emission to
weston_output_repaint()") fixed this deficency along with moving the
location of the emission. Due to an issue of the location change, this
commit had to be reverted again.
This makes sure that the pixman as well as the GL renderer now also
emits the damage region instead of the Weston output.
Fixes: adaf8c7410 ("renderer: change frame_signal emission to pass previous_damage as data argument")
Signed-off-by: Stefan Agner <stefan@agner.ch>
The member previous_damage from struct weston_output is no longer necessary.
First, stop calling init, fini and copying output_damage to it. Then remove
it from struct weston_output.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
The emission of frame_signal has to happen before a flip, otherwise
glReadPixels() could read an old frame or even worse an uninitialized buffer.
So move frame_signal emission back to renderers.
This reverts commit 2619bfe420.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
In order to remove duplication and make the code easier to follow, move
frame_signal emission from renderers to weston_output_repaint(). This should
have no observable effect.
Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
Accept XYUV dmabuf buffers that a client application such as
weston-simple-dmabuf-v4l might submit.
v2 (Daniel):
Add XYUV to yuv_formats array to have the compositor color convert
with a shader if GL_TEXTURE_EXTERNAL_OES does not work.
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Instead of using the EGL_*_WL macros imported from EGL headers,
start using enums that would be defined locally. This is needed as
there are limited number of macros defined in EGL headers and
adding new ones is not practically feasible when adding a new
texture type. (suggested by Daniel Stone)
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
As we avoid importing the buffer in the GPU, when attaching the buffer
we'll not have a valid image to retrieve it from, and as such we'll
avoid touching and setting the surface state shader.
This adds also 'direct_display' to the surface state and with it, sets the
surface state 'direct_display' member whenever the imported buffer will
have the direct-display member set.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
With the timeline scope being created it is time to convert TL_POINT()
to use the timeline scope through the compositor instance.
This patch removes the global variable allowing to run the new timeline
code.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
With it this removes the parts responsible for creating the file,
timeline_log class, removes the debug key binding when creating the
compositor instace, keeping only what can be re-used.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Use the surfaceless platform in the headless backend to initialize the
GL-renderer and create pbuffer outputs. This allows headless backend to use
GL-renderer, even hardware accelerated.
This paves way for exercising GL-renderer in CI and using the Weston test suite
to test hardware GL ES implementations.
Relates to: https://gitlab.freedesktop.org/wayland/weston/issues/278
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This allows passing EGL_PLATFORM_SURFACELESS_MESA to
gl_renderer_display_create(). It is not useful on its own, because the
surfaceless platform has no window surfaces.
This feature will be used by the headless backend.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
In case the base EGLConfig is needed, gl_renderer_display_create() needs to
know it should use EGL_WINDOW_BIT or EGL_PBUFFER_BIT.
The PBUFFER case is added for when the headless backend will grow GL-renderer
support.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
When all shared/ headers are included in the same way, we can drop unnecessary
include seach paths from the compiler.
This include style was chosen because it is prevalent in the code base. Doing
anything different would have been a bigger patch.
This also means that we need to keep the project root directory in the include
search path, which means that one could accidentally include private headers
with
#include "libweston/dbus.h"
or even
#include <libweston/dbus.h>
IMO such problem is smaller than the churn caused by any of the alternatives,
and we should be able to catch those in review. We might even be able to catch
those with grep in CI if necessary.
The "bad" include style was found with:
$ for h in shared/*.h; do git grep -F $(basename $h); done | grep -vF '"shared/'
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
If we don't have the surfaceless_context extension, we create a pbuffer as a
dummy surface to work with. If we also don't have configless_context, then it
is possible the config used for creating the context does not support pbuffers.
Therefore, if both conditions apply, we need to pick a config that supports
both window and pbuffer surfaces.
This makes the "base" config compatible, but it does not yet guarantee that we
actually pick it again when creating the pbuffer surface. Fixing that is
another patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fold more code into the common config choosing, the pbuffer path this time.
Simplifies code and allows gl_renderer_get_egl_config() to grow smarter in the
future to guarantee config compatility in the absence of configless_context
extension.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Now that all backends pass in a list of acceptable DRM formats, that is used to
determine if the EGLConfig has an alpha channel or not. Therefore the
opaque_attribs and alpha_attribs are now useless, and we can remove the whole
config_attribs argument from the API.
gl_renderer_get_egl_config() uses an internal attrib list that matches at least
the union of the opaque_attribs and alpha_attribs matches.
Overall, behaviour should remain unchanged.
The new attribute array becomes variable in the future, so it is left
non-const.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Implement fuzzy EGLConfig pixel format matching, where we ensure that R, G, B
and A channels have the expected number of bits exactly. This is used on EGL
platforms where the EGLConfig native visual ID is not a DRM format code. On EGL
GBM platform, the old exact matching of native visual ID is kept.
As only the DRM backend uses a DRM format list for picking a config, this patch
should not change any behaviour.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
If configless context is supported, we can skip choosing the "base" config
completely as it will never be used.
This simplifies the code a little bit.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Replace a direct call to egl_choose_config() with a higher level function
gl_renderer_get_egl_config(). This will make follow-up work easier when
attribute lists will be generated inside gl_renderer_get_egl_config() instead
of passed in as is.
We explicitly replace visual_id with drm_formats, because that is what they
really are. Only the DRM backend passes in other than NULL/0, and if other
backends start caring about the actual pixel format, drm_format is the lingua
franca.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
In an attempt to pull more of EGLConfig choosing into one place, refactor code
into the new gl_renderer_get_egl_config(). The purpose of this function is to
find an EGL config that not only satisfies the requested attributes and the
pixel formats if given but also makes sure the config is generally compatible
with the single GL context we have.
All this was already checked in gl_renderer_create_window_surface(), but
gl_renderer_create_pbuffer_surface() is still missing it. This patch is
preparation for fixing the pbuffer path.
We explicitly replace visual_id with drm_formats, because that is what they
really are. Only the DRM backend passes in other than NULL/0, and if other
backends start caring about the actual pixel format, drm_format is the lingua
franca.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Start a new source file for EGL glue stuff, for the EGL platform Weston runs
on. gl-renderer.c is getting too long, and I want to add even more boring code
(config pretty-printing etc.).
This pure code move, no changes.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Some extensions (such as EGL_KHR_partial_update) add functions to EGL.
When the extension is present, GetProcAddress must return usable
function pointers for those entrypoints.
Assert that GetProcAddress returns a non-NULL function pointer in these
cases.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Some drivers support EGL_EXT_image_dma_buf_import_modifiers for format
enumeration, but don't have any modifiers. In this case, on platforms where
malloc(0) returns non-NULL, we would leak that allocation to the caller.
Handle this by noticing when the number of supported modifiers is 0 and
returning early.
No caller ever used anything but NULL here, so just use NULL to simplify code.
In fact, no EGL platform defined today even defines any platform attributes
except the X11 platform for choosing a non-default SCREEN.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Contents on an ouput are captured when screenshooter/recorder/screen
sharing is enabled. In such cases the protected content must
be censored to ensure that it is not recorded along with unprotected
content. This is a required only when the surface protection is in
enforced mode.
Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>