Commit Graph

1216 Commits

Author SHA1 Message Date
Simon Ser 2f615468b6 backend: add output state allow-lists
Right now, when a new output state field is added, all backends by
default won't reject it. This means we need to add new checks to
each and every backend when we introduce a new state field.

Instead, introduce a bitmask of supported output state fields in
each backend, and error out if the user has submitted an unknown
field.

Some fields don't need any backend involvment to work. These are
listed in WLR_OUTPUT_STATE_BACKEND_OPTIONAL as a convenience.
2021-06-20 23:17:08 +02:00
Simon Ser 72ee196efa backend/session: use DRM_PRIMARY_MINOR_NAME
Instead of hardcoding the string "card", use DRM_PRIMARY_MINOR_NAME.
Some systems may use another prefix, e.g. OpenBSD uses "drm" instead.
2021-06-17 00:28:04 +02:00
Simon Ser fb933d3204 backend/session: use drmIsKMS
This moves the magic incantation into libdrm and is clearer. See
[1] for details.

While at it, fixup the doc comment and improve logging.

[1]: 523b3658aa
2021-06-17 00:27:12 +02:00
Simon Ser 6c3d080e25 backend/drm: populate cursor plane's current_fb
The set_cursor() hook is a little bit special: it's not really
synchronized to commit() or test(). Once set_cursor() returns true,
the new cursor is part of the current state.

This fixes a state where wlr_drm_connector.cursor_enabled is true
but there is no FB available. This is triggered by set_cursor()
followed by a failed commit(), which resets pending_fb.

We should definitely fix the output interface to make the cursor part
of the pending state, but that's a more involved change.
2021-06-17 00:25:27 +02:00
Simon Ser 3345eaca89 backend/drm: remove test_buffer
Instead, call drm_connector_set_pending_fb.
2021-06-13 10:57:17 +02:00
Simon Ser eca5d2f37f backend/drm: move session check from test_buffer to drm_connector_test
The other caller (drm_connector_commit_state) already checks this.
2021-06-13 10:57:17 +02:00
Simon Ser 758f117442 backend/drm: move drm_connector_set_pending_fb up
This will be used in drm_connector_test shortly.
2021-06-13 10:57:17 +02:00
Simon Ser f55b43ddd6 backend/drm: allocate a CRTC in drm_connector_test
We can't perform a test-only atomic commit if the connector is
missing a CRTC.
2021-06-13 10:57:17 +02:00
Simon Ser cb378600e4 backend/drm: allocate a CRTC in drm_connector_commit_state
drm_connector_set_pending_fb needs a CRTC to import the buffer.
2021-06-13 10:57:17 +02:00
Simon Ser b180d3482f backend/drm: introduce drm_connector_alloc_crtc
This function allocates a CRTC for a connector if necessary.
2021-06-13 10:57:17 +02:00
Simon Ser 63f891e393 backend/drm: allow committing a buffer and a mode together
Set the plane's pending FB before calling drm_connector_set_mode.
2021-06-13 10:57:17 +02:00
Simon Ser e89cf5f047 backend/drm: use atomic test-only commits for modifier fallback
Instead of trying to perform a real modeset in init_renderer,
perform an atomic test-only commit to find out whether disabling
modifiers is necessary because of bandwidth limitations.

This decouples init_renderer from the actual commit, making it
possible to modeset an output with a user-supplied buffer instead
of a black frame.

We loose the ability to make sure the buffers coming from the
swapchain will work fine when using the legacy interface. This
can break i915 when atomic is disabled and modifiers enabled.
But i915 always has atomic (so the user must explicitly disable it
to run into potential bandwidth limitations) and is the only known
problematic driver.
2021-06-13 10:57:17 +02:00
Simon Ser b2f6db3533 render: drop wlr_ prefix from wlr_renderer_bind_buffer
Make it clear this function is a private wlroots API and will stay
that way.
2021-06-09 10:26:09 +02:00
Simon Ser c87c849ec6 backend/x11: use wlr_renderer_begin_with_buffer for cursor 2021-06-09 10:26:09 +02:00
Simon Ser 543f5b35d0 backend/wayland: remove swapchain
Rely on wlr_output's generic swapchain handling.
2021-06-07 15:42:38 +02:00
Simon Ser 5f8092b045 backend/wayland: implement get_dmabuf_primary_formats 2021-06-07 15:42:38 +02:00
Simon Ser a670ee7940 backend/x11: remove swapchain
Rely on wlr_output's generic swapchain handling.

