Commit Graph

1073 Commits

Author SHA1 Message Date
Pekka Paalanen
9f428a633c gl-renderer: move functions into gl-shaders.c
These functions are related to shaders, so they are more at home in
gl-shaders.c. gl-renderer.c is too long already.

This allows making a couple functions static while the moved functions
become non-static. Future changes turn some of these functions into
static again, with the ultimate goal of making struct gl_shader opaque.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Marius Vlad
d171c7b3ba libweston/backend-drm: Re-order gbm destruction at DRM-backend tear down
Tearing down the drm-backend when there are no input devices, would call
for the gbm device destruction before compositor shutdown. The latter
would call into the renderer detroy function and assume that the
EGLDisplay, which was created using the before-mentioned gbm device, is
still available. This patch re-orders the gbm destruction after the
compositor shutdown when no one would make use of it.

Fixes: #314

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2021-04-01 11:28:44 +03:00
Pekka Paalanen
a4ecf96316 libweston: fix #ifdef ENABLE_EGL
Everywhere else uses #ifdef, this used just #if. When the next commit
adds -Wundef to the compiler options, this #if here will start failing
as ENABLE_EGL is undefined.

It would be much better to use Meson's set10() for ENABLE_EGL and change
all #ifdef into #if, but I opted for the smaller change for now.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
f65ba18853 gl-renderer: print use time with gl-shader-generator debug
This should help correlate which shaders were used in repainting outputs
recently.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
1ed2cad87e gl-renderer: garbage-collect old shaders
This adds a heuristic for freeing shader programs that have not been
needed for a while. The intention is to stop Weston accumulating shader
programs indefinitely, especially in the future when color management
will explode the number of possible different shader programs.

Shader programs that have not been used in the past minute are freed,
except always keep the ten most recently used shader programs anyway.
The former rule is to ensure we keep shader programs that are actively
used regardless of how many.  The latter rule is to prevent freeing too
many shader programs after Weston has been idle for a long time and then
repaints just a small area. Many of the shader programs could still be
relevant even though not needed in the first repaint after idle.

The numbers ten and one minute in the above are arbitrary and not based
on anything.

These heuristics are simpler to implement than e.g. views taking
references on shader programs. Expiry by time allows shader programs to
survive a while even after their last user is gone, with the hope of
being re-used soon. Tracking actual use instead of references also
adapts to what is actually visible rather than what merely exists.

Keeping the shader list in most recently used order might also make
gl_renderer_get_program() more efficient on average.

last_repaint_start time is used for shader timestamp to avoid calling
clock_gettime() more often. Adding that variable is an ABI break, but
libweston major has already been bumped to 10 since last release.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
a8c4dfead5 gl-renderer: log shader deletions too
This is useful for seeing that the shader program garbage collection
works in a future patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
40c26a0b7c gl-renderer: add compositor shorthand pointer
One more thing is coming to need this, so add the compositor pointer and
migrate existing places to use it where it simplifies things.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
768f07cb38 gl-renderer: whitespace style clean-up
Fix some deviations from the coding style.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
9a59303a4f gl-renderer: doc YCbCr-RGB conversion
I have verified that the conversion here follows ITU-R BT.601 except for
the offsets 16/256 and 128/256 which should be 16/255 and 128/255
respectively.

I used to following octave script to verify this:

rf = 0.299;
gf = 0.587;
bf = 0.114;

crdiv = 1.402;
cbdiv = 1.772;

M = [ rf, gf, bf ;
      -rf / cbdiv, -gf / cbdiv, (1 - bf) / cbdiv;
      (1 - rf) / crdiv, -gf / crdiv, -bf / crdiv ];

YCbCr = [ 'Y'; 'Cb'; 'Cr' ];
RGB = [ 'R'; 'G'; 'B' ];
eq = [ ' '; '='; ' ' ];
l = [ ' [ '; ' [ '; ' [ ' ];
r = [ ' ] '; ' ] '; ' ] ' ];

mat = [
	sprintf('%9f %9f %9f', M(1,:));
	sprintf('%9f %9f %9f', M(2,:));
	sprintf('%9f %9f %9f', M(3,:));
];

[ l YCbCr r eq l mat r l RGB r ]

R = inv(M);

mat = [
	sprintf('%9f %9f %9f', R(1,:));
	sprintf('%9f %9f %9f', R(2,:));
	sprintf('%9f %9f %9f', R(3,:));
];

[ l RGB r eq l mat r l YCbCr r ]

[ R(:,1), R(:,2:3) .* (255/224) ]

The final matrix printed is what the shader uses down to +/- one digit,
so at least 7 correct decimals.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
2b5a863974 gl-renderer: move view alpha out of sample_input_texture()
Sampling input texture has nothing to do with view alpha. This clarifies
the code structure.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
3f6be39f94 gl-renderer: factor out sample_input_texture()
Reading the input texture is just one part of the future color pipeline,
so separate it into a function of its own. This makes it easier to add
more steps to the pipeline, and shows the green tint is separate as
well.

