Commit Graph

5923 Commits

Author SHA1 Message Date
Simon Ser 9549749507 render/gles2: assert that GL_OES_EGL_image_external is supported
The target is set to GL_TEXTURE_EXTERNAL_OES when
EGL_EXT_image_dma_buf_import_modifiers [1] returns an external_only
flag. That spec states:

> In order to support imports for the GL_TEXTURE_EXTERNAL_OES target, a
> compatible OpenGL ES implementation supporting GL_OES_EGL_image_external
> must be present.

Fail hearder when a driver doesn't follow the spec instead of
skipping rendering.

See [2].

[1]: https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3631#note_1584343
2022-10-10 07:54:35 +00:00
Simon Ser f216e97983 backend/drm: drop drm_connector_set_mode()
Instead of special-casing modesets, we can just cut the wrapper
and directly call drm_crtc_page_flip(). drm_connector_test() should
already have the checks previously done in drm_connector_set_mode(),
all we need to do is update enabled/mode after a successful atomic
commit.
2022-10-10 07:48:25 +00:00
John Lindgren ab8341975e render/vulkan: Fix type-punned pointer warning/error 2022-10-09 12:07:57 -04:00
Simon Zeni 694e9bbb9d backend/drm: allocate connector CRTC on lease creation
This was leading to crash in compositors if the wanted connector had no CRTC
2022-10-07 15:54:51 -04:00
Simon Ser 5b0719b17c drm-lease-v1: reject the lease request by default
If the compositor didn't call wlr_drm_lease_request_v1_grant() nor
wlr_drm_lease_request_v1_reject(), then reject the lease.
2022-10-07 19:49:28 +00:00
Simon Ser 11d073ab09 drm-lease-v1: send finished event on failure in submit request
If the "submit" request handler fails, send a "finished" event
so that the client doesn't stall forever.
2022-10-07 19:49:28 +00:00
Simon Ser 5c382f6344 drm-lease-v1: fix error codepath
We were crashing in the error codepath [1] when
wlr_drm_create_lease() fails.

To fix this, delay the creation of the wlr_drm_lease_v1 until the
request is granted. Previously we were allocating that struct early
without populating the drm_lease field. However that means we ended
up with a half-constructed struct in the error codepath which is
annoying to handle.

[1]: https://github.com/swaywm/sway/issues/7204#issuecomment-1269797356
2022-10-07 19:49:28 +00:00
Simon Ser 3be6658ee7 output: allocate swapchain on first commit
On first commit, require a new buffer if the compositor called a
mode-setting function, even if the mode won't change. This makes it
so the swapchain is created now.

Stop trying to check whether the backend supports buffer-less modesets
because that makes everything more complicated. For instance, the
DRM backend doesn't need a new buffer if the previous DRM master left
the output enabled.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3502
2022-10-07 19:21:20 +00:00
Simon Ser e92b272616 output/render: make output_ensure_buffer() no-op when missing renderer
Some compositors want to have full control over the buffers attached
to the output, and don't want to use the internal swapchain. Such
compositors include KWinFT (allocates its buffers on its own) and
gamescope (uses a headless output without any buffers).

Let's just make output_ensure_buffer() a no-op in that case.
2022-10-07 19:21:20 +00:00
Simon Ser 7d8284ec10 output/render: early return in output_ensure_buffer()
Slightly simplify the logic here.
2022-10-07 19:21:20 +00:00
Kirill Primak 7eedbde878 tablet-v2: fix event parameters 2022-10-07 20:19:41 +03:00
Simon Ser f4cf0a8d86 backend/drm: nuke wlr_drm_connector.desired_enabled
This field becomes stale too easily: for instance, see 6adca4089c
("backend/drm: don't unconditionally set desired_enabled").
Additionally, drm_connector_alloc_crtc() needs to do some weird
dance, restoring its previous value.

