Commit Graph

1215 Commits

Author SHA1 Message Date
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
Simon Ser a7a230ebef
backend/drm: make drmModePlane arg in add_plane const
Make it clearer it'll be free'd after add_plane returns.
2020-12-24 12:34:13 +01:00
Simon Ser c011a0e2ed
backend/drm: add special case for cursor in add_plane
The code calling add_plane now makes sure not to add a cursor plane to a
CRTC which already has one.
2020-12-24 12:31:20 +01:00
Simon Ser 5548406667
backend/drm: log whether ADDFB2 modifiers are supported 2020-12-24 12:29:30 +01:00
Simon Ser 64a2ca4dba
backend/drm: don't retry page-flip when modifiers are unsupported
Parse WLR_DRM_NO_MODIFIERS at startup. Don't parse IN_FORMATS when
WLR_DRM_NO_MODIFIERS is set, so that the legacy behaviour is better
reproduced.

When modifiers aren't supported, try the initial page-flip once only.
2020-12-23 19:49:27 +01:00
Simon Ser 54ec17ff64
backend/drm: use plural form for possible_crtcs
Make it clearer that this is a bitmask of CRTC indices.
2020-12-23 12:14:36 +01:00
Simon Ser 2de400a541
backend/drm: assert connector state after wlr_output_destroy 2020-12-22 19:53:33 +01:00
Simon Ser 85cf4b235d
backend/drm: destroy DRM connectors that disappear
This was lost during the refactoring. We were previously calling
wlr_output_destroy, which destroyed the connector as well.

Fixes: 248c7787c7 ("backend/drm: refactor wlr_output destruction")
2020-12-22 19:38:29 +01:00
Simon Ser ad4dae0844 backend/drm: error on size mismatch in drm_surface_blit 2020-12-22 15:53:10 +01:00
Simon Ser d3bcd63a40 backend/drm: remove drm_fb_acquire
Instead, import the buffer into GBM and KMS in drm_fb_import. Also move
the multi-GPU copy there if necessary.
2020-12-22 15:53:10 +01:00
Simon Ser 5ee8b12dc3 backend/drm: make drm_fb_acquire return a FB ID 2020-12-22 15:53:10 +01:00
Simon Ser d09abe86c1 backend/drm: drop export_drm_bo
Not used anymore.
2020-12-22 15:53:10 +01:00
Simon Ser dabd2e7207 backend/drm: grab DMA-BUF from wlr_buffer instead of gbm_bo
Get the DMA-BUF directly out of the wlr_buffer instead of relying on the
gbm_bo. This eliminates a roundtrip through GBM.
2020-12-22 15:53:10 +01:00
Simon Ser 83925f04c3 backend/drm: don't save texture in gbm_bo user data
The GBM BO is destroyed when released anyways.
2020-12-22 15:53:10 +01:00
Simon Ser 55b02f753f backend/x11: destroy buffers when destroying output 2020-12-21 16:31:07 +01:00
Simon Ser d6dbdd97e9 backend/x11: re-use pixmaps
Instead of re-importing a buffer each time we submit a frame, re-use the
pixmaps if possible.
2020-12-21 16:31:07 +01:00
Simon Ser defcd9b025 backend/wayland: re-use wl_buffers
Instead of re-importing a buffer each time we submit a new frame, re-use
the wl_buffer objects if possible.
2020-12-21 16:30:47 +01:00
Simon Ser de896caceb backend/wayland: remove EGL config
We don't use EGLSurface anymore, so we don't need to choose an EGL
config anymore.
2020-12-19 21:11:01 +01:00
Ronan Pigott 917ecca58e backend/drm: avoid gcc stringop-truncation warning 2020-12-18 22:19:16 +01:00
Simon Ser 352fdd1bb0
backend/drm: remove unused wlr_drm_plane.drm_format 2020-12-18 11:44:50 +01:00
Simon Ser 248c7787c7 backend/drm: refactor wlr_output destruction
Instead of hand-rolling our own manual wlr_output cleanup function, rely
on wlr_output_destroy to remove an output from the compositor's state.
2020-12-18 10:48:44 +01:00
Simon Ser 019ffe8a5b backend/drm: introduce wlr_drm_connector.name
The DRM backend is a little special when it comes to wlr_outputs: the
wlr_drm_connectors are long-lived and are created even when no screen is
connected.