Making use of early returns, reducing the if-else ladder should help
with readability. Sharing the call to yuva2rgba() likewise.

Setting yuva.w = alpha is not shared though, in case support for AYUV
format might be added in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
d278015d00 gl-renderer: drop redundant texture lookups
Do not call texture2D() in the shader when we already have the result.
Simpler code, maybe even a little bit faster?

Suggested-by: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
a88144f9e1 gl-renderer: move magic constants into yuva2rgba()
These same magic constants were used in all cases, so move them into a
common place.

While we are touching all these lines, also change from the four floats
into a vec4. This allows further clean-up in the next patch.

This makes the code easier to read.

Behavior and results are unchanged.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
054ba37084 gl-renderer: move alpha pre-mult from YUV to RGB
Mathematically the result is the same, while multiplying RGB with alpha
is easier to understand as correct than the earlier form.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
a8d5ef4a04 gl-renderer: rename color uniform to unicolor
A more unique name is easier to grep for. Using 'color' as a local
variable might be useful in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
30104bd89a gl-renderer: support XYUV8888 wl_shm format
This support is added so that the XYUV shader variant can be tested with
wl_shm from the test suite.

Libwayland version requirement is bumped to get WL_SHM_FORMAT_XYUV8888.
Libwayland is bumped to 1.18 too in the CI image. libwayland-dev package
is dropped, because we build wayland anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:24 +02:00
Pekka Paalanen
4b301fe7f2 Add weston-drm-fourcc.h
This header is for sharing fallback definitions for drm_fourcc.h. A new
test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format,
and more new formats will be expected with HDR supports.

Share these fallback definitions in one place instead of copying them
all over.

All users of drm_fourcc.h are converted to include weston-drm-fourcc.h
instead for consistency: have the same definitions available everywhere.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen
b9ca801324 drop MOD_INVALID, MOD_LINEAR definitions
MOD_INVALID came with libdrm 2.4.83 and MOD_LINEAR came with libdrm
2.4.82. libweston unconditionally depends on libdrm >= 2.4.95, so the
fallback is not necessary.

Since linux-dmabuf.h itself has no use for these and also forgets to
include drm_fourcc.h, .c files including drm_fourcc.h after this header
would trigger compiler warnings.

linux-dmabuf.c does need these, so add the proper include.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen
e51a75c7b3 gl-renderer: drop R8 and GR88 definitions
These were introduced in libdrm 2.4.68, commit
268ae7cae5afd76462c3ef14ed9021a2d40c2e57. Weston unconditionally
requires libdrm >= 2.4.95, so these fallback definitions are
unnecessary now.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen
b1e56143c5 tests: extend output-damage to GL shadow framebuffer
Extend the existing output-damage test to test
blit_shadow_to_output() specifically. This function had problems
originally, so make sure they can't reappear.

The added quirk is explained in the test.

An additional check of the quirk in gl_renderer_output_create() ensures
that the shadow framebuffer is really used. The test could false-pass if
the shadow is not used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:27:33 +02:00
Harish Krupo
7ef26886f5 gl-renderer: implement intermediate framebuffer (shadow)
Proper color management will need blending done with linear light pixel
values, that is, EOTF applied before blending, and then inverse-EOTF
applied for scanout after blending. The simplest way to set that up is
to use an intemediate framebuffer a.k.a shadow buffer containing the
composited image in linear light values, then blit from that to the
actual framebuffer.

This patch implements the shadow buffer, but the linear light
blending is left for another patch. This allows GL-renderer to turn
WESTON_CAP_COLOR_OPS on.

Half-float is chosen as the buffer format because linear light values
require more bits to encode with sufficient precision than the usual
non-linear pixel values.

v2: Use /* */ instead of // (Pekka)
    Rename fbo and tex to shadow_{fbo,tex} (Pekka)
    Check for OpenGLES capabilities before creating
    shadow_{tex,fbo} (Pekka)

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>

v3: Rebased.
    Simplified GL version checks (Sebastian)
    Apply changes from "libweston: add color ops cap and bool renderer
    shadow buffer"
    Renamed supports_half_float_texture to has_gl_half_float to
    follow the existing naming pattern.
    Introduce gl_renderer_create_shadow_16f().
    Undo moving of glViewport() call.
    Replace half_float_texture_enabled with shadow_exists().
    Introduce struct gl_output_state_shadow.
    Assert no resizing with shadow.
    Fix triangle fan debug.
    Rename repaint_from_texture() to blit_shadow_to_output().
    Rewrite commit message because linear light blending is not
    implemented in this patch.
    Fix blit_shadow_to_output() for scaled/transformed outputs and
    remove redundant code.
    Fix has_gl_half_float determination.

v4: Disable blending in blit_shadow. (Daniel)
    Port to gl_renderer_get_program().
    Make a generic fbo-texture struct with parameterized format. (Daniel)
    Change has_gl_half_float into gl_half_float_type.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