We still need a renderer for cursor readback, sadly.
2021-06-07 15:42:38 +02:00
Simon Ser 68c4f15958 backend/x11: implement get_dmabuf_primary_formats 2021-06-07 15:42:38 +02:00
Simon Ser 44feb832f9 backend/headless: remove swapchain
Rely on wlr_output's generic swapchain support instead of creating our
own. The headless output now simply keeps a reference to the front buffer
and does nothing else.
2021-06-07 15:42:38 +02:00
Simon Ser b86a0c8d8f backend/drm: move cursor fields to wlr_drm_connector
Doesn't make a lot of sense to split the cursor fields between
wlr_drm_plane and wlr_drm_connector. Let's just move everything to
wlr_drm_connector.
2021-06-02 11:08:52 +02:00
Simon Ser 2b0a1aeed5 output: take a wlr_buffer in set_cursor
Instead of passing a wlr_texture to the backend, directly pass a
wlr_buffer. Use get_cursor_size and get_cursor_formats to create
a wlr_buffer that can be used as a cursor.

We don't want to pass a wlr_texture because we want to remove as
many rendering bits from the backend as possible.
2021-06-02 11:08:52 +02:00
Simon Ser 01e0f51fad backend/drm: introduce drm_plane_pick_render_format
This is a new helper function to pick a render format suitable for
a plane.

The next commit will use it to initialize the cursor multi-GPU
surface.
2021-06-02 11:08:52 +02:00
Simon Ser e06ea4e84a backend/drm: remove format arg from drm_plane_init_surface
This was always set to ARGB8888.
2021-06-02 11:08:52 +02:00
Simon Ser 9e9be83a58 backend/drm: implement get_cursor_formats and get_cursor_size 2021-06-02 11:08:52 +02:00
Simon Ser de51df2770 backend/wayland: implement get_cursor_formats 2021-06-02 11:08:52 +02:00
Simon Ser ce3e819b33 backend: stop using renderer to get the buffer type
When picking a format, the backend needs to know whether the
buffers allocated by the allocator will be DMA-BUFs or shared
memory. So far, the backend used the renderer's supported
buffer types to guess this information.

This is pretty fragile: renderers in general don't care about the
SHM cap (they only care about the DATA_PTR one). Additionally,
nothing stops a renderer from supporting both DMA-BUFs and shared
memory, but this would break the backend's guess.

Instead, use wlr_allocator.buffer_caps. This is more reliable since
the buffers created with the allocator are guaranteed to have these
caps.
2021-05-31 15:50:13 -04:00
Simon Ser fd2b1f018e backend/x11: use common renderer and allocator
Instead of managing our own renderer and allocator, let the common
code do it.
2021-05-21 22:13:54 +02:00
Simon Ser c82f37542d backend/headless: use common renderer and allocator
Instead of managing our own renderer and allocator, let the common
code do it.

Because wlr_headless_backend_create_with_renderer needs to re-use
the parent renderer, we have to hand-roll some of the renderer
initialization.
2021-05-21 22:13:54 +02:00
Simon Ser 349553d011 backend/wayland: use common renderer and allocator
Instead of managing our own renderer and allocator, let the common
code do it.
2021-05-21 22:13:54 +02:00
Simon Ser 4dae12890f backend: automatically create allocator
Introduce a new backend_get_allocator function that automatically
creates an allocator for the backend if the backend has a renderer.
2021-05-21 22:13:54 +02:00
Simon Ser bcabe34a2e backend: automatically create renderer
If a backend accepts buffers (as indicated by get_buffer_caps) but
doesn't implement get_renderer, automatically create a renderer.
2021-05-21 22:13:54 +02:00
Simon Ser 7ec5bf6b10 backend: introduce wlr_backend_finish
This new functions cleans up the common backend state. While this
currently only emits the destroy signal, this will also clean up
the renderer and allocator in upcoming patches.
2021-05-21 22:13:54 +02:00
Simon Ser 9ca743f9fd backend/drm: use wlr_texture_from_buffer 2021-05-17 16:22:43 +02:00
Kenny Levinsen 2603a5dee7 backend/drm: Do not require mode commit on enable
If a mode is not provided, use the current mode intead.

