Commit Graph

1197 Commits

Author SHA1 Message Date
Simon Ser 1e5460d4c6 backend/x11: check for connection errors 2021-04-14 23:56:56 +02:00
Simon Ser 053ebe7c27 backend/drm: terminate display on drmHandleEvent failure 2021-04-14 23:56:56 +02:00
Simon Ser 846e0838d6 backend/libinput: terminate display on error 2021-04-14 23:56:56 +02:00
Kenny Levinsen 7f09085461 backend/session: Remove session_impl
libseat provides all session functionality, so there is no longer need
for a session backend abstraction. The libseat device ID, seat handle
and event loop handle are moved to the main wlr_session and wlr_device
structs.
2021-04-14 23:25:07 +02:00
Kenny Levinsen 3f87c2caea backend/session: Remove noop backend
This is instead delegated to libseat.
2021-04-14 23:25:07 +02:00
Kenny Levinsen d037c2dddc backend/session: Remove direct backend
This is instead delegated to libseat.
2021-04-14 23:25:07 +02:00
Kenny Levinsen 95b657ba80 backend/session: Make libseat mandatory 2021-04-14 23:25:07 +02:00
Roman Gilg b36af22c94 backend: move get_drm_fd to public interface
The get_drm_fd was made available in an internal header with a53ab146f. Move it
now to the public header so consumers opting in to the unstable interfaces can
make use of it.
2021-04-12 11:43:56 +02:00
Kenny Levinsen d50bbf0bbc backend/session: Remove logind backend
This is instead delegated to libseat.
2021-04-11 10:03:13 +02:00
Stephan Hilb 9f012cac2f drm: check for PRIME support
PRIME support for buffer sharing has become mandatory since the renderer
rewrite. Make sure we check for the appropriate capabilities in backend,
allocator and renderer.

See also #2819.
2021-04-10 10:49:55 +02:00
Simon Ser d5105c42e3 build: disable libseat subproject server and man pages
When libseat is built as a subproject, we're not interested in
building the server or the man pages.
2021-04-09 22:28:46 +02:00
Simon Ser 1eb38e0015 Remove WLR_HAS_XCB_ERRORS
wlroots' dependency on this library doesn't change the features
exposed to compositors. It's purely a wlroots implementation detail.
Thus downstream compositors shouldn't really care about it.

Introduce an "internal_features" dictionary to store the status of
such internal dependencies.
2021-04-09 21:54:38 +02:00
Simon Ser 8ccb4bbb5f backend/drm: stop testing for buffer in drm_connector_commit_buffer
We now do the test in drm_connector_test, called from
drm_connector_commit.
2021-04-06 20:35:15 +02:00
Simon Ser d0bf750916 backend/drm: use atomic test-only commits for direct scan-out
This allows callers to use wlr_output_test to figure out whether a
buffer can be scanned out prior to committing the output.
2021-04-06 20:35:15 +02:00
Simon Ser 7efc2d05b7 backend/drm: downgrade test-only commit failure log level
Let's not clutter the logs with error messages when a test-only
atomic commit fails.
2021-04-06 20:35:15 +02:00
Simon Ser 5088e25eaf backend/drm: don't set NONBLOCK with TEST_ONLY
The kernel ignores NONBLOCK when TEST_ONLY is set. Let's just not
set it, to make it clear it's unused.
2021-04-06 20:35:15 +02:00
Simon Ser e9361e0492 backend/x11: reject DMA-BUFs with flags
We cannot scan-out DMA-BUFs with any flag right now.
2021-04-06 15:03:52 +02:00
Simon Ser 6bfbf35618 backend/drm: reject DMA-BUFs with flags
We cannot scan-out DMA-BUFs with any flag right now.
2021-04-06 15:02:57 +02:00
Simon Ser 1ec97bdf4f backend/drm: improve logs in drm_fb_create
Downgrade errors to DEBUG level, because drm_fb_create is used in
test_buffer, so errors aren't always fatal. Add ERROR logs at call
sites where a failure is fatal, to make it clear something wrong
happened.
2021-04-06 14:57:59 +02:00
Simon Ser 511e42be5e backend/drm: try to import buffer when testing it
If the import to KMS succeeds, we have a better chance to be able to
scan it out.