0692079aae pixman-renderer: share region_global_to_output()
Converting a region from global coordinates to output pixel coordinates
will become useful in GL-renderer soon, so move this function to be
shared. It is tricky to reinvent.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
b5265af620 libweston: add color ops cap and bool renderer shadow buffer
This adds the libweston capability bit for "color operations" which
refers to a renderer's support for operations needed for color
management. GL-renderer will grow the support while Pixman-renderer will
not, which is why the cap is needed.

To make an example use of the cap, this also adds new API:
weston_output_set_renderer_shadow_buffer(). This is a temporary API to
enable future experimental features. The first such feature will be the
renderer internal shadow buffer, the boolean variable for it taken from
Harish Krupo's "weston.ini: introduce use-shadow-fbo in output config".

Obviously this patch does not implement the renderer shadow buffer. No
renderer sets WESTON_CAP_COLOR_OPS yet so trying to enable it will fail.

The documentation here is deliberately vague, because the bits needed
for color management will come in trickling for a long time until we can
call it color management in any sense. Until then, the temporary API
shall remain, perhaps poorly named.

Cc: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Harish Krupo
71078b4044 gl-renderer: Add debug scope for shader generator
This helps accounting how many shaders live in the cache, what the
shader source code is, and when shaders are compiled.

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>

v2: Resolved rebase conflicts.
    Put shader_scope in struct gl_renderer, remove struct
    gl_shader_generator.
    Wrote commit message.
    Rebased for "gl-renderer: rewrite fragment shaders" which completely
    changed how shader sources are generated.
    Added cache statistics to debug output on subscribe.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
7714c6172d gl-renderer: add missing glActiveTexture calls
Various functions leave the current active texture as whatever. The
functions touched in this commit forgot to reset the active texture to
slot 0 before binding their textures. If not explicitly unbound, this
could leave textures lingering in unused slots, perhaps. Not sure if
that could cause any harm, but for consistency's sake, always use slot 0
when not multitexturing.

Found by code inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
c12963f98d gl-renderer: add fallback shader
If shader compiling on demand fails, then rather than using whatever
random shader happens to be current, use an explicit fallback shader
painting stuff brown.

The color is chosen dim enough to hopefully not cause problems even in
a HDR setting as it will be written verbatim into the fb/shadow.

This also prevents NULL dereference on shader->key.variant in
draw_view().

One way to test this shader is to hack fragment.glsl:
 #if DEF_VARIANT == SHADER_VARIANT_EXTERNAL
 #extension GL_OES_EGL_image_external : require
+#error haa haa
 #endif

and then run e.g. weston-simple-dmabuf-v4l -f YUYV
with vivid kernel module loaded. This worked on Intel.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
06c9d0f054 gl-renderer: send protocol error on shader failure
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>
2021-02-25 13:16:02 +02:00
Harish Krupo
7903c5e667 gl-renderer: Requirement based shader generation
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>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
e41c6d90d0 gl-renderer: simplify shader replacement in draw_view()
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>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
5b86f366c7 gl-renderer: dump failed shader source
To help debugging shader compilation errors, print the shader source the
way it was given to the GLSL compiler and with line numbers that match
the compiler error messages.

This is necessary because some snippets are added at runtime to the
beginning, the source is not only what is in the respective .glsl file.

I did look into using #line directives, but you cannot put source file
names to it, only "source string numbers" which must be an integer
expression. If we used #line, the reader would need to know that string
number 0 is the version, string 1 is the config and string number 2 is
fragment.glsl. I think that would have been too cumbersome.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
5d64e66e06 gl-renderer: rename shader debug flag to green_tint
The new name reflects better what it does.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
477bdc85c9 gl-renderer: rewrite fragment shaders
The main goal of this patch is to improve the readability of how and
what fragment shaders are generated.

Instead of having C code that assembles each shader variant from literal
string snippets, create one big fragment shader source that has
everything in it. This relies on a GLSL compiler to optimize statically
false conditions and unused uniforms away.

Having all the fragment shader code in one file, uncluttered by C string
literal syntax, improves readability significantly. A disadvantage is
that the code is more verbose, but it allows comments much better.

The actual shader code is kept unchanged except:
- FRAGMENT_CONVERT_YUV macro is now a proper function
- GLSL version is explicitly set to 1.00 ES
- RGBA and EXTERNAL use the same path, the difference is how the sampler
  is declared

Further shader code consolidation is possible, but is left for another
time.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
d913363394 gl-renderer: move vertex shader into new file
This patch adds the tooling for incorporating files as C data, so that
files can be built into the binaries. The tool is in Python to avoid
adding extra dependencies like xxd.

xxd.py is copied from Mesa as-is, from commit
b729cd58d76f97f3fc04a67569535ee5ef2f5278 (master branch on 2021-01-26),
a.k.a 21.0-branchpoint-635-gb729cd58d76.