Closes: https://github.com/swaywm/wlroots/issues/2904
2021-04-30 21:33:28 +02:00
Simon Ser c85789a3a9 backend/headless: dup DRM FD in wlr_headless_backend_create_with_renderer
We were not dup'ing the DRM FD coming from wlr_renderer_get_drm_fd,
resulting in a double-close on backend destroy.
2021-04-29 19:59:42 +02:00
Simon Ser a1e8a639b3 backend/drm: introduce drm_connector_commit_state
Backend-initiated mode changes can use this function instead of
going through drm_connector_set_mode. drm_connector_set_mode becomes
a mere drm_connector_commit_state helper.
2021-04-29 19:51:57 +02:00
Simon Ser e543e26206 backend/drm: take a wlr_drm_connector instead of a wlr_output
No need to take a generic wlr_output, we already know the output
comes from the DRM backend at that point.
2021-04-29 19:51:57 +02:00
Simon Ser e06c62af77 backend/drm: take output state arg in drm_connector_commit_buffer
This will allow a whole state to be applied at once, instead of
individually applying the buffer and the mode.
2021-04-29 19:51:57 +02:00
Simon Ser 218955ce95 backend/drm: remove mode arg from drm_connector_set_mode
All of the information is in wlr_output_state.
2021-04-29 19:51:57 +02:00
Simon Ser 7aba881c47 backend/drm: remove mode arg from drm_connector_init_renderer
This is now unused.
2021-04-29 19:51:57 +02:00
Simon Ser 31082a0554 backend/drm: remove wlr_drm_crtc_state.mode
Replace it with drm_connector_state_mode, which computes the mode
from the wlr_output_state to be applied.
2021-04-29 19:51:57 +02:00
Simon Ser dfea0ff31d backend/drm: remove wlr_drm_crtc_state.active
Replace it with drm_connector_state_active, which figures out
whether the connector is active depending on the wlr_output_state
to be applied.
2021-04-29 19:51:57 +02:00
Simon Ser 485ecc11a6 backend/drm: remove wlr_drm_crtc.pending_modeset
Replace it with a new drm_connector_state_is_modeset function that
decides whether a modeset is necessary directly from the
wlr_output_state which is going to be applied.
2021-04-29 19:51:57 +02:00
Simon Ser c9c2d7539c backend/drm: fill scratch wlr_output_state for set_mode
Populate the wlr_output_state when setting a mode. This will allow
drm_connector_set_mode to stop relying on ephemeral fields in
wlr_drm_crtc. Also drm_connector_set_mode will be able to apply
both a new buffer and a new mode atomically.
2021-04-29 19:51:57 +02:00
Simon Ser 1a9701cd7c backend/drm: take wlr_output_state as arg in commit callers
Instead of relying on wlr_output.pending to be empty when performing
backend-initiated CRTC commits, use a zero wlr_output_state.
2021-04-29 19:51:57 +02:00
Simon Ser 8f90d7f8f5 backend/drm: take wlr_output_state as arg in crtc_commit
Stop assuming that the state to be applied is in output->pending in
crtc_commit. This will allow us to remove ephemeral fields in
wlr_drm_crtc, which are used scratch fields to stash temporary
per-commit data.
2021-04-29 19:51:57 +02:00
Simon Ser e7f68ba081 backend/drm: fix allocator DRM FD on multi-GPU setups
On multi-GPU setups, there is a primary DRM backend and secondary
DRM backends. wlr_backend_get_drm_fd will always return the parent
DRM FD even on secondary backends, so that users always use the
primary device for rendering.

However, for our internal rendering we want to use the secondary
device. Use allocator_autocreate_with_drm_fd to make sure the
allocator will create buffers on the secondary device.

We do something similar to ensure our internal rendering will
happen on the secondary device with renderer_autocreate_with_drm_fd.

Fixes: cc1b66364c ("backend: use wlr_allocator_autocreate")
2021-04-29 15:58:56 +02:00
Simon Ser 619a975025 render: remove wlr_ prefix from wlr_renderer_autocreate_with_drm_fd
This function is only required because the DRM backend still needs
to perform multi-GPU magic under-the-hood. Remove the wlr_ prefix
to make it clear it's not a candidate for being made public.
2021-04-29 09:46:34 +02:00
Simon Ser 6bf2406dbf backend/drm: reword wlr_renderer failure message
Remove the assumption about EGL.
2021-04-29 09:38:10 +02:00
Simon Ser 1c1ef69326 Log when WLR_BACKENDS/WLR_RENDERER is set
Makes it easier to figure out why a backend/renderer is picked.
2021-04-28 21:06:41 +02:00