Commit graph

10268 commits

Author SHA1 Message Date
Leandro Ribeiro
6d8a15839d shared: add many weston assert that were missing
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>
2025-09-15 19:14:00 -03:00
Leandro Ribeiro
81d68a561e shared: few cosmetic changes to weston assert file
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>
2025-09-15 19:13:50 -03:00
Leandro Ribeiro
a4cefa69a2 shared: rename a few weston assert
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>
2025-09-15 19:13:04 -03:00
Elliot Chen
b268b3827c backend-pipewire: support frame rate configuration
Signed-off-by: Elliot Chen <elliot.chen@nxp.com>
2025-09-15 08:20:52 +00:00
Erico Nunes
1a68480421 backend-drm: use dmabuf renderbuffer for Vulkan
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>
2025-09-12 18:04:57 +01:00
Erico Nunes
aff309fa9f vulkan-renderer: rename output options to surface/surfaceless
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>
2025-09-12 18:04:57 +01:00
Erico Nunes
dfad00e8c4 backend-drm: Refactor drm_fb_get_from_dmabuf_attributes
So that it can be used with other dmabuf objects other than
linux_dmabuf_buffer.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-09-12 18:04:57 +01:00
Marius Vlad
d2cf5a7ba5 frontend: Explicitly add a check for printing warning
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>
2025-09-12 15:06:22 +01:00
Marius Vlad
208157f2e4 weston-test: Handle missing layer fini on shutdown path
BUG: layer_list is not empty after shutdown. Calls to
weston_layer_fini() are missing somwhere

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-09-12 14:46:43 +01:00
Marius Vlad
41bef3caaa weston-test: Fix another mem leak on shutdown path
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>
2025-09-12 14:46:43 +01:00
Marius Vlad
02a6e45ce5 weston-test: Fix mem leak on shutdown path
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>
2025-09-12 14:46:43 +01:00
Marius Vlad
7722b9f443 weston-test: Remove output_destroyed_listener listener on shutdown path
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>
2025-09-12 14:46:43 +01:00
Marius Vlad
5af8340a00 weston-test: Proper release pointer/seat on shutdown path
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>
2025-09-12 14:46:43 +01:00
Derek Foreman
658f66216a drm: Fix crash on hardware without cursor planes
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>
2025-09-10 13:26:12 -05:00
Robert Mader
67de2a1967 tests: drm-smoke: Stop hardcoding output name to Virtual-1
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>
2025-09-09 14:03:26 +02:00
Robert Mader
516e86222f gitlab-ci: Bump Mesa to 25.2.2
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>
2025-09-09 11:14:41 +02:00
Robert Mader
68d036e2b1 gitlab-ci: Collapse Vulkan-Headers installation
Fixes: 7bc103e5a (gitlab-ci: Build Vulkan-Headers for CI)

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-09 11:14:41 +02:00
Erico Nunes
811edc0a8c tests/client-buffer: Update Vulkan format mustpass list for CI
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>
2025-09-08 12:02:11 +01:00
Erico Nunes
f42ccf2140 vulkan-renderer: Add query to populate shm formats
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>
2025-09-08 12:02:11 +01:00
Erico Nunes
9341192f51 vulkan-renderer: Drop dmabuf format print
These are fairly noisy now especially with more formats being added.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-09-08 12:02:11 +01:00
Erico Nunes
6d20e480a0 pixel-formats: Update Vulkan formats
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>
2025-09-08 12:02:11 +01:00
Erico Nunes
fef0de7d72 pixel-formats: Use a single __BYTE_ORDER macro name
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>
2025-09-08 12:02:11 +01:00
Erico Nunes
8c9f395c6c vulkan-renderer: refactor extensions to extension table
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>
2025-09-08 12:02:11 +01:00
Leandro Ribeiro
b717030a10 backend-drm: assert that there's a valid output state before repaint
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>
2025-09-08 08:37:28 +00:00
Derek Foreman
439aea0188 compositor: Track DIRTY_POS properly
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>
2025-09-08 08:14:09 +00:00
Derek Foreman
eac3d78bc6 compositor: Remove view->visible
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>
2025-09-05 15:23:08 -05:00
Derek Foreman
ac71d40dec compositor: Add transforms to scene graph debug dump
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>
2025-09-05 13:34:18 -05:00
Derek Foreman
cfaa19a292 libweston: Move transform string code into libweston
Pull this out of the frontend.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:34:18 -05:00
Derek Foreman
628e860ffa compositor: Dump some paint node info with the scene graph
For now I've just added plane failure reasons, but more could follow.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:34:18 -05:00
Derek Foreman
37c94a12d9 drm: Dump scene graph at end of repaint instead of beginning
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>
2025-09-05 13:34:18 -05:00
Derek Foreman
6e7b4d63c2 compositor/drm: Move failure reason stringification into compositor
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>
2025-09-05 13:34:17 -05:00
Derek Foreman
b4529320ff drm: Better track plane failure reasons
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>
2025-09-05 13:33:22 -05:00
Derek Foreman
38e6a292a2 drm: Replace dead code with an assert in plane transform check paths
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>
2025-09-05 13:33:22 -05:00
Derek Foreman
a2a6030902 drm: Test cursor plane transform when finding plane for view
Explicitly test the cursor transform so we can properly set
the plane failure reason.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 13:33:22 -05:00
Derek Foreman
23b9f92398 surface-state: refactor weston_surface_commit
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
8966ea79fe surface-state: remove more subsurface specific paths
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
f322b41b3d surface-state: Remove weston_subsurface_apply_from_cache
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
ed1edb7b5c compositor: replace surface_state->buffer with a buffer_ref
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
760ca22e8f compositor: Remove unused forward declaration
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
cd58c45daa compositor: Move weston_surface_commit()
Moving this later in the file lets us drop the prototype for
weston_subsurface_commit().

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
f4bad074e6 compositor: Move some surface state functions
Just code motion to get rid of an unnecessary prototype.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
0ea8141195 compositor: Move a bunch of surface state handling stuff to another file
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
72f73f6692 compositor: internally export weston_surface_to_subsurface
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
3b017341b7 compositor: Make weston_surface_commit handle subsurfaces
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
76dc730d3d compositor: Move region_init_infinite to a header
We've got it in two places, let's share the code.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
e79c9ceee5 compositor: Move cache flush into weston_subsurface_set_synchronized
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
b76e6ebd82 compositor: rename surface_commit_from_cache to apply_from_cache
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
98253554c8 compositor: Remove weston_subsurface_synchronized_commit
This is now just a call to weston_subsurface_commit_from_cache, so just
call that directly.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Derek Foreman
93ad388414 compositor: Move parent_apply call into weston_surface_apply
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>
2025-09-05 10:01:42 -05:00
Derek Foreman
fb7b3e2880 compositor: Make subsurface state application order consistent
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>
2025-09-05 10:01:42 -05:00