Fixes a definitely lost:
== 56 bytes in 1 blocks are definitely lost in loss record 16 of 45
== at 0x48450F8: malloc (vg_replace_malloc.c:309)
== by 0x4B55E93: wl_event_loop_add_timer (event-loop.c:197)
== by 0x4126CF: weston_compositor_create (in /usr/local/bin/weston)
== by 0x409997: main (in /usr/local/bin/weston)
Signed-off-by: Lujin Wang <luwang@nvidia.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This fixes the following leaks detected by ASan in
./tests/test-alpha-blending:
Direct leak of 176 byte(s) in 2 object(s) allocated from:
#0 0x7fb447880518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fb4432c12d7 in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fb4432c2ca6 in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:410
#3 0x7fb4432baadf in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
#4 0x7fb4432e1e1f in wet_shell_init ../../git/weston/tests/weston-test-desktop-shell.c:224
#5 0x7fb44775fddd in wet_load_shell ../../git/weston/compositor/main.c:956
#6 0x7fb447770db1 in wet_main ../../git/weston/compositor/main.c:3434
#7 0x56172c599279 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#8 0x56172c59cce5 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#9 0x56172c58dc8c in fixture_setup ../../git/weston/tests/alpha-blending-test.c:65
#10 0x56172c58dd31 in fixture_setup_run_ ../../git/weston/tests/alpha-blending-test.c:67
#11 0x56172c59d29a in main ../../git/weston/tests/weston-test-runner.c:661
#12 0x7fb4473d509a in __libc_start_main ../csu/libc-start.c:308
Indirect leak of 144 byte(s) in 2 object(s) allocated from:
#0 0x7fb447880518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fb4432bb592 in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fb4432bb882 in weston_desktop_client_create ../../git/weston/libweston-desktop/client.c:108
#3 0x7fb4432c2d0e in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:415
#4 0x7fb4432baadf in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
#5 0x7fb4432e1e1f in wet_shell_init ../../git/weston/tests/weston-test-desktop-shell.c:224
#6 0x7fb44775fddd in wet_load_shell ../../git/weston/compositor/main.c:956
#7 0x7fb447770db1 in wet_main ../../git/weston/compositor/main.c:3434
#8 0x56172c599279 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#9 0x56172c59cce5 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#10 0x56172c58dc8c in fixture_setup ../../git/weston/tests/alpha-blending-test.c:65
#11 0x56172c58dd31 in fixture_setup_run_ ../../git/weston/tests/alpha-blending-test.c:67
#12 0x56172c59d29a in main ../../git/weston/tests/weston-test-runner.c:661
#13 0x7fb4473d509a in __libc_start_main ../csu/libc-start.c:308
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This new function is callable explicitly, unlike the old function that
used to have the same name.
This will be needed when tearing down what
weston_desktop_xwayland_init() puts up.
Since calling weston_desktop_client_destroy() for an external client
(one that has a wl_resource for this) is a bug, add asserts to prevent
it. This will only be needed for the internal client: XWM.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This function here is a wl_resource destructor, but we will need another
function for externally triggered destroy when wl_resource does not
exist.
Rename the existing function, because the old name fits better the new
function to be written.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
There would be a lot more to tear down here, but that is for another
time.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Layers did not have a fini sequence before, which means the compositor
layer list might have stale pointers temporarily when shutting down. A
bigger problem might be having views linger after the destruction of the
layer.
These problems were not observed yet, but if they exist, this patch
should help to find them and then fix them.
The check in weston_compositor_shutdown() is not an assert yet, because
it will trigger until all components call weston_layer_fini() correctly.
Some components do not even have a tear-down function to call it from at
all, like fullscreen-shell.
The same with the check in weston_layer_fini().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
$FDO_CI_CONCURRENT is provided by in the CI environment by the fd.o
GitLab runners to tell us how many parallel processes would be 'good' to
use.
Use this to override the default Ninja invocation which uses as many
CPUs as available, and instead tell it to use as many parallel processes
as the runner thinks we should during the build process.
Tests are invoked using `meson test` inside a virtme/QEmu VM; whilst
Meson's test backend will use as many processors as availble, virtme
will by default create a single-CPU VM. So if we create a VM with as
many CPUs as we should have parallel processes, we can let it use all of
them. This also requires quadrupling the requested RAM so ASan doesn't
force us straight into OOM.
Suggested by @daenzer.
Signed-off-by: Daniel Stone <daniels@collabora.com>
These are all the remaining places that still use the global view_list,
and cannot avoid it. Add a comment to explain why in each.
Now all places that use view_list have been audited for paint node
lists.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This patch creates a per-output paint node list in the same z-order as
the global view_list in weston_compositor.
The next step is to switch output repaints and backends to use the
z-order list instead of view_list.
Having a per-output paint node list for repaints allows including only
those paint nodes that actually contribute to the output image, so that
completely occluded and out-of-screen views can be ignored in libweston
core already.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This new object is created for every surface-view-output triplet. As
there is always exactly one surface for a view and it does not change
during a view's lifetime, this is really for a view-output pair or a
surface-output pair.
The object is created on-demand as a part of preparing for an output
repaint, so it applies only to surfaces that are going through repaint.
A prerequisite for that is that the surface is mapped, which means it
has a mapped view.
When any one of surface or view gets destroyed or output gets disabled,
all related paint nodes are destroyed.
In future, paint node will be useful for caching surface-output or
view-output pair dependent data:
- damage regions for overlapping outputs
- color transformations
- backend-specific bookkeeping (e.g. DRM KMS plane assigments)
- per-output repaint lists
- surface geometry transformed into output space
Suggested by Daniel Stone in
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/582#note_899406
PS. The call in weston_view_destroy() to
weston_compositor_build_view_list() might be so that if the view has
sub-surfaces, rebuilding the view list removes those those too and
automagically deletes their views.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
While this is harmless because gbm_bo_create_with_modifiers will just
fail, it's easy to misunderstand that gbm_bo_create_with_modifiers
accepts MOD_INVALID. Let's just keep modifiers_count to zero instead
and stop even trying to call that function with invalid input.
Stop using modifiers_count to decide whether the compositor supports a
format. Instead use a separate format_supported flag.
Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7601#note_778845
Running under ASan introduces a good amount of overhead. Using the Meson
test wrapper rather than invoking a Ninja target lets us set a timeout
multiplier, which we smash up pretty high to account for this overhead
and prevent some of the larger tests from hitting timeout.
Signed-off-by: Daniel Stone <daniels@collabora.com>
The old job names were really long, so long that Gitlab web UI had to
almost always ellipsize them, showing only the beginning which is the
same fof the two and hiding the part that actually matters.
Rename the templates and the jobs to be shorter and more descriptive.
Meson is the only tool we build with. All builds are native. Default
options is a long way to say full-featured and besides libseat was not
even default yet we build it.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
I'm tired of scrolling through that flood when looking at CI logs. It's
just listing every gcno, gcda and c file name as it parses them.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Change BUILDDIR and PREFIX from exported shell variables into CI
variables. This way they can be used in CI configuration, e.g.
artifacts.
The main reason for this change is that it makes it possible to use
these variables in after_script, which is not possible with shell
variables as the values do not carry over there.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Use the real name of the seat instead of calling each seat 'default'. This makes
it easier to identify the current seat in a multi-seat environment.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This change fixes the "touch-up" operation to clear "data_source"
by setting "seat" to NULL. This operation is done in the mouse button
release operation, but seems to have been forgotten in the "touch up"
case.
Forgetting this operation causes weston to send a "premature finish
request" error to the client which causes the client to exit.
This issue can be reproduced with the "weston-dnd" program by performing
a drag-and-drop operation with a touch input device. Once the drag
is released, the weston-dnd program will exit with an error.
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
If sprites_are_broken, then we will only ever arrive in renderer_only
mode, so this case will be caught by the checks above.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Avoids an user-after-free when destroying the surface, like in the
following ASAN message:
==25180==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060000589d8 at pc 0x7ff70a4f7102 bp 0x7fff8f7e13b0 sp 0x7fff8f7e13a8
READ of size 8 at 0x6060000589d8 thread T0
#0 0x7ff70a4f7101 in weston_schedule_surface_protection_update ../libweston/compositor.c:1163
#1 0x7ff70a4f743b in weston_surface_update_output_mask ../libweston/compositor.c:1212
#2 0x7ff70a4f7a47 in weston_surface_assign_output ../libweston/compositor.c:1298
#3 0x7ff70a4f7f44 in weston_view_assign_output ../libweston/compositor.c:1348
#4 0x7ff70a4fa12f in weston_view_update_transform ../libweston/compositor.c:1589
#5 0x7ff70a4ffc20 in view_list_add ../libweston/compositor.c:2657
#6 0x7ff70a5000ee in weston_compositor_build_view_list ../libweston/compositor.c:2688
#7 0x7ff70a4fd577 in weston_view_destroy ../libweston/compositor.c:2202
#8 0x7ff70a4fd7df in weston_surface_destroy ../libweston/compositor.c:2239
#9 0x7ff70a4fdbb0 in destroy_surface ../libweston/compositor.c:2285
#10 0x7ff70a4a2d3e in destroy_resource ../src/wayland-server.c:723
#11 0x7ff70a4a8940 in for_each_helper ../src/wayland-util.c:372
#12 0x7ff70a4a8e1f in wl_map_for_each ../src/wayland-util.c:385
#13 0x7ff70a4a3748 in wl_client_destroy ../src/wayland-server.c:882
#14 0x7ff6fe04e866 in shell_destroy ../desktop-shell/shell.c:5004
#15 0x7ff70a4ee923 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
#16 0x7ff70a51598d in weston_compositor_destroy ../libweston/compositor.c:7903
#17 0x7ff70a903a58 in wet_main ../compositor/main.c:3493
#18 0x560de7b3b179 in main ../compositor/executable.c:33
#19 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
#20 0x560de7b3b099 in _start (/home/mvlad/install-amd64/bin/weston+0x1099)
0x6060000589d8 is located 56 bytes inside of 64-byte region [0x6060000589a0,0x6060000589e0)
freed by thread T0 here:
#0 0x7ff70a9d3b6f in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xa9b6f)
#1 0x7ff70a5167d2 in cp_destroy_listener ../libweston/content-protection.c:193
#2 0x7ff70a4ee923 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
#3 0x7ff70a51598d in weston_compositor_destroy ../libweston/compositor.c:7903
#4 0x7ff70a903a58 in wet_main ../compositor/main.c:3493
#5 0x560de7b3b179 in main ../compositor/executable.c:33
#6 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
previously allocated by thread T0 here:
#0 0x7ff70a9d4037 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xaa037)
#1 0x7ff70a5160aa in zalloc ../include/libweston/zalloc.h:38
#2 0x7ff70a516cda in weston_compositor_enable_content_protection ../libweston/content-protection.c:329
#3 0x7ff7070247e0 in drm_backend_create ../libweston/backend-drm/drm.c:3180
#4 0x7ff707024cae in weston_backend_init ../libweston/backend-drm/drm.c:3250
#5 0x7ff70a515d02 in weston_compositor_load_backend ../libweston/compositor.c:7999
#6 0x7ff70a8fbcfb in load_drm_backend ../compositor/main.c:2614
#7 0x7ff70a900b46 in load_backend ../compositor/main.c:3103
#8 0x7ff70a902ecd in wet_main ../compositor/main.c:3380
#9 0x560de7b3b179 in main ../compositor/executable.c:33
#10 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: heap-use-after-free ../libweston/compositor.c:1163 in weston_schedule_surface_protection_update
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Use address sanitizer to catch use-after-free and other errors when
running the test suite.
Leak detection is disabled, because currently there are too many leaks,
making almost all tests fail otherwise.
The atexit=1 is for verifying that ASan was actually used.
The default 128 MB of RAM in the qemu machine leads to oom-killer
killing most tests, so bump the memory size to 1 GB.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Found by Address sanitizer on test-devices:
==10640==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000000580 at pc 0x7fa0f050dcd1 bp 0x7fff41c908e0 sp 0x7fff41c908d8
WRITE of size 8 at 0x60c000000580 thread T0
#0 0x7fa0f050dcd0 in unbind_input_method ../../git/weston/compositor/text-backend.c:852
#1 0x7fa0efd1b20d in destroy_resource ../../git/wayland/src/wayland-server.c:724
#2 0x7fa0efd1f7f1 in for_each_helper ../../git/wayland/src/wayland-util.c:372
#3 0x7fa0efd1fcde in wl_map_for_each ../../git/wayland/src/wayland-util.c:385
#4 0x7fa0efd1b35c in wl_client_destroy ../../git/wayland/src/wayland-server.c:883
#5 0x7fa0f050ea82 in text_backend_destroy ../../git/weston/compositor/text-backend.c:1067
#6 0x7fa0ebb69f2f in shell_destroy ../../git/weston/desktop-shell/shell.c:5012
#7 0x7fa0efd55933 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
#8 0x7fa0efd7d061 in weston_compositor_destroy ../../git/weston/libweston/compositor.c:7896
#9 0x7fa0f050a349 in wet_main ../../git/weston/compositor/main.c:3493
#10 0x559c1e794354 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#11 0x559c1e797dc0 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#12 0x559c1e786ab8 in fixture_setup ../../git/weston/tests/devices-test.c:39
#13 0x559c1e786b3a in fixture_setup_run_ ../../git/weston/tests/devices-test.c:41
#14 0x559c1e798375 in main ../../git/weston/tests/weston-test-runner.c:661
#15 0x7fa0f016e09a in __libc_start_main ../csu/libc-start.c:308
#16 0x559c1e786769 in _start (/home/pq/build/weston-meson/tests/test-devices+0xc769)
0x60c000000580 is located 0 bytes inside of 120-byte region [0x60c000000580,0x60c0000005f8)
freed by thread T0 here:
#0 0x7fa0f0618fb0 in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.5+0xe8fb0)
#1 0x7fa0f050df1d in input_method_notifier_destroy ../../git/weston/compositor/text-backend.c:902
#2 0x7fa0efd86d77 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
#3 0x7fa0efd98086 in weston_seat_release ../../git/weston/libweston/input.c:3475
#4 0x7fa0ebb0d002 in test_seat_release ../../git/weston/tests/weston-test.c:132
#5 0x7fa0ebb0e197 in device_release ../../git/weston/tests/weston-test.c:314
#6 0x7fa0efca88ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)
previously allocated by thread T0 here:
#0 0x7fa0f0619518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fa0f050a8bf in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fa0f050e6f1 in text_backend_seat_created ../../git/weston/compositor/text-backend.c:1011
#3 0x7fa0f050e947 in handle_seat_created ../../git/weston/compositor/text-backend.c:1040
#4 0x7fa0efd86d77 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
#5 0x7fa0efd97d57 in weston_seat_init ../../git/weston/libweston/input.c:3440
#6 0x7fa0ebb0ce4b in test_seat_init ../../git/weston/tests/weston-test.c:110
#7 0x7fa0ebb0f699 in wet_module_init ../../git/weston/tests/weston-test.c:592
#8 0x7fa0f04f8d69 in wet_load_module ../../git/weston/compositor/main.c:941
#9 0x7fa0f04f914d in load_modules ../../git/weston/compositor/main.c:1012
#10 0x7fa0f0509ec1 in wet_main ../../git/weston/compositor/main.c:3441
#11 0x559c1e794354 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#12 0x559c1e797dc0 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#13 0x559c1e786ab8 in fixture_setup ../../git/weston/tests/devices-test.c:39
#14 0x559c1e786b3a in fixture_setup_run_ ../../git/weston/tests/devices-test.c:41
#15 0x559c1e798375 in main ../../git/weston/tests/weston-test-runner.c:661
#16 0x7fa0f016e09a in __libc_start_main ../csu/libc-start.c:308
Fix UAF by resetting wl_resource user data, and ensuring it is valid
before used.
Setting seat->input_method to NULL may not be necessary since it is
being called from seat destroy listener, but added just in case.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Weston internals and Wayland clients assume that output presentation
clock cannot go backwards. Therefore require unconditionally that KMS
uses the monotonic clock.
The kernel unconditionally supports DRM_CAP_TIMESTAMP_MONOTONIC. See:
commit 25e1a79874eb3821d93310c908cc0a81b47af060
Author: Arnd Bergmann <arnd@arndb.de>
Date: Wed Oct 11 17:20:13 2017 +0200
drm: vblank: remove drm_timestamp_monotonic parameter
That one removed the final possibility of DRM_CAP_TIMESTAMP_MONOTONIC
being false, by removing the module option. But even before that, all
drivers have been supporting monotonic, since
commit c61eef726a78ae77b6ce223d01ea2130f465fe5c
Author: Imre Deak <imre.deak@intel.com>
Date: Tue Oct 23 18:53:26 2012 +0000
drm: add support for monotonic vblank timestamps
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This drops the software presentation clocks that could jump backwards.
See the previous commit "libweston: assert frame times never go
backwards" for the rationale.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Adding this check was prompted by
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/609
There is no reason to allow frame times jump backwards, and apparently
we already have code that makes that assumption.
DRM KMS uses CLOCK_MONOTONIC as the vblank and page flip timestamps,
which by definition cannot go backwards. Other backends call
weston_compositor_set_presentation_clock_software().
Frame times are also reported directly to Wayland clients via
presentation-time extension, and clients too will not expect that the
timestamp could go backwards.
So make sure time can never go backwards.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
As observed in #420 (Running Weston under Weston's kiosk shell with
multiple outputs causes the scrollback to go nuts), not
being able to cope with (a correct) resize of the parent surface would
cause the client weston instance to spin forever. If dispatching
failed, just exit.
Fixes#420
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
As an in-flight resize call might cause a call to
wayland_output_destroy_shm_buffers() to go over a list of free_buffers
list. Just initialize the lists before attempting to create the parent
surface to avoid it.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
fb->format is *pixel_format_info, whereas fb->format->format is the
actual DRM/wl_shm format code we want to see here. Fix the drm_debug()
call accordingly.
Signed-off-by: Bastian Krause <bst@pengutronix.de>
In "backend-drm: simplify compile time array copy", ARRAY_COPY was
introduced to be used by the DRM-backend.
In this patch we expand its usage to other code where hardcoded arrays
are being copied.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In commit "backend-drm: simplify compile time array copy", the macro
ARRAY_COPY was introduced.
The macro STRING was accidentally introduced in the same commit, and as
it is completely unnecessary, remove it.
Also, memcpy was copying from src to dst, and it should do the opposite.
So fix it.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In drm_fb_get_from_dmabuf() we have some compile time array copies, and
multiple static_assert() calls are needed (for safety). This makes the
code unpleasant to read.
Add ARRAY_COPY macro, to simplify the code.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
EGL implementations have no way to tell that implicit modifiers are not
supported. So Weston must consider that implicit modifiers are
supported. Always add DRM_FORMAT_MOD_INVALID to formats that we query
from EGL.
The implication is that clients using dmabuf extension may pick
DRM_FORMAT_MOD_INVALID to allocate their buffers, and so these buffers
will not be directly imported to KMS and placed in planes. See commit
"backend-drm: do not import dmabuf buffers with no modifiers to KMS" for
more details.
But we should not avoid advertising DRM_FORMAT_MOD_INVALID in the dmabuf
protocol just because we hope that the client don't choose it, it's not
our choice.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In commit "libweston: add struct weston_drm_format" struct
weston_drm_format and its helper functions were added to libweston.
The functions query_dmabuf_formats and query_dmabuf_modifiers are very
specific to GL-renderer and its internals. So instead of exposing them
in libweston, query and store DRM formats and modifiers internally in
GL-renderer. Also, add a vfunction to struct weston_renderer in order
to retrieve the formats.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In commit "backend-drm: do not import dmabuf buffers with no modifiers
to KMS" we've stopped to import dmabuf with no modifiers to KMS.
In this patch we document why we can still import wl_drm buffers with no
modifiers to KMS.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
We can't tell the layout of a buffer that has been allocated with no
modifiers. Although usually drivers use linear layouts to allocate in
these cases, it is not a rule. It can use a tiling layout, for instance,
under the hood.
So it is not safe to import a buffer with no modifiers to KMS, as it
can't tell the buffer layout and this may result in garbage being
displayed. In this patch we start to require explicit modifiers to
import buffers to KMS.
In most cases things just work as expected, but just because both sides
(display and render driver) usually end up using the linear layout when
modifiers are not exposed. It also works on systems where the display
and render devices are tied (desktops with Intel or AMD, for instance),
as there's only one driver and it knows the layout of the buffer (no
need to guess).
But in SoC's where the display and render device are split, things can
go wrong. It is better to lose performance and not break things. To
solve the problem, drivers should be updated to expose modifiers (even
if only DRM_FORMAT_MOD_LINEAR), as the concept of implicit modifiers is
the root of the problem.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In commit "backend-drm: add DRM_FORMAT_MOD_INVALID to modifier sets when
no modifiers are supported" we've changed the code that iterates through
the IN_FORMATS blob property. Now it adds DRM_FORMAT_MOD_INVALID for
formats exposed without modifiers.
But the thing is that there shouldn't be formats in the IN_FORMATS blob
exposed without modifiers, as the blob has been added after the
introduction of the explicit modifiers API in the kernel. For now,
there's nothing in the kernel to ensure this correct behavior. So
instead of adding DRM_FORMAT_MOD_INVALID in this case, ignore these
formats, as userspace can't do much in this case.
In the future this may be fixed by the kernel. Or maybe the following MR
in libdrm, which adds an iterator API for the IN_FORMATS blob:
https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>