A wlr_drm_connector only advertises a wlr_output to the compositor when
a screen is connected. As such, most of wlr_output's state is invalid
when the connector is disconnected.

We want to stop using wlr_output state on disconnected connectors.
Introduce wlr_drm_connector.name which is always valid regardless of the
connector status to avoid reading wlr_output.name when disconnected.
2020-12-18 10:48:44 +01:00
Simon Ser c89b131f29 backend/drm: introduce wlr_drm_conn_log
Simplify and unify connector-specific logging with a new
wlr_drm_conn_log macro. This makes it easier to understand which
connector a failure is about, without having to explicitly integrate the
connector name in each log message.
2020-12-18 10:48:44 +01:00
Simon Ser 0aefa18690 backend/x11: send more precise output present events
Instead of sending dummy output present events, use the X11 Present
extension to send more precise events.
2020-12-18 10:37:08 +01:00
Simon Ser 94fda895ac backend/x11: use DRI3Open to get DRM FD
Instead of relying on EGL to retrieve the DRM FD, query it from the
DRI3 extension.

Use the EGL GBM platform, and drop the EGL config.
2020-12-18 10:12:55 +01:00
Simon Ser 1e2c7fce86 backend/drm: use wlr_drm_format_{create,add}
Instead of manually allocating and initializing the structs, use the new
wlr_drm_format helpers.
2020-12-18 09:41:12 +01:00
Simon Ser 253f447329
backend/drm: print DRM device name when scanning connectors 2020-12-17 20:50:19 +01:00
Simon Ser 9cd3f03f65
backend/drm: add wlr_drm_backend.name
Save the DRM device name in a wlr_drm_backend field, so that we can
easily use it for logging purposes.
2020-12-17 20:48:47 +01:00
Simon Ser 60001a75a2
backend/drm: remove nouveau workaround
The workaround is broken because drm_fb_acquire doesn't leave the EGL
context current anymore. We'll need to re-introduce it.

References: https://github.com/swaywm/wlroots/issues/2525
2020-12-17 20:38:02 +01:00
Simon Ser 0dcdb5e7a1 backend/x11: fix DRI3 formats not used
We queried DRI3 formats, but we weren't using them. Because of a typo,
only render formats were used.

Fixes: c59aacf944 ("backend/x11: query modifiers supported by X11 server")
Closes: https://github.com/swaywm/wlroots/issues/2552
2020-12-17 17:02:09 +01:00
Simon Ser 0aa2ba0c03 backend/headless: select the rendering device ourselves
Backends will eventually stop creating their renderer. To prepare for
this, stop using EGL_PLATFORM_SURFACELESS_MESA in the headless renderer.
Pick a render node using libdrm.

The new allocator/renderer creation logic looks very much like what will
end up in common code.
2020-12-16 12:12:36 +01:00
Simon Ser da2a216934
backend/drm: add wlr_drm_connector.backend
This allows the DRM code to have direct access to the wlr_drm_backend
without having to go through an upcast via get_drm_backend_from_backend.
2020-12-15 22:56:14 +01:00
Simon Ser 87bd718de5
backend: use fcntl(F_DUPFD_CLOEXEC) instead of dup
This makes sure the CLOEXEC flag is set on the dup'ed FD.
2020-12-15 20:52:53 +01:00
Simon Ser 1ca4d6b029
backend/drm: dup FD before wlr_gbm_allocator_create
The GBM allocator takes ownership of the DRM FD.
2020-12-15 20:50:04 +01:00
Simon Ser e57a52e7f7
Remove inline keyword
The compiler is smarter at figuring out whether a function should be
inlined or not.
2020-12-15 13:49:42 +01:00
Simon Ser 93cd3a79b2 backend/drm: stop using GBM flags
gbm_bo_create_with_modifiers doesn't take GBM flags, so our
wlr_gbm_allocator interface doesn't either. We were still internally
using GBM flags in the DRM backend, leading to awkward back-and-forth
conversions.