Moving the GLSL vertex shader into a separate file is not that
interesting, the purpose of this commit is to provide a simple
demonstration of the tooling. The real benefits come in a following
patch where the fragment shaders are re-written and externalized.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
3ec25d7812 gl-renderer: split into gl-shaders.c
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>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
d8a0ba893d gl-renderer: bikeshed GL version handling
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>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
fbd4160474 tests: add output damage test
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>
2021-02-25 12:54:17 +02:00
Pekka Paalanen
1e365c8c4c gl-renderer: assume pbuffers preserve contents
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>
2021-02-25 12:47:07 +02:00
Pekka Paalanen
b4f91edb5e libweston: do not damage on screenshot
If full output damage is forced every time a screenshot is taken, the
test suite cannot take screenshots of damage as that would depend on
repainting only the damaged area.

Stop damaging the output and instead just schedule a repaint so the
screenshot can be taken. This is safe because:

- if any views were promoted to hw planes previously,
  weston_output_disable_planes_incr() would force them to be demoted at
  assing_planes() time causing damage via weston_view_move_to_plane()

- even when hardware primary plane has no damage, DRM-backend will not
  skip calling to the renderer after commit
  "drm-backend: do not skip renderer if capturing screen".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 12:47:07 +02:00
Pekka Paalanen
7f1a113c89 drm-backend: do not skip renderer if capturing screen
The renderer must be called for any pending screen capture to complete.
Previously this was guaranteed by weston_screenshooter_shoot() forcing
full output damage, so damage was never empty. If the future,
screenshooting stops inflicting damage, and the damage on the primary
plane even after disabling hardware planes may be empty.

This patch ensures that screenshots do not get stuck until damage
occurs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 12:47:07 +02:00
Maxime Roussin-Bélanger
1d009c248e libweston: fix typos
Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
2021-02-24 10:01:17 -05:00
Maxime Roussin-Bélanger
35e34505ce backend-drm: fix typos
Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
2021-02-24 10:01:07 -05:00
Pekka Paalanen
eb5a95bfc9 libweston: move TYPEVERIFY macro into shared
This will be useful in the test harness macros.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-17 12:52:33 +00:00
Emmanuel Gil Peyrot
0b48e6b5ca backend-wayland: Abort early when wl_shm isn’t advertised
This prevents a segfault in libwayland-cursor when the parent compositor
doesn’t have any of the needed protocols implemented.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2021-02-12 12:31:26 +01:00
nerdopolis
9cb96f8353 launcher-logind: handle any seat without VTs
Instead of assuming that seat0 has TTYs, use logind to check if
the seat has TTYs
2021-01-21 09:02:26 +00:00
nerdopolis
72db3ac694 launcher-direct: handle seat0 without VTs
This allows launcher-direct to run when seat0 has no TTYs
This checks for a proper /dev/tty0 device as /dev/tty0
does not get created by kernels compiled with CONFIG_VT=n
2021-01-21 09:02:26 +00:00
Anurup M
aa7de33e03 launcher: Add more error logging to launcher backends
Add error logging in three different launcher backends:
launcher-logind, launcher-weston-launch, and launcher-direct
to indicate failures for easier debug

Signed-off-by: Anurup M <anurup.m@huawei.com>
2020-12-16 07:23:02 +00:00
Pekka Paalanen
593d5af43a gl-renderer: require GL_EXT_unpack_subimage
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>
2020-12-15 14:42:46 +00:00
Pekka Paalanen
2d738b856d launcher-direct: warn when opening devices non-root
Warn the user that this is not supposed to work. Developers who know
what they are doing know to ignore this message, others should think
twice.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-11 10:18:19 +00:00
Pekka Paalanen
4e9f4d0474 launcher-direct: allow non-root on non-seat0
If the launcher is told to use a non-default seat (not seat0), there
will not be a VT or tty to set up. VT/tty setup requires privileges.

This patch allows a non-root user to use launcher-direct, provided that
the seat is not the default. There is still the problem of opening DRM
and input devices, which is left for the user to solve.

This mode of operation is useful for developers who can set up a
secondary seat on their machine. You can run Weston/DRM from a terminal
window by pointing it to a non-default seat. You have to arrange a
DRM device by having an extra unused graphics card in the machine. You
also need dedicated input devices. Both the DRM device and the input
devices must be assigned to the secondary seat and device file
permissions adjusted so that they can be opened.