Instead, add a connector arg to realloc_crtcs() to indicate a new
connector we want to enable.
2022-10-07 16:28:36 +00:00
Simon Ser 5a207aea72 backend/drm: drop unnecessary wlr_drm_connector.crtc checks
drm_connector_alloc_crtc() already checks this.
2022-10-07 16:09:05 +00:00
David96 f885aa0fbe render/vulkan: implement vulkan_preferred_read_format 2022-10-07 15:59:39 +00:00
David96 dce1372e35 render/vulkan: Implement vulkan_read_pixels 2022-10-07 15:59:39 +00:00
Kirill Primak ff9c52801f output: add a swapchain NULL check in wlr_output_commit_state()
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3504
2022-10-07 15:12:53 +00:00
Kirill Primak 46a686ce6b output-damage: drop unused pending_attach_render 2022-10-07 18:09:26 +03:00
Kirill Primak dd0665d822 output-damage: drop precommit listener 2022-10-07 17:43:50 +03:00
Kirill Primak b9155c5b80 output-damage: fix setting pending_attach_render 2022-10-07 17:42:32 +03:00
Simon Ser 052ea7b475 build: alphabetically sort protocol lists
More consistent with the rest of wlroots, and can avoid merge
conflicts.
2022-10-04 17:13:09 +00:00
Simon Ser 6832ae14aa render: drop wlr_renderer_read_pixels() flags
These are unused.
2022-10-04 09:15:19 +02:00
Simon Ser 50cc1ef4d3 screencopy-v1: simplify frame_dma_copy() error path
Unify success and error code-paths.
2022-10-03 17:06:38 +00:00
Simon Ser 0af4affd0b screencopy-v1: fix frame_shm_copy() error path
Don't call wlr_renderer_end() if wlr_renderer_begin_with_buffer()
failed. This will result in an abort().
2022-10-03 17:06:38 +00:00
Simon Ser 0613fb0159 backend/drm: remove outdated TODO
This has been addressed in 8795dde94e ("Initialize connectors
current mode to the mode used by KMS on startup.").
2022-10-03 12:07:10 +02:00
Simon Ser 6adca4089c backend/drm: don't unconditionally set desired_enabled
We were unconditonally setting desired_enabled = true for all
connected connectors. This makes realloc_crtcs() always keep a CRTC
active for these, even if the user doesn't want to enable them.
2022-10-03 12:04:12 +02:00
Kirill Primak b7e2a2584e foreign-toplevel-management: fix indentation 2022-10-01 19:57:32 +00:00
Simon Ser 58d4cfaca3 render/allocator/drm_dumb: drop finish_buffer()
Simplify things a bit.
2022-10-01 19:45:29 +00:00
Simon Ser c659792d7b render/allocator/drm_dumb: fix error handling
In the CREATE_DUMB error code-path, we'd only free() the buffer,
however it's already inserted in the alloc->buffers list at this
point.

Instead, make sure finish_buffer() is safe to call (by populating
drm_fd) and call that function.
2022-10-01 19:45:29 +00:00
Simon Ser 3e7ea8715b render/allocator/drm_dumb: get format info before allocating
Simplifies error handling a bit.
2022-10-01 19:45:29 +00:00
Simon Ser d81f68d2b4 render/allocator/drm_dumb: check modifier list
Check that the modifier list passed as input contains either
INVALID or LINEAR. We don't support others.
2022-10-01 19:45:29 +00:00
Simon Ser 5ef8a18a29 render/allocator/drm_dumb: advertise LINEAR instead of INVALID modifier
INVALID means that the modifier is implicit. However dumb buffers
are guaranteed to be LINEAR, so let's just advertise this. Fixes
cursors with the DRM backend: cursor planes usually only support
LINEAR.
2022-10-01 19:45:29 +00:00
Simon Ser 3799649333 render/pixman: advertise support for linear format modifier
When running with the DRM backend, the Pixman renderer needs to
render the cursor buffer. However, DRM drivers only support linear
buffers for these in general, they don't support implicit modifiers
(aka. INVALID).

Advertise support for LINEAR in the Pixman renderer to fix this.
2022-10-01 19:45:29 +00:00
Consolatis e22aa2796c screencopy-v1: make sure wlr_buffer enum is visible
.. by including wlr_buffer.h
2022-10-01 18:53:36 +00:00
Simon Ser 49738406a3 render: don't fall back to Pixman if we have a render node
If we have a render node, it means there is a GPU which could be
used. We probably failed GL because of a kernel or Mesa issue.
Instead of automatically falling back to Pixman, error out.

This makes it more obvious to users when something goes wrong,
instead of silently exposing a slow unaccelerated desktop.

References: https://github.com/swaywm/sway/issues/7194
2022-10-01 18:05:31 +02:00
Simon Ser db08004c23 render: don't automatically fall back to Vulkan
The Vulkan renderer is still experimental. If GL fails, we don't
want to automatically fall back to it by default.

Fixes: 8bd7170fd9 ("Use env helpers")
2022-10-01 18:01:57 +02:00
Simon Ser e40d492b78 output: fix typo in error message 2022-10-01 16:52:31 +02:00
Simon Ser e4efb6b601 render/vulkan: use addon for wlr_vk_texture
Avoids having to walk the list of all textures.
2022-09-30 14:02:51 +00:00
Simon Ser 7899b97d20 render/vulkan: use addon for wlr_vk_render_buffer
Avoids having to walk the list containing all of the render buffers.
2022-09-30 14:02:51 +00:00
Simon Ser 651c876e79 backend/drm: fix missing wlr_output_state.allow_artifacts
Without allow_artifacts, applying the new state will fail because
it requires ALLOW_MODESET.

Fixes VT switch and disabling CRTCs.
2022-09-30 13:35:07 +02:00
Simon Ser a0345f2854 output: add wlr_output_state.allow_artifacts
When starting up, the compositor might call wlr_output_set_mode()
with a mode which is already the current one. wlroots will detect
this and make the wlr_output_set_mode() call a no-op. During the
next wlr_output_commit() call, wlroots will perform an atomic
commit without the ALLOW_MODESET flag.

This is an issue, because some drivers need ALLOW_MODESET even if
the mode is the same. For instance, if the FB stride or modifier
changed, some drivers require a modeset.

Add a new flag "allow_artifacts" which is set when the compositor
calls mode-setting functions. Use this flag to figure out whether
we want to perform atomic commits with ALLOW_MODESET.

(The name "allow_artifacts" is picked because ALLOW_MODESET is a
misnomer, see [1].)

[1]: https://patchwork.freedesktop.org/patch/505107/

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499
2022-09-30 10:58:17 +00:00
Rouven Czerwinski baf3fa27dc meson: update default options for libdrm
Libdrm now uses enabled/disabled/auto for the drivers, migrate to these
new defaults.

Error message from meson:

  wlroots| subprojects/wlroots/subprojects/libdrm/meson.build:21:0: Exception: Value "false" (of type "string") for combo option "Enable support for Intel's KMS API." is not one of the choices. Possible choices are (as string): "enabled", "disabled", "auto".`
2022-09-25 12:54:38 +02:00
Simon Ser bcc6a5832f render: drop trailing whitespace 2022-09-23 21:48:03 +02:00
Simon Ser c153ae3c5d screencopy-v1: use wlr_buffer APIs
Instead of using low-level wl_shm_buffer and wlr_dmabuf_v1_buffer
APIs, use the unified wlr_buffer APIs. That way it doesn't matter
what the exact wlr_buffer implementation is used, any which provides
the necessary capabilities (data_ptr or dmabuf) would work.

Simplifies the logic a bit, and will make the transition to wlr_shm
easier.
2022-09-22 18:01:52 +00:00
Simon Ser f03da48491 screencopy-v1: rename wlr_screencopy_frame_v1.stride
Make it clear it's only about shm, not about DMA-BUFs.
2022-09-22 18:01:52 +00:00
Simon Ser 77b829e15f screencopy-v1: use DRM format code for shm buffers
Will allow us to simplify common shm/DMA-BUF logic later on.
2022-09-22 18:01:52 +00:00
Simon Ser 4885c08f38 screencopy-v1: rename wlr_screencopy_frame_v1.{format,fourcc}
Make it clear that one is for shm buffers only, and the other is
for DMA-BUF buffers only.
2022-09-22 18:01:52 +00:00
John Lindgren 2b767fe743 backend/libinput: Fix SIGSEGV found in low-memory fuzzing
Stack trace:

    #0  0x00007f17081f5b99 in wl_list_insert (list=list@entry=0x2d8, elm=elm@entry=0x7ffe7f7e85d0)
        at ../wayland-1.21.0/src/wayland-util.c:48
    #1  0x00007f17081f5f2e in wl_signal_emit_mutable (signal=signal@entry=0x2d8, data=data@entry=0x7ffe7f7e8660)
        at ../wayland-1.21.0/src/wayland-server.c:2167
    #2  0x00007f170815a971 in handle_switch_toggle (wlr_switch=0x2a0, event=0x55d5ba13dc00)
        at ../backend/libinput/switch.c:50
    #3  handle_libinput_event (event=0x55d5ba13dc00, backend=0x55d5b975d740) at ../backend/libinput/events.c:234
    #4  handle_libinput_readable (fd=<optimized out>, mask=<optimized out>, _backend=<optimized out>)
        at ../backend/libinput/backend.c:58
    #5  handle_libinput_readable (fd=fd@entry=34, mask=mask@entry=1, _backend=_backend@entry=0x55d5b975d740)
        at ../backend/libinput/backend.c:48
    #6  0x00007f170815c110 in backend_start (wlr_backend=0x55d5b975d740) at ../backend/libinput/backend.c:109
    #7  0x00007f1708160996 in multi_backend_start (wlr_backend=0x55d5b97583d0) at ../backend/multi/backend.c:32
2022-09-22 13:37:32 -04:00
Simon Ser 0cabc83046 backend/drm: pass through mode picture aspect ratio 2022-09-22 09:38:27 +02:00
Simon Ser 2178573b0a output: add wlr_output_mode.picture_aspect_ratio
CTA-861-H defines a picture aspect ratio which may be attached to
each mode. This affects the way the sink will display the image.
See annexes H.1 and H.2 for examples.
2022-09-22 09:36:59 +02:00
John Lindgren 68c8cef38e cursor: Don't warp to (0,0) when last output is disconnected
There doesn't appear to be any good reason to warp the cursor to
the top-left corner when all outputs are disconnected; it's no more
valid than any other (x,y) point in that case.

The real-world case here is a user with a single external monitor
turning it off (which apparently counts as disconnected depending
on the connection type/hardware).  For that user, it's desirable to
have the cursor remain in its original location when the monitor
is turned back on.
2022-09-21 14:25:09 -04:00