The only flag passed to drm_plane_init_surface was GBM_BO_USE_LINEAR, so
turn that into a bool to make sure other flags can't be passed in.

Move the "force linear" logic out of init_drm_surface, because the
supplied wlr_drm_format should already contain that information.
2020-12-13 13:20:39 +01:00
Simon Ser 525fa6ada0
backend/x11: fix xinput mask mixed up with present
Don't mix xinput and present flags.

Fixes: d79a00bf02 ("backend/x11: switch to wlr_swapchain")
2020-12-13 12:21:21 +01:00
Simon Ser c59aacf944 backend/x11: query modifiers supported by X11 server 2020-12-13 12:16:52 +01:00
Simon Ser d79a00bf02 backend/x11: switch to wlr_swapchain 2020-12-13 12:16:52 +01:00
Simon Ser 16a51bbab2 backend/wayland: query render formats 2020-12-13 12:16:28 +01:00
Simon Ser 441bac139f backend/wayland: use wlr_swapchain for cursor surface 2020-12-13 12:16:28 +01:00
Simon Ser 3923ff005d backend/wayland: use wlr_swapchain for main surface
The cursor surface still uses a wl_egl_window.

References: https://github.com/swaywm/wlroots/issues/1352
2020-12-13 12:16:28 +01:00
Simon Ser 038285d496 backend/wayland: stop rendering black frame on init
Instead of rendering a black frame, schedule a frame event to ask the
compositor to render a proper frame.
2020-12-13 12:16:28 +01:00
Simon Ser 768131e488 output: stop assuming a frame is pending in init
- The DRM backend initially doesn't have a frame scheduled initially.
  However the compositor is expected to set a mode to start the
  rendering loop (frame_pending is set to true in drm_crtc_pageflip).
- The headless and X11 backends have a timer to schedule frames, so they
  ignore this hint completely.
- The Wayland backend renders a fake frame to start the rendering loop.
  It's the only case where a frame is pending on init, move the
  assumption there.
2020-12-13 12:16:28 +01:00
Simon Ser 4c363a564f backend/drm: remove workaround for amdgpu DP MST
Closes: https://github.com/swaywm/wlroots/issues/2533
2020-12-11 23:27:13 +01:00
Simon Ser 6ff478632a backend/drm: remove EGL config
Since we're using wlr_swapchain, we don't need to provide an EGL config.
2020-12-09 14:25:41 +01:00
Simon Ser 06ab41a160
backend/drm: fix missing wlr_drm_format.cap
This caused issues with wlr_drm_format_dup.
2020-12-08 23:32:04 +01:00
Simon Ser eb5886ddbe backend/headless: add support for direct scan-out
I was about to add a check to fail instead of crash when the compositor
uses direct scan-out, but with renderer v6 it's so simple to just add
support for direct scan-out, why bother?

Closes: https://github.com/swaywm/wlroots/issues/2523
2020-12-08 18:57:11 +01:00
Stephane Chauveau b790e5ea34 backend/drm: don't assume possible_crtcs has only one bit set
This isn't necessarily the case [1].

This should fix an assertion failure on Raspberry Pi 4 dual screen.

[1]: https://lists.freedesktop.org/archives/dri-devel/2020-August/275142.html

Closes: https://github.com/swaywm/wlroots/issues/1943
Co-authored-by: Simon Ser <contact@emersion.fr>
2020-12-08 18:38:42 +01:00
Simon Ser 863acb26c0 backend/drm: stop tracking overlay planes
We don't do anything with them. Once we do, we can easily add this back.
2020-12-08 18:38:42 +01:00
Simon Ser e69bbfd0d6 backend/drm: unset current surface before importing
drm_fb_import_wlr may need to change the current EGL context. For
instance by calling drm_fb_clear, which calls wlr_buffer_unlock, which
may destroy a buffer if the cursor swapchain size has changed, which
calls gles2's destroy_buffer, which calls glDeleteFramebuffers.

