This adds a ton of weston assert macros that were missing, as well as
tests for all of that.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Rename parameter "compositor" to "comp", allowing us to have one-line
macros that makes the file easier to read. Also moves a few macros
to other parts of the file.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Currently weston-test-assert.h has a better naming style than
weston-assert.h: more concise and standardized.
So let's copy the same style to weston-assert.h
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
The initial drm backend implementation for Vulkan passes display device
allocated gbm bos directly to the renderer. This is a bit awkward since
it requires the renderer to maintain a custom output creation interface
and another code path for importing specifically gbm bos.
Since then, vulkan-renderer received support to use dmabuf renderbuffers
to support e.g. pipewire dmabuf, in an interface which is also common
with gl-renderer.
The dmabuf renderbuffer code path is similar to what the drm backend
implementation intended to do, so we can unify it to a single interface.
This has the advantages of requiring one less custom output creation
interface, as well as the renderer being able to handle the drm backend
through a single shared dmabuf renderbuffer path.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
The fbo naming inherited from gl-renderer is confusing, and now it
is used in many places.
Rename the two options for output creation to surface and surfaceless
to hopefully make them more meaningful.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Fixes a minor issue with 28bdcb46be ("frontend: Log when exiting due to
insufficient active outputs") to only print that we have
no outputs enabled but we're allowed to continue when we actually get to
that scenario.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Fixes the following mem leak:
=================================================================
==191==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7f6b843f6610 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f6b8302f499 in output_created_listener ../tests/weston-test.c:145
#2 0x7f6b83032dcd in wet_module_init ../tests/weston-test.c:857
#3 0x7f6b842b8425 in wet_load_module ../frontend/main.c:989
#4 0x7f6b842b89eb in load_modules ../frontend/main.c:1069
#5 0x7f6b842d2711 in wet_main ../frontend/main.c:4865
#6 0x562862e934d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#7 0x562862e9756b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#8 0x562862e81e1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#9 0x562862e81e9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#10 0x562862e97bb6 in main ../tests/weston-test-runner.c:726
#11 0x7f6b83d33ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Fixes the following memory leak:
=================================================================
==191==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 72 byte(s) in 1 object(s) allocated from:
#0 0x7f18bfa83610 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f18bf890191 in zalloc ../include/libweston/zalloc.h:38
#2 0x7f18bf89184c in weston_log_ctx_add_log_scope ../libweston/weston-log.c:631
#3 0x7f18bf891c2c in weston_compositor_add_log_scope ../libweston/weston-log.c:696
#4 0x7f18be524ef6 in wet_module_init ../tests/weston-test.c:864
#5 0x7f18bf945425 in wet_load_module ../frontend/main.c:989
#6 0x7f18bf9459eb in load_modules ../frontend/main.c:1069
#7 0x7f18bf95f711 in wet_main ../frontend/main.c:4865
#8 0x557b36c114d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#9 0x557b36c1556b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#10 0x557b36bffe1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#11 0x557b36bffe9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#12 0x557b36c15bb6 in main ../tests/weston-test-runner.c:726
#13 0x7f18bf3c0ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7f18bfa83610 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f18be521499 in output_created_listener ../tests/weston-test.c:145
#2 0x7f18be524dcd in wet_module_init ../tests/weston-test.c:857
#3 0x7f18bf945425 in wet_load_module ../frontend/main.c:989
#4 0x7f18bf9459eb in load_modules ../frontend/main.c:1069
#5 0x7f18bf95f711 in wet_main ../frontend/main.c:4865
#6 0x557b36c114d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#7 0x557b36c1556b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#8 0x557b36bffe1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#9 0x557b36bffe9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#10 0x557b36c15bb6 in main ../tests/weston-test-runner.c:726
#11 0x7f18bf3c0ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x7f18bfa7dd60 in strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:578
#1 0x7f18bf8918ed in weston_log_ctx_add_log_scope ../libweston/weston-log.c:639
#2 0x7f18bf891c2c in weston_compositor_add_log_scope ../libweston/weston-log.c:696
#3 0x7f18be524ef6 in wet_module_init ../tests/weston-test.c:864
#4 0x7f18bf945425 in wet_load_module ../frontend/main.c:989
#5 0x7f18bf9459eb in load_modules ../frontend/main.c:1069
#6 0x7f18bf95f711 in wet_main ../frontend/main.c:4865
#7 0x557b36c114d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#8 0x557b36c1556b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#9 0x557b36bffe1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#10 0x557b36bffe9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#11 0x557b36c15bb6 in main ../tests/weston-test-runner.c:726
#12 0x7f18bf3c0ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Fixes the following UAF:
==191==ERROR: AddressSanitizer: heap-use-after-free on address 0x518000000360 at pc 0x7f1ee142f5df bp 0x7ffe60aaf010 sp 0x7ffe60aaf008
READ of size 8 at 0x518000000360 thread T0
#0 0x7f1ee142f5de in output_destroyed_listener ../tests/weston-test.c:166
#1 0x7f1ee25f08eb in wl_signal_emit_mutable ../src/wayland-server.c:2401
#2 0x7f1ee274c7f8 in weston_compositor_remove_output ../libweston/compositor.c:7877
#3 0x7f1ee274fa92 in weston_output_release ../libweston/compositor.c:8641
#4 0x7f1ee146e5f8 in drm_output_destroy ../libweston/backend-drm/drm.c:2626
#5 0x7f1ee27552df in weston_compositor_shutdown ../libweston/compositor.c:9941
#6 0x7f1ee2756a89 in weston_compositor_destroy ../libweston/compositor.c:10369
#7 0x7f1ee286bed8 in wet_main ../frontend/main.c:4934
#8 0x56113c4244d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#9 0x56113c42856b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#10 0x56113c412e1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#11 0x56113c412e9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#12 0x56113c428bb6 in main ../tests/weston-test-runner.c:726
#13 0x7f1ee22ccca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x7f1ee22ccd64 in __libc_start_main_impl ../csu/libc-start.c:360
#15 0x56113c412860 in _start (/home/mvlad/vkms/weston/b/tests/test-drm-writeback-screenshot+0xe860) (BuildId: 9f9e2ed12b9317dd859498374500f2406c32e5d3)
0x518000000360 is located 736 bytes inside of 792-byte region [0x518000000080,0x518000000398)
freed by thread T0 here:
#0 0x7f1ee298e8f8 in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
#1 0x7f1ee1433002 in wet_module_init ../tests/weston-test.c:882
#2 0x7f1ee2851425 in wet_load_module ../frontend/main.c:989
#3 0x7f1ee28519eb in load_modules ../frontend/main.c:1069
#4 0x7f1ee286b711 in wet_main ../frontend/main.c:4865
#5 0x56113c4244d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#6 0x56113c42856b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#7 0x56113c412e1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#8 0x56113c412e9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#9 0x56113c428bb6 in main ../tests/weston-test-runner.c:726
#10 0x7f1ee22ccca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
previously allocated by thread T0 here:
#0 0x7f1ee298f610 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f1ee142edc5 in zalloc ../include/libweston/zalloc.h:38
#2 0x7f1ee1432cba in wet_module_init ../tests/weston-test.c:840
#3 0x7f1ee2851425 in wet_load_module ../frontend/main.c:989
#4 0x7f1ee28519eb in load_modules ../frontend/main.c:1069
#5 0x7f1ee286b711 in wet_main ../frontend/main.c:4865
#6 0x56113c4244d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#7 0x56113c42856b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#8 0x56113c412e1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#9 0x56113c412e9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#10 0x56113c428bb6 in main ../tests/weston-test-runner.c:726
#11 0x7f1ee22ccca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
For fixing the following UAF.
==191==ERROR: AddressSanitizer: heap-use-after-free on address 0x518000000168 at pc 0x7f7aac77493e bp 0x7ffdd9dddc00 sp 0x7ffdd9dddbf8
READ of size 8 at 0x518000000168 thread T0
#0 0x7f7aac77493d in udev_input_destroy ../libweston/libinput-seat.c:388
#1 0x7f7aac73e632 in drm_shutdown ../libweston/backend-drm/drm.c:3623
#2 0x7f7aad9208b8 in weston_compositor_shutdown_backends ../libweston/compositor.c:10337
#3 0x7f7aad920a7d in weston_compositor_destroy ../libweston/compositor.c:10367
#4 0x7f7aada35ed8 in wet_main ../frontend/main.c:4934
#5 0x561e808014d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#6 0x561e8080556b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#7 0x561e807efe1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#8 0x561e807efe9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#9 0x561e80805bb6 in main ../tests/weston-test-runner.c:726
#10 0x7f7aad496ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x7f7aad496d64 in __libc_start_main_impl ../csu/libc-start.c:360
#12 0x561e807ef860 in _start (/home/mvlad/vkms/weston/b/tests/test-drm-writeback-screenshot+0xe860) (BuildId: 9f9e2ed12b9317dd859498374500f2406c32e5d3)
0x518000000168 is located 232 bytes inside of 792-byte region [0x518000000080,0x518000000398)
freed by thread T0 here:
#0 0x7f7aadb588f8 in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:52
#1 0x7f7aac3f2f9d in wet_module_init ../tests/weston-test.c:878
#2 0x7f7aada1b425 in wet_load_module ../frontend/main.c:989
#3 0x7f7aada1b9eb in load_modules ../frontend/main.c:1069
#4 0x7f7aada35711 in wet_main ../frontend/main.c:4865
#5 0x561e808014d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#6 0x561e8080556b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#7 0x561e807efe1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#8 0x561e807efe9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#9 0x561e80805bb6 in main ../tests/weston-test-runner.c:726
#10 0x7f7aad496ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
previously allocated by thread T0 here:
#0 0x7f7aadb59610 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f7aac3eedc5 in zalloc ../include/libweston/zalloc.h:38
#2 0x7f7aac3f2c55 in wet_module_init ../tests/weston-test.c:836
#3 0x7f7aada1b425 in wet_load_module ../frontend/main.c:989
#4 0x7f7aada1b9eb in load_modules ../frontend/main.c:1069
#5 0x7f7aada35711 in wet_main ../frontend/main.c:4865
#6 0x561e808014d6 in execute_compositor ../tests/weston-test-fixture-compositor.c:431
#7 0x561e8080556b in weston_test_harness_execute_as_client ../tests/weston-test-runner.c:570
#8 0x561e807efe1d in fixture_setup ../tests/drm-writeback-screenshot-test.c:48
#9 0x561e807efe9e in fixture_setup_run_ ../tests/drm-writeback-screenshot-test.c:50
#10 0x561e80805bb6 in main ../tests/weston-test-runner.c:726
#11 0x7f7aad496ca7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
This would be caused by not being able to compile keymaps.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
In a2a6030902 I introduced a crash when no
cursor plane exists. Fix this by pulling the cursor plane tests into their
own function and doing an early return when we have a conclusive no-cursor
failure state.
Fixes a2a6030902
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
On certain setups - notably virtual machines - the output name can
be already taken (by e.g. virtio).
Given that we only use a single output for the test, do what other
tests do and don't assume any name.
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Notably including
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35915
which is needed for some upcoming MRs.
Returning to a proper release also makes it easier to understand
what we are testing against.
Mesa 25.2 requires Meson >= 1.4 and libX11 >= 1.8. The later requires
autoconf >= 2.70.
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Now that new formats are supported by the Vulkan renderer, update
this list to match our driver in CI for a more reasonable coverage.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Remove the limited shm formats hardcoded list and add a query to
populate them according to the device.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Update list of Vulkan equivalent of the DRM formats.
Fix some format information to account for endianness according
to the "DRM pixel format guide".
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
This file used both __BYTE_ORDER and __BYTE_ORDER__ which could become
confusing to inspect.
Both appear to be valid, since it is being compared to __LITTLE_ENDIAN
stick to __BYTE_ORDER for all uses.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Define extension tables for all extensions that are potentially used,
and use that to enumerate and request extensions which will be used.
This allows for a bitset to hold supported extensions and makes it
less cumbersome to define new ones to use later, as well as requiring
less traversing of the extension string list to decide which extensions
to request.
This also fixes some missing dependency issues which could trigger
validation errors on some drivers with limited extension support.
It also allows some code paths that didn't require some specific
extensions that were in the default list before, by checking for
those in the code path that actually uses them at runtime.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Follow-up of "compositor: let backends handle output->disable_planes".
Now we always call assign_planes() before a repaint, so we must have
a valid output state when we enter assign_planes().
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
For clients using old protocol versions, the WESTON_SURFACE_DIRTY_POS bit
currently gets set on any attachment. It should really only be set if
the attachment is non-zero.
Since it's possible to attach mulitple times, or to invoke
wl_surface.offset multiple times, let's allow clearing the bit so it
stays up to date with the state that will actually be used on commmit().
Currently, this is pointlessly pedantic, as we don't really do much with
the bit, but in a future commit I intend to use it to notice states that
may change visibility/occlusion status of a surface.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This is not what any sensible person would expect it to be. It was updated
by a walk of all the paint nodes on the output most recently repainted,
so if a view spanned outputs the visible region would only make sense
within the most recently painted output's region.
It's basically a scratchpad for a mid-repaint operation. Instead of making
it a view member, put it in the paint node, which are always per-output.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Add transform information to scene graph debug dumps, which can be
helpful in determining why application surfaces aren't ending up on
hardware planes.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
At the end we'll have the plane failure reasons in their final state for
the frame we're submitting (instead of a stale state from the previous)
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
While this is generally drm specific stuff, it's leaked into paint nodes
a little bit already.
Pushing it into the core gives us the ability to print failure reasons
in the scene graph debug text (in a future commit), which can be very
informative.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We have a big bitfield of failure reasons for when we can't place a paint
node on a plane - but between the introduction of this bitfield and now
we added many new reasons, so it's an expecation that the reason
FAILURE_REASON_FORCE_RENDERER only means that the compositor is configured
to force the use of the renderer via the WESTON_FORCE_RENDERER environment
variable, or debug key bind, or similar.
Some of the code retained the older generic use of FORCE_RENDERER to mean
any number of things.
Add some new reasons and use other existing reasons to disambiguate the
FORCE_RENDERER reason.
Since we already print the (somewhat misleading) failure reason strings
late in the repaint pass, we can drop the (currently accurate) debug
prints we fired off along the way, and just print them accurately at the
end.
We also move the failure reason reset point to the start of repaint,
as it is convenient to have it be valid after plane assignment so
we can print it in scene graph debug text in a later commit.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
The caller to drm_plane_state_coords_for_paint_node() has already tested
for valid transforms, so drm_plane_state_coords_for_paint_node() is never
called with a transform that needs to be tested.
Replace the test with an assert() - and this also lets us stop returning
a bool, and drop the debug prints that could never trigger.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Move some code around so we only have a single call to
weston_surface_apply(). This will simplify having deferred state updates
later.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
weston_subsurface_commit_to_cache and weston_subsurface_commit are
trivial functions with single call sites. Eliminate them.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Now that we don't have a buffer_ref to manage outside the surface_state
struct, this function is a trivial wrapper.
Just inline it where it's used.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Use a buffer_ref here to allow us to remove the subsurface
cached_buffer_ref and keep it in the surface state struct instead.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We don't need to define weston_compositor_build_view_list here, as it's
already defined before it's used.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
compositor.c is too big, let's try to peel off a bit of surface state
handling code into another file.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
I'll want to use this in another file soon, but for now let's just
clean up the extra prototypes.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Push the subsurface vs surface logic into weston_surface_commit so there's
just one function to call from surface_commit to handle both.
This is mostly preparation for splitting off a bunch of surface handling
functions into their own file later.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Do a subsurface cache flush in weston_subsurface_set_effectively_synchronized
instead of in the protocol handler.
This is just so when I move some functions into another file later, I don't
need to expose weston_subsurface_apply_from_cache().
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Finish up renaming functions so that committing state and applying state
have their own function names. This will be useful soon when we have a
mechanism to commit state into a queue and apply it later.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
To streamline state handling, push the weston_subsurface_parent_apply
calls and list walks into weston_surface_apply().
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We have several places where we apply surface state, then walk the
subsurface list.
In surface_commit() however, we walk the list first then apply state.
Re-order surface_commit() so it's the same as the other sites.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>