Doing so is an obvious security risk, as input could easily be
eavesdropped.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-11 10:18:19 +00:00
Marius Vlad
e825fe389e libweston/libinput-device: Enable/Set pointer capabilities only on pointer movement
Some panels advertise both pointer/touch capabilities but without having
real capability of driving a cursor (they're basically touch panels) and
use USB as a communication tunnel to transfer/send out input events.

As we can't really tell if they're fake or not, only advertise to
clients pointer capabilities if we detect movement on the cursor/pointer.

We handle it at lower level as that allows to handle the case where
removal of a real pointer should also remove the cursor from being
displayed on the screen.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-12-08 17:54:55 +02:00
Marius Vlad
a86b590fea backend-drm: Fix ignoring config 'require-input' option
Without this patch, the DRM-backend would rewrite the 'require-input',
core section option given by the user.

This removes 'continue_without_input' DRM-backend option and takes into
consideration the cmd line option only if that was passed (Pekka Paalanen).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-12-07 12:49:38 +02:00
Leandro Ribeiro
cdb7218daf compositor: move tests quirks initialization to weston_compositor_create()
Until now we had the test quirks initialization in wet_main(),
just after calling weston_compositor_create(). But there are
some cases that require the quirks during struct weston_compositor
creation time.

Move test quirks initialization to weston_compositor_create()
in order to cover more use cases for the test quirks mechanism.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-11-17 12:38:42 +00:00
bnlrnz
cf83b48be4 backend-headless: NULL check after wl_event_loop_add_timer
Running weston with headless backend will segfault if wl_event_loop_add_timer fails
   Closes #102

   Signed-off-by: Ben Lorenz <bnlrnz@gmail.com>
2020-11-06 16:13:24 +00:00
Leandro Ribeiro
2d4dd70ff5 libweston: drop opaque struct wet_testsuite_data
Until now we had struct wet_testsuite_data as an opaque
struct that should be defined by the testsuite of libweston
users. Instead, keep the data as a void * and document that
users are responsible for defining the data type.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 11:21:55 +00:00
Leandro Ribeiro
32a5acde5b tests: add mechanism to change Weston's behavior when running certain tests
There are some specific cases in which we need Weston to
behave differently when running in the test suite. This
adds a new API to allow the tests to select these behaviors.

For instance, in the DRM backend we plan to add a writeback
connector screenshooter. In case it fails for some
reason, it should fallback to the renderer screenshooter
that all other backends use. But if we add a test to
ensure the correctness of the writeback screenshooter,
we don't want it to fallback to the renderer one, we
want it to fail. With this new API we can choose to
disable the fallback behavior specifically for this test.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-10-27 11:21:55 +00:00
Heiko Thiery
ea0b03dff0 libweston/backend/drm: might need EGL
gbm-drm.c includes gl-renderer.h. When EGL is enabled, that in turns
includes egl.h. As such, dependencies for drm should include EGL if
it is available.

This condition is modelled after a similar one in libweston/meson.build

Reported-by: Gary Bisson <gary.bisson@boundarydevices.com>
Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Refik Tuzakli <tuzakli.refik@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
2020-10-26 15:44:34 +01:00
Pekka Paalanen
8285005744 libweston: constify data_source_interface
Found mutable global variables with
 $ grep -P '^static (?!const).*[=;]' -- compositor libweston shared

Mutable global or static variables make it harder to run several
compositor instances in the same process. That is what the test suite
would probably need to do to test wayland-backend.

This one variable does not need to be mutable.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-10-21 14:18:30 +03:00
Igor Matheus Andrade Torrente
6354455979 backend-drm: Reuse drmModeRes in drm_backend_create
Rework some functions in `drm.c` to reuse the `drmModeRes` and
reduce the usage of `drmModeGetResources` and `drmModeGetResources`.

Signed-off-by: Igor Matheus Andrade Torrente <igormtorrente@gmail.com>
2020-10-19 09:12:02 +00:00
Pekka Paalanen
9b94a7d833 Bump libdrm dependency to 2.4.95
96bef0517e "drm-backend: add support for
writeback connectors" started using DRM_MODE_CONNECTOR_WRITEBACK and
DRM_CLIENT_CAP_WRITEBACK_CONNECTORS. These were introduced in libdrm
2.4.95.

According to
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/311
Ubunut Xenial is the only mentioned distribution that does not provide a
libdrm new enough. I think that is fine to drop now, 2016 was a good
while ago.

Libdrm 2.4.95 also introduced DRM_CLIENT_CAP_ASPECT_RATIO,
DRM_MODE_PICTURE_ASPECT_64_27, DRM_MODE_PICTURE_ASPECT_256_135.

The fallback definitions for the above are dropped.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-10-16 16:20:54 +00:00
Stefan Agner
7d2da94b05 backend-rdp: release seat on peer disconnect
Properly release the seat on RDP disconnect. Using current master
branch which is commit d93c0f7059 ("backend-rdp: fix memory leak")
I was not able to reproduce the crash on reconnect as mentioned in the
current comment. Using Weston with rdp-backend directly as well as
using the screen-share plug-in allowed to reconnect just fine. Hence
release the Weston seat properly using weston_seat_release and free
the seat structure. This also avoids mouse pointers displayed for
every RDP connection.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2020-10-16 12:11:27 +00:00
David Fort
e3f447eee8 rdp-backend: require FreeRDP >= 2.2 to remove all the version hacks
The stable FreeRDP 2.x branch has been released, so let's rely on that maintained
version and drop all the hacks for older versions. That makes the code and build
cleaner.

Signed-off-by: David Fort <contact@hardening-consulting.com>
2020-10-01 18:15:42 +02:00
David Fort
495a892190 rdp-backend: unify creation of pixman_renderer_output
As pointed by Daniel Stone in #372, creation of pixman renderer outputs in the
rdp backend were inconsistant regarding use_shadow.
2020-09-30 09:55:56 +02:00
Leandro Ribeiro
96bef0517e drm-backend: add support for writeback connectors
Recognize writeback connectors and add 'struct drm_writeback'
objects in order to store them.

These objects are created and stored in a list by the time
that DRM-backend is initialized. This list is updated if a
writeback connector dynamically appears or is disconnected.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
7243022b38 drm-backend: add function drm_backend_add_connector() to create drm_head for connectors that appear
Instead of directly creating heads for the connectors in functions
drm_backend_create_heads() and drm_backend_update_connectors(),
add drm_backend_add_connector() that will handle this.

This split makes the code look better and will also make our lives
easier when we introduce writeback connectors.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
99611c8788 drm-backend: add helper function resources_has_connector()
Add helper function resources_has_connector(), what makes
the function drm_backend_update_connectors() look better.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
993920dd81 drm-backend: rename drm_backend_update_heads() to drm_backend_update_connectors()
To deal with appearing/disappearing connectors we have the
function drm_backend_update_heads(). Rename it to
drm_backend_update_connectors(), as it is more in line with
what it does.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
4a5b67a5db drm-backend: update description of drm_head_create() and drm_head_update_info()
In case of success, drm_head_create() and drm_head_update_info()
take ownership of a connector. As this is an important
information, update the description of these functions
to include this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
6794164bd9 drm-backend: move drm_head management from drm_connector_assign_connector_info() to drm_head_update_info()
The function drm_connector_assign_connector_info() should
not be calling functions to handle drm_head, as connectors
and heads are not the same thing after patch "drm-backend:
move connector data from struct drm_head to struct drm_connector".

Move drm_head specific calls to drm_head_update_info(). This
is more in line with the hierarchy of the objects and also
allow us to drop drm_head pointer from drm_connector.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
7086396f75 drm-backend: reduce number of drmModeGetConnector() calls
Instead of calling drmModeGetConnector() in drm_head_create()
and drm_head_update_info(), it is better to call it in
drm_backend_create_heads() and drm_backend_update_heads().
Then we can pass the drmModeConnector object as parameter.
This does not change the behavior of the code, but help us
to avoid unnecessarily calling drmModeGetConnector().

Besides that, in the future we will have support for writeback
connectors. And so drm_backend_create_heads() will be reworked
to also populate a list of writeback connectors. To make this
work, we are going to need to know if a connector is of the
writeback type or not, to know if we should call drm_head_create()
or drm_writeback_create(). We can only tell the type of connector
if we have the drmModeConnector object.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
702fbf7282 drm-backend: cache drmModeObjectProperties for connectors
Instead of calling drmModeObjectGetProperties() each time that we need
the connector properties, it is better to keep a reference for it in
struct drm_connector. This reference is only updated when is necessary.
E.g. hotplug events.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
e636990de3 drm-backend: move connector data from struct drm_head to struct drm_connector
This is the first step in order to add support for writeback
connector in Weston. We don't want writeback connectors data
to be stored in 'struct drm_head' objects, as these objects are
used to output content and we should not use writeback connectors
for this purpose.

The writeback connectors will be stored in a new 'struct
drm_writeback', but the connector data is common between
'struct drm_head' and 'struct drm_writeback'.

So move connector data from 'struct drm_head' to 'struct
drm_connector'. This helps to avoid code duplication and makes
the code clearer.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Leandro Ribeiro
bb33f90658 drm-backend: free old connector props before replacing it with newer data
In commit c1e89ba2 "compositor-drm: move connector fields into
drm_head" the function drm_head_assign_connector_info() was
introduced. By that time it was being used only at drm_head
creation, and not to handle connector changes.

In d2e6242e "compositor-drm: create heads for all connectors"
it started to be used also to handle connector changes. In
this scenario we replace old connector props with newer data.
Before doing this, free the old connector data to avoid memory
leak.

Note that as drm_property_info_free() is safe to be called on
a zero-initialized struct, we can call it even in the case where
the head is being created and there are no props yet.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-16 14:03:18 +00:00
Pekka Paalanen
3d6721eb15 drm-backend: fix deinit_planes
Commit "drm-backend: move code to init/deinit planes to specific
functions" lost a chunk of drm_output_deinit() when moving code into
drm_output_deinit_planes(). Reinstate the missing chunk.

This fixes an endless loop over weston_compositor::plane_list when you
start with three monitors connected, unplug and re-plug one.

Fixes: 3be23eff99

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-09-16 15:04:04 +03:00
Leandro Ribeiro
de1b77e7cd drm-backend: do not set output->crtc to NULL in drm_output_init_planes() failure
After commit "drm-backend: move code to init/deinit planes to specific
functions" we have a specific function to init planes. As this function
does not set output->crtc, it should not set it to NULL in case of
failure. This is caller's responsibility.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-08 10:05:26 -03:00
Leandro Ribeiro
05cecc8ef3 drm-backend: cosmetic changes to make the code easier to read
There are some places where we can make some cosmetic changes
to make code simpler and easier to read. Make these cosmetic
changes. Note that they do not change the code behavior.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-07 13:08:18 -03:00
Leandro Ribeiro
3be23eff99 drm-backend: move code to init/deinit planes to specific functions
The code to init/deinit scanout and cursor planes was in
drm_output_init() and drm_output_deinit(). Move this code
to specific functions drm_output_init_planes() and
drm_output_deinit_planes(), as it makes the code clearer
and easier to maintain.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-07 13:06:14 -03:00
Leandro Ribeiro
744c0cbb32 drm-backend: drop unused_crtcs from struct drm_backend
Now that we have a CRTC list in the DRM-backend, we can
iterate through it and look for the CRTCs that do not have
assigned outputs in order to find unused CRTCS.

So we can drop unused_crtcs from struct drm_backend and also
drop the functions drm_backend_update_unused_outputs() and
wl_array_remove_uint32().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-07 13:04:06 -03:00
Leandro Ribeiro
b00d1a2efb drm-backend: move CRTC data from struct drm_output to new struct drm_crtc
There are no 'struct drm_output' for CRTCs that are not active.
Also, CRTC data lives in 'struct drm_output'. This is causing
us some trouble, as the DRM-backend needs to program those
unnactive CRTCs to be off.

If the DRM-backend had the reference for every CRTC (being
active or not), it would make certain functions (e.g.
drm_pending_state_apply_atomic()) more simple and efficient.

Move CRTC data from 'struct drm_output' to 'struct drm_crtc',
as this is the first step to allow the DRM-backend to have
references for every CRTC.

Also, add list of CRTCs to DRM-backend object. Now the
DRM-backend is responsible for allocating/deallocating the CRTC
objects. The outputs will only reference, init and fini the CRTCs
in this list.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-09-07 12:39:10 -03:00
Daniel Stone
ebcf4f35b4 drm/state-propose: Flatten and clarify control flow
Try to make drm_output_state_propose a little more clear by reducing
divergence between plane and renderer modes towards the end, removing
a possibly-surprising conditional continue.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-09-04 11:04:26 +00:00
Daniel Stone
71e6ba5c06 drm/state-propose: Fix fix typo typo
Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-09-04 11:04:26 +00:00
Daniel Stone
8ca5d73355 drm/state-propose: Reduce variable scope
Reduce the scope of surface_overlap to where it's actually used, which
is only in the per-view loop, where it gets initialised and destroyed
every time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-09-04 11:04:26 +00:00
Daniel Stone
b625cdcf20 drm/state-propose: Remove special casing for cursor plane
Previously we assumed that cursor planes occluded nothing and would
always be blended, but overlay and scanout planes would always occlude
what's behind them. This is not actually true, as we can support alpha
blending on any kind of plane type now.

Remove the special case, which might hopefully fix some weird display
issues along the way. (Noticed by inspection.)

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-09-04 11:04:26 +00:00
Daniel Stone
9217ec9c6c drm/state-propose: Remove unused planes_region member
We used to use planes_region for the output regions which were being
displayed on hardware planes; before we grew zpos awareness, we couldn't
have any planes overlapping with each other, since the ordering would be
undefined.

Since the zpos awareness though, this region is unused, so we can just
remove it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-09-04 11:04:26 +00:00
Michael Olbrich
0e4f097d08 compositor: clip the opaque region with the scissor area
The opaque region is used to determine where the views underneath the current
view must be drawn. If the opaque is not clipped, then the area that is part of
the opaque region but not part of the scissor area is not drawn at all.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-09-04 11:01:26 +00:00
Michael Olbrich
cb04f9894f compositor: update scissor region before using it
Subsurfaces inherit the scissor region from the parent surface. Currently
the region is updated at the end of weston_view_update_transform(). As a
result, the old region is used to clip the transform.boundingbox of the
subsurface.

Change the order to update the scissor region after the transform.matrix is
updated but before it is used.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-09-04 11:01:26 +00:00
Marius Vlad
67b382ccdc compositor: Avoid using weston_log() in weston_view_is_opaque()
As from commit b7e5f10bf4, weston_view_is_opaque() is called from
debug_scene_graph_cb(), which on its own represents a (different)
scope. By default, we already have a subscriber for the 'log' scope,
which will cause a harmless, yet spurious, message.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-08-24 14:19:02 +03:00
Michael Olbrich
d70e712c2f drm: always check the repaint_status in update_complete
Initially finish_frame() was never called in drm_output_update_complete() for
'dpms_off_pending = true'. This is wrong for repaint_status ==
REPAINT_AWAITING_COMPLETION and that was fixed in
68d49d772c ("compositor-drm: run finish_frame when
dpms is turned off in update_complete").
However finish_frame() may now be called for repaint_status !=
REPAINT_AWAITING_COMPLETION, which is not allowed and results in a failed
assertion.

Fix this by checking dpms and repaint_status unconditionally.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-19 07:35:14 +02:00
Marius Vlad
5130a8c21a backend-drm: Correctly tear down the DRM backend
It seem that we skipped to put back in TEXT mode the tty, in case a DRM
device node wasn't present at that time, or it isn't present at all. This
orders the destroy part correctly as to handle that case as well.

As a side effect, as the tty will still be set to GRAPHICS mode we will
require a manual change of the tty number, which might be not possible
on all systems. Properly putting back the tty to TEXT mode should avoid
that, and allows to re-use the same tty no in case the DRM device has
been created at a later point in time.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-08-18 12:59:50 +03:00
Andreas Heynig
2592d6591e libweston/launcher-direct.c: do not fail if already in graphics mode
In case of a crash tty remains in graphic mode. This change allows to restart weston without
taking care of the actual tty mode.

Signed-off-by: ahe <Andreas.Heynig@meetwise.com>
2020-08-17 11:59:39 +00:00
Stefan Agner
465ab2cd92 backend-drm: allow to disable GBM modifiers
Allow to disable GBM modifiers at runtime using the environment variable
WESTON_DISABLE_GBM_MODIFIERS.

This can be useful for debugging or when modifiers cause issues, e.g. in
case modifiers use higher memory bandwidth and hence impose a lower
resolution limit as it is the case with Intel Kaby Lake graphics.

Related to: https://gitlab.freedesktop.org/wayland/weston/-/issues/404
Signed-off-by: Stefan Agner <stefan@agner.ch>
2020-08-17 10:17:30 +00:00
Michael Olbrich
43ebb7e25a backend-drm: the GL renderer is a hard requirement for DRM virtual outputs
Building fails without it. So don't just warn about it but fail immediately.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-17 10:12:54 +00:00
Michael Olbrich
27fb564a19 backend-drm: build DRM virtual support when the pipewire plugin is enabled
The pipewire plugin uses this API as well, not just the remoting plugin. So
enable it if either is enabled.

And disable pipewire in the no-gl-renderer CI build. The virtual outputs don't
work without it.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-17 10:12:54 +00:00
Michael Olbrich
3097acc702 backend-drm: reorder plane checks to avoid unnecessary rendering
If a surface is not visible, then is does not matter if the view is on multiple
outputs. It will be skipped anyways when the output is rendered.

So check first if the surface is acually visible on the output before doing any
checks that might force rendering. This avoids unnecessary rendering.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-17 09:53:38 +00:00
Alexandros Frantzis
53a71cb186 drm: Reset associated universal plane states when finalizing a crtc
When dissociating a universal plane from a crtc, we currently don't
reset the current state of the plane (plane->state_cur). When attempting
to use this plane in the future, we can run into invalid memory accesses
due to left over associations with potentially freed drm backend
objects. This commit resets the state of the scanout and cursor
universal planes associated with a crtc.

The following scenario exhibits the problem:

1. Start a (fullscreen) client that is suitable for and assigned to
   the scanout plane. The plane's state_cur->output value is set.
2. Unplug the monitor: the scanout plane is "released" but still
   maintains the state_cur->output association.
3. Replug the monitor: the plane is deemed unavailable due to an
   existing, albeit invalid, state_cur->output value. Note the memory
   errors trying to access the drm_output which was freed at step (2).

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2020-08-17 09:44:45 +00:00
Alexandros Frantzis
9975134593 drm: Introduce drm_plane_reset_state() helper function
Introduce a helper function to reset the current state of a drm_plane.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2020-08-17 09:44:45 +00:00
Michael Olbrich
ad41ad968a gl-renderer: remove incorrect assertion
The refcount is not zero if the corresponding buffer is attached to multiple
surfaces.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-13 18:50:57 +00:00
Michael Olbrich
c5ea495f7a compositor: ignore views on other outputs during compositor_accumulate_damage()
compositor_accumulate_damage() is called for each output during repaint.
The DRM backend will only set keep_buffer for the surfaces that are visible on
the current output. So a buffer_ref is released that may still be needed. When
the output that shows the surface is repainted, the buffer_ref is gone and the
surface cannot be put on a plane.

Ignore all surfaces that are not visible on the current output to avoid this.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-12 11:03:43 +00:00
Michael Olbrich
b7e5f10bf4 compositor: use weston_view_is_opaque() to check for opacity in debug_scene_view_print()
Currently the debug output for 'drm-backend' can be confusing. In the output of
debug_scene_view_print() views may be listed as 'not opaque' but later, during
plane assignment, other views underneath such a view is reported as 'occluded on
our output'.
This happens because weston_view_is_opaque() has some extra checks to determine
if a view is fully opaque, such as 'is_opaque' provided by the renderer for
formats that have no alpha channel.

Use weston_view_is_opaque() in debug_scene_view_print() as well to get more
accurate results.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-11 16:41:14 +02:00
Michael Olbrich
3ac911f69b drm: remove duplicate function declarations
These functions are all declared twice in the same file. Remove on of the two
declarations.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-06 10:22:18 +02:00
Leandro Ribeiro
ea4d13b3e3 drm-backend: remove log that advertises universal planes support
There's a log that advertises support for universal planes. That
can make users think there's something wrong with Weston or their
systems when universal planes are not supported, but that's not
the case. Remove this log from the code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-07-28 11:13:53 -03:00