Importing is also necessary for test-only commits, which we want to
add in the future.
2021-04-06 14:57:59 +02:00
Simon Ser 07a5345aa5 build: add subproject fallback for libseat
This allows libseat to be compiled as a Meson subproject when it's
not installed system-wide. This can ease development and compilation
on distributions where libseat isn't packaged.
2021-04-02 19:13:17 +02:00
Simon Ser 7709a965e5 backend/drm: use format table in test_buffer
Instead of an ad-hoc strip_alpha_channel function, use the
centralized format table to get an opaque substitute.
2021-03-31 17:29:31 +02:00
Simon Ser b89bcffea4 render/egl, backend/wayland: add workaround for split render/display setups
Split render/display setups have two separate devices: one display-only
with a primary node, and one render-only with a render node. However
in these cases the EGL implementation and the Wayland compositor will
advertise the display device instead of the render device [1]. The EGL
implementation will magically open the render device when the display
device is passed in.

So just pass the display device as if it were a render device. Maybe in
the future Mesa will advertise the render device instead and we'll be
able to remove this workaround.

[1]: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4178
2021-03-27 11:23:32 +01:00
Simon Zeni c8b3536b01 backend/drm: use pixel format table in renderer 2021-03-25 10:55:54 +01:00
Simon Ser c740fccc9d Fix buffer blit matrices
There was a missing wlr_matrix_scale call, so we ended up with black
frames.

Closes: https://github.com/swaywm/wlroots/issues/2780
2021-03-16 17:57:51 +01:00
Kenny Levinsen 883d5b6e7c backend/session/libseat: Set loglevel to INFO 2021-03-15 21:29:22 +01:00
Simon Ser 44fa2c4b49 output: fix transform matrix for 90/270 rotations
We need to adjust the second translation depending on the transform
we applied.