Closes: https://github.com/swaywm/wlroots/issues/2479
2020-12-08 00:10:57 +01:00
Simon Ser 325cba6414
backend/drm: use EGL_PLATFORM_GBM_KHR
This is just the vendor-agnostic define for the GBM platform. It has the
same value as EGL_PLATFORM_GBM_MESA, so should work with old drivers
that only offer the Mesa-vendored extension too.
2020-12-07 12:06:38 +01:00
Simon Ser bfb59fd4d7 backend/headless: create a config-less EGL context 2020-12-07 11:40:45 +01:00
Ilia Bozhinov 54b7ca56c0 drm: do not unset make/model before emitting destroy event 2020-12-07 10:39:29 +01:00
Simon Ser 90c8452959 backend/session/libseat: set XDG_SESSION_TYPE
libseat will call logind's SetType method if necessary.
2020-12-05 00:14:04 +01:00
Simon Ser 1336ad2a23
backend/drm: remove unused if in drm_connector_move_cursor
We return early if we don't have a plane.
2020-12-04 19:34:35 +01:00
Simon Ser 0e927533b0 backend/drm: query render formats
On some platforms it's possible that the display engine supports
modifiers not supported by the render engine.

Query render formats and intersect them with plane formats to accommodate
for this.
2020-12-03 10:52:25 +01:00
Simon Ser 237c2cf2fb backend/drm: take a wlr_drm_format in init_drm_surface
Instead of taking a format code and wlr_drm_format_set, simplify the
function signature and take a single wlr_drm_format.
2020-12-03 10:52:25 +01:00
Simon Ser 8bc5a92a98 Revert "backend/drm: stop force-probing connectors"
This reverts commit 713c1661b7.

It turns out we do need to force-probe on startup and on hotplug [1].
This is unfortunate, but that's just how the uAPI works. Fixing this
would require patching the kernel.

[1]: https://lists.freedesktop.org/archives/dri-devel/2020-November/289506.html

Closes: https://github.com/swaywm/wlroots/issues/2499
2020-12-01 11:31:03 +01:00
Simon Ser de9ff46629
backend/drm: "scaling mode" is a connector property
It's not a CRTC property. Remove it altogether since it's unused.
2020-11-30 11:57:08 +01:00
Simon Ser 2649600fa1
backend/drm: rotation is a plane property
"rotation" is a plane property, it's not a CRTC property. It was also
missing from plane_info.
2020-11-30 11:57:08 +01:00
Simon Ser c045253927 backend/headless: use a format suitable for rendering
When allocating buffers, use a format suitable for rendering. This
avoids picking a format that won't work.
2020-11-30 11:08:44 +01:00
Simon Ser 6485fadc16
backend/wayland: don't set EGL visual
The Wayland platform doesn't have visuals. By chance,
WL_SHM_FORMAT_ARGB8888 is zero, which means egl_get_config was ignoring
it and everything worked fine.
2020-11-25 13:52:05 +01:00
Simon Ser 713c1661b7 backend/drm: stop force-probing connectors
After discussing with Pekka and Daniel on #dri-devel, we concluded [1]
that user-space shouldn't need to force-probe connectors. Force-probing
can take some time, so using drmModeGetConnectorCurrent can result in
faster start-up.

Users can manually trigger a force-probe if necessary:

    echo detect | sudo tee /sys/class/drm/card0-DP-1/status

Or just by running a tool like drm_info.

A similar change has been submitted to Weston [2].