Fixes: 9601a2abf0 ("output: improve transform matrix calculation"
Closes: https://github.com/swaywm/wlroots/issues/2774
2021-03-11 22:52:38 +01:00
Simon Zeni 9601a2abf0 output: improve transform matrix calculation
Compute only the transform matrix in the output. The projection matrix
will be calculated inside the gles2 renderer when we start rendering.

The goal is to help the pixman rendering process.
2021-03-10 15:33:36 +01:00
Ilia Mirkin 10dbb00f5f backend/x11: clamp hotspot to texture bounds
When a new texture is set, the hotspot may actually belong to the
previous texture and be out of bounds. Rather than incur X errors for
these, clamp the hotspot to be inside of the texture.

This fixes weston examples updating their cursors (e.g.
weston-eventdemo).
2021-03-09 22:27:07 +01:00
Simon Ser a02da8e6f6 backend/drm: add new writeback and SPI connector types
We already depend on libdrm 2.4.95, which is the first to have the
writeback connector type.
2021-03-05 17:59:26 +01:00
Simon Ser 73137ace84 backend/session: fix KMS device filtering
As explained in [1], user-space should perform a drmModeGetResources
call to figure out whether a device supports KMS.

[1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/127
2021-02-28 21:07:48 +01:00
Simon Ser b54ef3372d render: use DRM formats in wlr_renderer_read_pixels 2021-02-23 16:09:26 +01:00
Simon Ser f3758d1d0a backend: add error messages in attach_render impls 2021-02-18 22:14:19 +01:00
Simon Ser 6f873078d4 build: use dictionnary for features instead of configuration_data
This allows us to easily iterate on all features and only deal with
bools.
2021-02-15 16:32:33 +01:00
Simon Ser 533a36f05a backend/x11: drop x11-xcb dependency
We don't need it anymore now that we've stopped using the EGL Xlib
platform.
2021-02-08 12:29:12 +01:00
Ilia Mirkin ef94e7e847 backend/x11: use native cursors
Fixes #2659
2021-02-05 11:45:54 +01:00
Manuel Stoeckl a290d7a78d Make implementation function lists static const
This requires a change to the type of `struct wlr_tablet` and
`wlr_tablet_init` signature, both of which are part of the unstable API.
2021-02-05 10:04:20 +01:00
Simon Ser 8e27418dd3 backend/wayland: flush remote display
It turns out wl_event_source_check is not enough to guarantee that the
remote wl_display will be flushed after we queue requests. We need to
explicitly flush, just like we do in our X11 code.

References: https://gitlab.freedesktop.org/wayland/wayland/-/issues/187
2021-02-03 15:22:36 +01:00
Simon Ser 7b50f5d324 backend/wayland: remove unnecessary cast 2021-01-29 12:12:47 +01:00
Simon Ser 50b9921642
backend/x11: remove output_set_refresh
The X11 backend uses the Present extension to schedule frames. The
refresh rate is unused.
2021-01-28 18:47:47 +01:00
Simon Ser 73ffab70b0 backend/drm: don't blit in drm_fb_import
Instead blit in drm_plane_lock_surface. This makes drm_fb_import simpler
and better fits its name.
2021-01-24 18:33:56 +01:00
Simon Ser 4af85f4c19 backend/drm: simplify drm_fb_lock_surface
Make it take a plane instead, and rename to drm_plane_lock_surface.
2021-01-24 18:22:03 +01:00
Ilia Mirkin 7bc8dbb991 backend/x11: keep track of exposed rects, add them to damage regions
When we receive an Expose event, that means that we must redraw that
region of the X11 window. Keep track of these regions with pixman
regions, and merge them with the additional output damaged regions.

Fixes #2670
2021-01-21 15:14:54 +01:00
Ilia Mirkin 922b7f415d backend/x11: skip events we don't care about
These are ones I see log messages about in my setup.
2021-01-21 15:14:54 +01:00
Ilia Mirkin bb92fd4c90 backend/x11: add support for scanout mode
This makes full-screen with weston-terminal work.
2021-01-21 12:35:52 +01:00
Ilia Mirkin 62f37ee319 backend/x11: make sure output transform matrix is initialized
The transform matrix was all 0's, which meant that effectively nothing
got rendered other than the clear color.
2021-01-20 14:55:27 +01:00
Simon Ser 702eed5cbd backend/x11: fix region not being actually used
The region variable was shadowed in an if block. As a result, in the
outer block region was always XCB_NONE and was never destroyed (causing
a memory leak on the server).

Reported-by: Ilia Mirkin <imirkin@alum.mit.edu>
2021-01-18 22:31:09 +01:00
Ilia Mirkin 966e653935 backend/x11: set a blank cursor rather than hiding globally
This actually simplifies the logic since we no longer have to wait for
enter/leave events, and also improves the UX when e.g. handling a crash
with gdb attached.

See #2659
2021-01-18 21:07:11 +01:00
Simon Ser 04d89a8bc5
backend/drm: fix modifiers for cursor plane buffers
In 93cd3a79b2 ("backend/drm: stop using GBM flags"), we stopped
using the GBM_BO_USE_LINEAR flag in favor of a modifier list set
to { DRM_FORMAT_MOD_LINEAR }. However, the last argument of
drm_plane_init_surface disables modifiers -- so the buffer will just
get allocated with an implicit modifier, without necessarily being
LINEAR.

To fix this, allow modifiers when allocating the cursor buffers.
wlr_drm_plane.formats should already have the necessary LINEAR
restrictions.

Fixes: 93cd3a79b2 ("backend/drm: stop using GBM flags")
2021-01-17 22:25:18 +01:00
Simon Ser f17b0f975d backend/drm: add wlr_drm_connector_get_id
This allows a compositor to get a KMS connector object ID from a
wlr_output. The compositor can then query more information about
the connector via libdrm.

This gives more freedom to compositors and allows them to read
KMS properties that wlroots doesn't know about. For instance,
they could read the EDID or the suggested_{X,Y} properties and
change their output configuration based on that.
2021-01-17 12:42:32 +01:00
Simon Ser cb6f584496 backend/drm: add support for the subconnector property
The subconnector property indicates the connector sub-type. This is
useful because that usually indicates what kind of connector the user
has plugged in to their monitor, e.g. a DisplayPort-to-DVI cable will
indicate a DVI subconnector. Also some laptops have non-DP connectors
that are internally linked to a DP port on the GPU.

Set the output description accordingly.

See https://drmdb.emersion.fr/properties/3233857728/subconnector
2021-01-17 12:42:25 +01:00
Simon Ser 879cadd34e backend/x11: add xcb_dri3_pixmap_from_buffers check for n_planes
Just in case.
2021-01-17 12:08:40 +01:00
Simon Ser e537382991 backend/x11: add support for DRI3 1.0
Add fallbacks when DRI3 1.2 isn't supported.

Closes: https://github.com/swaywm/wlroots/issues/2586
2021-01-17 12:08:40 +01:00
Simon Ser 284233c34f backend/x11: log DRM node name 2021-01-17 10:28:12 +01:00
Simon Ser 5373187186 backend/x11: log when creating X11 backend 2021-01-17 10:28:12 +01:00
Simon Ser c6c7fccd96
backend/headless: create renderer after wlr_backend_init
We were calling wlr_renderer_autocreate before wlr_backend_init,
which caused a NULL dereference on wlr_backend.impl.
2021-01-17 01:08:40 +01:00
Simon Ser 9e98f497af backend/drm: use local DRM FD for wlr_rend
The new wlr_renderer_autocreate API is great for compositors, however
it causes some issues with DRM multi-GPU support.

A DRM child backend wants the compositor to use the parent GPU, so it
exposes the parent's DRM FD in get_drm_fd. However, in order to be able
to perform multi-GPU buffer copies, the child DRM backend still needs to
create a local renderer.

Use the new private wlr_renderer_autocreate_with_drm_fd function to
avoid creating a renderer for the parent GPU.

Fixes: e128e6c08d ("render: drop egl parameters from wlr_renderer_autocreate")
2021-01-16 22:52:26 +01:00
Simon Ser afdf4dc890 render/gles2: make EGL context current in bind_buffer
Instead of requiring callers to manually make the EGL context current
before binding a buffer and unsetting it after unbinding a buffer, do
it inside wlr_renderer_bind_buffer.

This hides renderer-specific implementation details inside the
wlr_renderer interface. Non-GLES2 renderers may not use EGL.
This removes all EGL dependencies from the backends.

References: https://github.com/swaywm/wlroots/issues/2618
References: https://github.com/swaywm/wlroots/pull/2615#issuecomment-756687006
2021-01-16 09:06:17 +01:00
Simon Zeni 08a4c62aac render: remove egl include from wlr_renderer 2021-01-16 08:57:42 +01:00
Simon Zeni e128e6c08d render: drop egl parameters from wlr_renderer_autocreate 2021-01-16 08:57:42 +01:00
Simon Ser affc59454e backend/headless: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser 6dfc8ce00b backend/x11: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser b7c95d483a backend/drm: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser 400f4e7f27 backend/wayland: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser ad3a455db9 backend/multi: implement get_drm_fd
Just like get_renderer, iterate over all sub-backends until we find one
that implements get_drm_fd.
2021-01-16 08:57:42 +01:00
Simon Ser a53ab146fe backend: add get_drm_fd to interface
This function allows backends to return the DRM FD they are using. This
will allow the allocator and the renderer to use the right device.
2021-01-16 08:57:42 +01:00
Simon Ser a6a0568316
backend: remove unnecessary GLES2 includes 2021-01-14 12:36:49 +01:00
Simon Ser dc61f471da
backend/drm: remove unnecessary wlr_drm_fb.wlr_buf check
We don't need this check, wlr_buf is guaranteed not to be NULL.
2021-01-13 19:01:02 +01:00
Simon Ser 5d054258af
backend/drm: fix segfault in page_flip_handler
Since 5b1b43c68c ("backend/drm: make wlr_drm_plane.{pending,queued,current}_fb
pointers"), current_fb can be NULL if there's no buffer. If current_fb
is not NULL, current_fb->wlr_buf is guaranteed to not be NULL.

Closes: https://github.com/swaywm/wlroots/issues/2634
2021-01-12 11:41:45 +01:00
Simon Ser 3f7e0cf5f0 render/egl: remove surface and buffer age args from make_current
These aren't used anymore.
2021-01-12 11:31:04 +01:00
Simon Ser 098094c5cb backend/wayland: use the EGL GBM platform
Just like other backends, use the EGL GBM platform. This will make it
easier to move the allocator and renderer initialization out of the
backends.
2021-01-10 11:32:00 +01:00
Simon Ser c94728b53a
backend/drm: stop using surface size for BO
Stop using wlr_drm_surface.{width,height} to figure out the size of a
gbm_bo. In the future we'll stop using wlr_drm_plane.surf, so these will
be zero. Instead, rely on gbm_bo_get_{width,height}.
2021-01-10 11:24:44 +01:00
Simon Ser d9bbc416a6 backend/drm: re-use FBs
Instead of importing buffers to GBM and KMS at each frame, cache them
and re-use them while the wlr_buffer is alive.

This is the same as [1] and [2] but for the DRM backend.

[1]: https://github.com/swaywm/wlroots/pull/2538
[2]: https://github.com/swaywm/wlroots/pull/2539
2021-01-10 11:24:35 +01:00
Simon Ser 91cb0fc443 backend/drm: only keep track of local buffer
Stop keeping track of buffers on the parent GPU when multi-GPU is used.

This removes support for export_dmabuf on secondary GPUs, but renderer
v6 will bring this back by managing the swapchains in wlr_output instead
of the backends.
2021-01-10 11:24:35 +01:00
Simon Ser 5bd86b94f9 backend/drm: add wlr_drm_buf.local_wlr_buf 2021-01-10 11:24:35 +01:00
Simon Ser cd64610c66 backend/drm: introduce drm_fb_create 2021-01-10 11:24:35 +01:00
Simon Ser 5b1b43c68c backend/drm: make wlr_drm_plane.{pending,queued,current}_fb pointers
This will be useful once we start re-using wlr_drm_fb.
2021-01-10 11:24:35 +01:00
Simon Zeni 9192c0480a remove unnecessary egl includes 2021-01-07 17:11:22 +01:00
Simon Zeni b899a412e3 backend: remove wlr_egl from all backends 2021-01-07 17:11:22 +01:00
Simon Ser 5773794baf
backend/drm: don't log errno on plane_get_next_fb failure
errno isn't guaranteed to be set after a plane_get_next_fb failure, so
we were printing garbage.
2021-01-07 16:53:20 +01:00
Simon Ser 07d75c99db render: remove EGL config and visual from wlr_renderer_autocreate
This isn't used anymore by any backend.

Some examples still provide an EGL config to wlr_egl_init, so we can't
drop it yet there.
2021-01-06 12:05:51 +01:00
Simon Ser 3721dbfddb
backend/wayland: remove unnecessary flags from event source
wl_event_loop_add_fd only accepts READABLE and WRITABLE. ERROR and
HANGUP are always implicitly enabled.
2021-01-05 19:54:20 +01:00
Kenny Levinsen d3047011d0 backend/wayland: Avoid uninitialized read
keyboard_handle_leave would always process 1 keycode more than was
pending, which meant reading uninitialized memory from the "pressed"
array.

Found by valgrind.
2021-01-05 12:26:00 +01:00
Simon Ser e8d56ca415 backend/session: allow wlr_session_find_gpus to return an error
Sometimes wlr_session_find_gpus will encounter an error. This is
different from finding zero GPUs.

On error, wlr_session_find_gpus already returns -1. However, this is
casted to size_t, so callers uncorrectly assume this is a success.

Instead, make wlr_session_find_gpus return a ssize_t and allow callers
to handle the error accordingly.
2021-01-04 19:46:44 +01:00
Simon Ser 7febdc7334 backend/wayland: re-use cursor wl_buffers
We were importing cursor buffers as wl_buffers over and over again.
Instead, only import these once.
2021-01-04 13:48:28 +01:00
Simon Ser adfb7cd35a backend/drm: stash pending page-flip CRTC
wlr_drm_connector.crtc may be updated by the DRM backend while a
page-flip is pending. In this case, the page-flip handler won't be able
to find the right wlr_drm_connector from the CRTC ID.

Save the CRTC when performing a page-flip to ensure we always find the
right connector when we get the event.
2021-01-03 19:35:02 +01:00
Simon Ser 576ff57db0 backend/drm: ignore hotplug events while inactive
When the session is inactive, we can't change the KMS state. Ignore
hotplug events so that compositors don't try to perform a modeset when
a connector is plugged in. We already re-scan connectors when the
session becomes active.

To test, run a wlroots compositor on VT 1, switch to VT 2, unplug a
connector, re-plug it, switch back to VT 1. Without this patch the
screen is black on VT 1.

References: https://github.com/swaywm/wlroots/issues/2370
2021-01-03 19:34:54 +01:00
Ilia Bozhinov eb30cde777 noop: listen to display destroy and destroy the backend 2020-12-31 20:34:36 +01:00
Simon Ser 4ffd537d2d
backend/x11: print version on extension error 2020-12-31 20:17:31 +01:00
Simon Ser 1491ec42da backend/x11: always open render node
If we get an authenticated primary node from the X11 server, don't use
it because we can't authenticate our Wayland clients with it. Instead,
open a render node.

Closes: https://github.com/swaywm/wlroots/issues/2576
2020-12-30 19:37:19 +01:00
Simon Ser 4b03bdc3ab Remove wlr_create_renderer_func_t
This callback allowed compositors to customize the EGL config used by
the renderer. However with renderer v6 EGL configs aren't used anymore.
Instead, buffers are allocated via GBM and GL FBOs are rendered to. So
customizing the EGL config is a no-op.
2020-12-30 17:09:40 +01:00
Simon Ser bec1e6b149 backend/drm: remove special linear case for cursor plane
We now properly mark the cursor plane's formats as linear-only, and we
now have a version of wlr_drm_format_intersect that handles the case of
linear-only formats and implicit modifiers.

We can remove the special drm_plane_init_surface flag we had for cursor
planes. This also allows us to use a non-linear layout for cursor planes
on drivers that support it.

Tested on amdgpu GFX9.
2020-12-30 11:17:43 +01:00
Simon Ser 92a0fc0435 backend/drm: extract linear format creation into function
Simplifies error handling.
2020-12-30 11:17:43 +01:00
Simon Ser 7ea0e9f277 backend/drm: force LINEAR for cursor plane formats
If the kernel driver doesn't support modifiers, it still expects cursor
FBs to have a LINEAR layout. See [1] for expectations for framebuffers
attached to the cursor plane.

[1]: https://patchwork.freedesktop.org/patch/408512/
2020-12-30 11:17:43 +01:00
Simon Ser caeed70f28 backend/x11: create per-window present event contexts
The Present protocol states:

> An event context is associated with a specific window; using an existing
> event context with a different window generates a Match error.

Instead of a global event context, use a per-window event context to fix
this error:

    [backend/x11/backend.c:608] X11 error: op Present (SelectInput), code Match (no extension), sequence 63, value 4194307

Closes: https://github.com/swaywm/wlroots/issues/2577
2020-12-28 16:57:56 +01:00
Ariadne Conill 23b6f3e3f5 drm: add fallback drmModeAddFB for drivers which do not support drmModeAddFB2
This makes wlroots able to run on some big-endian machines like G4 and
G5 systems with ATI Radeon 7500 AGP graphics.
2020-12-28 14:15:04 +01:00
Simon Ser c012d770f7 backend/x11: implement a real rendering loop
Instead of using a timer, rely on X11 Present events and send a new
frame event when the parent compositor displays a new frame on screen.

The previous attempt at doing this [1] hit issues with EGLSurface, but
we don't use that anymore.

[1]: https://github.com/swaywm/wlroots/pull/1894
2020-12-27 10:10:07 +01:00
Simon Ser c5f239f411
backend/drm: make listener names more idiomatic
Use the "<object>_<event>" notation for listeners, use
"handle_<listener>" for handlers.
2020-12-25 14:45:00 +01:00
Simon Ser b9460ab724
Stop using wlr_texture_get_size
Just use wlr_texture.{width,height} directly.
2020-12-25 12:21:29 +01:00
Simon Ser 17dd4c9e9a
backend/drm: use connector log helpers in atomic backend 2020-12-24 17:55:45 +01:00