[1]: https://lists.freedesktop.org/archives/dri-devel/2020-November/287728.html
[2]: https://gitlab.freedesktop.org/wayland/weston/-/issues/437
2020-11-24 15:00:46 +01:00
Simon Ser 154fe8696f backend/x11: log unhandled client messages 2020-11-24 14:57:25 +01:00
Simon Ser f6c36f8881 backend/x11: log unhandled X11 events 2020-11-24 14:57:25 +01:00
Simon Ser 52805feae9 backend/x11: log errors
Register an X11 error handler, and optionally use xcb-errors to print a
detailed message.
2020-11-24 14:57:25 +01:00
Isaac Freund 262740bc9a backend/libseat: fix change_vt return value
This should return true on success and false on failure not vice-versa.
2020-11-24 13:09:13 +01:00
Simon Ser 754179dacd backend/session: add a timeout waiting for GPUs
If a GPU doesn't show up in 10s, bail out and return zero GPUs.
2020-11-19 22:47:49 +01:00
Simon Ser c491a21d25 backend/session/logind: log when using XDG_SESSION_ID
This makes it easier to figure out how wlroots selected the session.
2020-11-19 22:47:49 +01:00
Simon Ser 0e76f92de7 backend/session: replace session_signal with events.active
This is more idiomatic wlroots API. The new name makes it clear that the
signal is emitted when wlr_session.active changes.
2020-11-19 22:47:49 +01:00
Simon Ser cd95d70df0 Revert "session/logind: support CanGraphical property"
We now use udev to wait for DRM card devices.

This reverts commit 3ebf079a9a.
2020-11-19 22:47:49 +01:00
Simon Ser fbf11a41e1 backend/session: wait for DRM device if none found
Wait for a DRM device if none is found in wlr_session_find_gpus. This
can happen if the compositor is loaded before the display kernel driver.

This supersedes the logind CanGraphical property.

To test, e.g. with i915 and sway:

    rmmod -f i915
    sway &
    modprobe i915

Closes: https://github.com/swaywm/wlroots/issues/2093
2020-11-19 22:47:49 +01:00
Simon Ser 76bcddf071 backend/session: introduce wlr_session.events.add_drm_card
This is triggered when a new DRM card is added.

An easy way to test this patch is `modprobe vkms`.
2020-11-19 22:47:49 +01:00
Simon Ser 768fbaad54 backend/session: filter udev events by sysname
We're only interested in card devices. The loop over wlr_session.devices
would take care of ignoring non-card events, but a future patch will
listen to udev "add" events as well.
2020-11-19 22:47:49 +01:00
Simon Ser 44a4792fd8 backend/session: operate on wlr_device
Instead of operating on FDs in {open,close}_device, operate on
wlr_devices. This avoids the device lookup in wlr_session and allows
callers to have access to wlr_device fields.

For now, we use it to remove wlr_session_signal_add and replace it with
a more idiomatic wlr_session.events.change field. In the future, other
events will be added.
2020-11-19 22:47:49 +01:00
Simon Ser 63df2bcbe6 backend/session: don't return FD on failure in open_file
When wlr_session_open_file fails, don't return the FD, otherwise the
caller will think the call succeeded.
2020-11-19 22:47:49 +01:00
Kenny Levinsen fb3bea8014 backend/drm: Use legacy gamma size for legacy backend
We would always return the GAMMA_LUT_SIZE property if available, and
only fall back to legacy gamma size otherwise. This leads to issues if
both are available in differs in size while we use the legacy backend.

Ensure that we only return the legacy size if we're using the legacy
backend.

Closes: https://github.com/swaywm/wlroots/issues/2429
2020-11-19 22:46:25 +01:00
Simon Ser 02df7b7ac8 backend/headless: implement export_dmabuf 2020-11-15 22:54:07 +01:00
Simon Ser 61f8cdfb9e backend/headless: switch to wlr_swapchain 2020-11-15 22:54:07 +01:00
Simon Ser eef8b3dde8 backend/drm: check drm_surface_render_black_frame return value
This avoids hitting an assertion in drm_fb_lock_surface when
we failed to render a black frame.
2020-11-15 22:48:42 +01:00
Simon Ser c881008e1c backend/drm: add support for wlr_swapchain multi-GPU 2020-11-15 22:48:42 +01:00
Simon Ser 8058e338ea backend/drm: get rid of wlr_drm_fb_type
Since all DRM FBs are backed by a wlr_buffer, there's no need for this
anymore.
2020-11-15 22:48:42 +01:00