Commit Graph

2690 Commits

Author SHA1 Message Date
Simon Ser b03f71fe5f render/vulkan: add support for NV12 2023-05-04 20:07:20 +00:00
Alexander Orzechowski 5adb1be3a7 drm_format_set_intersect: Require initialized dst and remove assert
The usages in linux_dmabuf zero out the dst before passing it so this
change should be fine.
2023-05-04 18:19:33 +00:00
Alexander Orzechowski 1ee75786b4 drm_format_set_union: Require initialized dst and remove assert 2023-05-04 18:19:33 +00:00
novenary d7917d2076 xwayland: allow compositor to set withdrawn state 2023-05-04 18:05:00 +00:00
Alexander Orzechowski 394accbe4a wlr_compositer: Keep track if surface has committed a buffer before.
This would break if you are running with a NULL renderer.
2023-05-04 11:53:26 +02:00
Alexander Orzechowski 2dd9549085 drm_format_set: Mark as unstable
This is supposed to be an unstable interface and it was a mistake that
this header was not included.
2023-05-03 19:08:14 +02:00
Austin Shafer ec37d55a5e Add union function for format sets 2023-05-03 12:06:48 -04:00
Simon Ser a93fc8afd6 render: introduce blend mode
Allow callers to pick the blend mode when rendering a rect. The
"none" mode can be used to disable blending and clear rects.
2023-05-02 21:32:51 +02:00
Simon Ser f5a5712a02 render/vulkan: use VK_KHR_synchronization2
This simplifies the vkQueueSubmit call, removing the need to pass
timeline semaphore point values as separate arrays.
2023-04-28 15:36:39 +00:00
Simon Ser 6830bfc17f render/pixman: implement render pass API 2023-04-25 17:26:35 +02:00
Simon Ser 6ce371a317 render/pixman: add begin_pixman_data_ptr_access()
This logic is used twice.
2023-04-25 17:26:35 +02:00
Simon Ser 587852056c output: add wlr_output_add_software_cursors_to_render_pass()
Same as wlr_output_render_software_cursors(), but takes a
struct wlr_render_pass.
2023-04-25 17:26:34 +02:00
Simon Ser 471249ae4f render/pass: add legacy render pass implementation
Add a render pass implementation which leverages the legacy
rendering API. This is helpful during the migration.
2023-04-25 17:25:10 +02:00
Simon Ser 4a1ad32534 render: add render pass helpers 2023-04-25 17:25:10 +02:00
Simon Ser 756dedae20 Add a new renderer API
Goals:

- Extensibility: we need to be able to add new params to the calls
  to render a texture/rect. For instance we'll need to add fences to
  the render texture operation for explicit sync purposes.
- No implicit state: no more bind_buffer, begin, end.
- No matrices: these hurt Pixman and we don't need them.
- Clip regions for optimized damage repainting.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3188
2023-04-25 17:25:10 +02:00
Simon Ser 44069dfd5e output-layer: add cropping support
Add a src_box state field. Use the SRC_* KMS props in the DRM
backend, reject the layers in the Wayland backend (for now, we can
support it later via viewporter).
2023-04-20 10:39:46 +02:00
Simon Ser 92b726ef67 render/vulkan: use full names for extension command fields
This makes grepping much easier.
2023-04-18 15:58:55 +00:00
Simon Ser 25d9055281 xcursor: sync with libwayland
xcursor.c was copied over from libwayland-cursor. A lot of
cosmetic imporvements have been merged upstream. Copy-paste the
new version.
2023-04-18 14:54:25 +00:00
Andri Yngvason 00489b11a0 seat: Provide dummy resources for inert seats 2023-04-18 08:29:30 +00:00
Simon Ser dae2deb3c9 compositor: add wlr_surface_set_preferred_buffer_transform()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-14 17:07:26 +02:00
Simon Ser 42edd36785 compositor: add wlr_surface_set_preferred_buffer_scale()
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-14 17:07:26 +02:00
Simon Ser 0bb574239d compositor: pass version in wlr_compositor_create
This allows wlroots to support newer versions of the interface
without breaking the API.
2023-04-14 17:07:26 +02:00
Alexander Orzechowski b1e38fc7ea output: Drop output_is_direct_scanout 2023-04-06 22:39:08 +02:00
Simon Ser 9ef98452a3 output-damage: drop
Compositors can migrate to wlr_damage_ring.
2023-04-06 20:34:30 +00:00
Simon Ser 079ff9e6fb output: add wlr_output_is_direct_scanout_allowed()
This lets compositors check whether direct scan-out is possible.
Compositors will soon be responsible for manually calling this
function.
2023-04-06 21:42:08 +02:00
Simon Ser 835208db98 output-layer: add support for scaling buffers
This allows callers to set a destination size different from the
buffer size to scale them.

The DRM backend supports this. The Wayland backend doesn't yet
(we'd need to wire up viewporter).
2023-04-04 19:39:38 +02:00
Simon Ser 89dcecba39 backend/wayland: only unmap layers when necessary 2023-03-28 22:58:29 +00:00
Simon Ser e00c4cd7dc output-layer: cache current state
The will be used by the Wayland backend to figure out whether
updating sub-surface position is necessary.
2023-03-28 22:58:29 +00:00
Rose Hudson 37f42e2df2 backend/wayland: support touch cancel events
since wayland doesn't provide a touch id in cancel events, track what
points are active so we can cancel all of them

timestamp is also not provided - use 0 because no one's paying attention
to that anyway

Closes #3000
2023-03-24 11:47:08 +00:00
zccrs 5602fb1373 backend/wayland: fix undefined reference to wlr_wl_input_device_get_seat
Amend b7e9ad79 to remove wlr_wl_input_device_get_seat definition.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3611
2023-03-20 09:49:54 +08:00
Kirill Primak a3489f2c64 xdg-shell: improve unmapping logic slightly 2023-03-12 11:09:36 +00:00
Simon Ser 1b6fac4aa6 output-layer: require all layers in wlr_output_state.layers
- Simplifies the backends
- Avoids having two ways to do the same thing: previously one could
  disable a layer by either omitting it from wlr_output_state.layers,
  or by passing a NULL buffer
- We can change our mind in the future: we can allow users to omit
  some layers and define a meaning without breaking the API.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4017#note_1783997
2023-03-10 11:16:01 +00:00
Kirill Primak ad51983b23 xwm: make atom_map static 2023-03-09 18:51:47 +00:00
Simon Ser cab47d33e2 util/log: prefix WLR_REL_SRC_DIR with underscore
Just like _WLR_FILENAME and _WLR_ATTRIB_PRINTF, this makes it more
obvious that this isn't part of our API.
2023-03-01 00:52:18 +01:00
Simon Ser a160304289 backend/drm: use libdisplay-info for CVT mode generation 2023-02-28 14:44:02 +00:00
Simon Ser 35da997001 backend/drm: use libdisplay-info to parse EDID 2023-02-28 14:44:02 +00:00
Simon Ser 40117e1e0d render/vulkan: prefer render node for wlr_renderer_get_drm_fd()
Instead of returning a primary node from wlr_renderer_get_drm_fd(),
prefer to return a render node if any.
2023-02-28 14:25:21 +00:00
Simon Ser fef8ab22e3 output: introduce wlr_output_configure_primary_swapchain()
The goal is to simplify wlr_output by moving all of its rendering
API into separate helpers. Here is a first step to sunset
wlr_output_attach_render(). Instead, compositors call
wlr_output_configure_primary_swapchain(), wlr_swapchain_acquire(),
wlr_renderer_begin_with_buffer() and wlr_output_attach_buffer().

Note that compositors can supply a base struct wlr_output_state.
This is useful to allocate a buffer suitable for submission with
a modeset, for instance.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3079
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3197
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3984
2023-02-24 18:22:20 +00:00
Simon Ser b33ab26fe7 render/swapchain: make public
We've had this struct for a while. It'd be useful for compositors
if they want to manage the swap chains themselves instead of being
forced to use wlr_output's. Some compositors might also want to use
a swapchain without an output.
2023-02-21 17:14:31 +01:00
Simon Ser 3874577d3c output-layer: document interactions with screen capture
When e.g. screencopy-v1 is active, callers are responsible for
disabling output layers.
2023-02-21 10:35:30 +00:00
Simon Ser 8338d17d7e backend/drm: drop wlr_drm_layer.pending_{width,height}
No need to store this info in struct wlr_drm_layer. We can just
extract the size when we need it.
2023-02-21 09:45:47 +00:00
Simon Ser 7215bd1e0f output: expose wlr_output_state_set_buffer() 2023-02-21 09:43:43 +00:00
Simon Ser 4629d0ef40 output: expose wlr_output_state_finish()
Same as the original function, but check for the bitfield before
calling pixman_region32_fini(), because that function expects an
initialized region.
2023-02-21 09:43:43 +00:00
Alexander Orzechowski 3ef9f91283 wlr_scene: Add dmabuf_feedback helper 2023-02-20 17:21:17 -05:00
Alexander Orzechowski 323f0b94db wlr_scene: Cleanup header includes
We don't need to pull wlr_compositor.
2023-02-20 16:53:59 -05:00
Simon Ser 849c362ffb linux-dmabuf-v1: add helper for output layer feedback events 2023-02-20 18:38:57 +01:00
Simon Ser 22d9df2af4 backend/drm: send output layer feedback events 2023-02-20 18:38:57 +01:00
Simon Ser e1335a792a output-layer: add feedback event 2023-02-20 18:38:57 +01:00
Simon Ser 4d6fbb2289 backend/drm: add support for output layers 2023-02-20 18:38:57 +01:00
Simon Ser 2398621b8b backend/drm: add libliftoff composition layer
This will be useful for implementing the output layers API.
2023-02-20 18:38:57 +01:00
Simon Ser 9d43e7e4d6 backend/drm: add libliftoff interface 2023-02-20 18:38:57 +01:00
Simon Ser b4e9487312 backend/drm: init wlr_drm_plane for all plane types 2023-02-20 18:38:57 +01:00
Simon Ser cd17b18495 backend/wayland: implement output layers 2023-02-20 18:38:57 +01:00
Simon Ser 3e0ce761ad output: add wlr_output_set_layers() 2023-02-20 18:38:09 +01:00
Simon Ser 2f29b0c438 Add wlr_output_layer
This is based on previous work [1] [2].

This new API allows compositors to display buffers without needing to
perform rendering operations. This API can be implemented on Wayland
using subsurfaces and on DRM using KMS planes.

Compared to [1], this approach leverages wlr_addon_set to let backends
attach their own private state to layers, removes the pending
state (necessary for interop with wlr_output_commit_state()) and
enum wlr_output_layer_state_field.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/1985
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3447
2023-02-20 18:38:09 +01:00
John Lindgren 068280201a xwayland: Read and publish _NET_WM_STRUT_PARTIAL property
This is needed for compositors that want to reserve space for
XWayland panels.  Such a feature can be useful in a "transitional"
setup, where only the X11 window manager and compositor is replaced
but other components of an X11 desktop environment are still used.

This change simply reads the X11 property; the compositor is free
to ignore it.  Thus, compositors that don't want to support such a
"transitional" feature are not impacted.

v2: Update xwayland_surface_associate()
2023-02-13 12:57:20 -05:00
Kenny Levinsen 1225f81a6a scene: Add fractional scale handling 2023-02-08 16:31:39 +01:00
Kenny Levinsen efb8df8b22 wp-fractional-scale-v1: new protocol implementation
This implements the WIP wp-fractional-scale-v1 protocol.
2023-02-08 16:31:39 +01:00
Simon Ser 0c966f102c linux-dmabuf-v1: add wlr_linux_dmabuf_feedback_v1_init_with_options() 2023-02-06 19:14:15 +00:00
Simon Ser b264ec7767 linux-dmabuf-v1: add basic helpers for feedback 2023-02-06 19:14:15 +00:00
Simon Ser 5cd14dfc91 linux-dmabuf-v1: stop using const in feedback
Instead of using const pointers, use structs owned by the tranche.
This will allow wlroots to expose helpers to build feedback
objects.
2023-02-06 19:14:15 +00:00
Alexander Orzechowski 7b32c25a4f wlr_scene: Rename wlr_scene_surface_from_buffer
This renames it to wlr_scene_surface_try_from_buffer to be more clear
that this function can return NULL. This is inline with the rest of
wlroots[1].

[1] https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991
2023-02-04 02:57:42 -05:00
Simon Ser cfa7696d7b backend/wayland: handle wl_registry.global_remove for wl_seat
Destroy the struct wlr_wl_seat when the global is removed.
2023-02-02 18:24:38 +00:00
Simon Ser 2b5eb0733e backend/wayland: make destroy_wl_seats() handle a single seat
Instead of destroying all seats, destroy a single one. We only need
to destroy all seats at one call-site (backend_destroy), but we'll
need to destroy a single seat elsewhere in the next commit.
2023-02-02 18:24:38 +00:00
Simon Ser eb3e8f08a8 subcompositor: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:14:39 +01:00
Simon Ser c5f7f8ab98 ext-session-lock-v1: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:14:12 +01:00
Simon Ser f9bd416d41 layer-shell-v1: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:13:53 +01:00
Simon Ser 49cb85ad72 input-method-v2: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:13:30 +01:00
Simon Ser 711a1a3ed4 xdg-shell: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:12:49 +01:00
Kirill Primak fbf5982e38 xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface()
This new function replaces wlr_surface_is_xwayland_surface() and
wlr_xwayland_surface_from_wlr_surface().
2023-02-01 16:13:21 +00:00
Simon Ser 3668c9d86c examples, tinywl: use "default" cursor instead of "left_ptr"
"left_ptr" is the X11 name, "default" is the cursor spec name.
2023-02-01 15:00:42 +01:00
Consolatis 4097eb20f3 xcursors: Alias existing cursor defaults to cursor-spec cursor names
wlr_xcursor_get_resize_name() returns cursor-spec [1] based names
but the default cursor icons shipped in include/xcursor/cursor_data.h
use traditional X cursor names instead.

Compositors that use wlr_xcursor_get_resize_name() to resolve an edge
to a cursor icon name may thus be unable to render appropriate cursor
icons for users that don't have a cursor-spec compliant cursor theme
installed on their system or have it installed in an unusual place.

This patch adds cursor-spec cursor icon name aliases.

[1] https://www.freedesktop.org/wiki/Specifications/cursor-spec/
2023-02-01 14:14:41 +01:00
Simon Ser 0f24d27e0b xdg-shell: rename wlr_xdg_popup.committed to sent_initial_configure
We made a similar change to wlr_xdg_toplevel.
2023-01-31 16:27:05 +01:00
Simon Ser df0c926a7a xdg-shell: rename wlr_xdg_toplevel.added to sent_initial_configure
This is more descriptive, and avoids the confusion with
wlr_xdg_surface.added.
2023-01-31 16:20:33 +01:00
Simon Ser d36dd96e8d backend/drm: set "max bpc" property based on pixel format
Since 1d581656c7 ("backend/drm: set "max bpc" to the max") we
set the "max bpc" property to the maximum value. The kernel driver
is supposed to clamp this value depending on hardware capabilities.

All kernel drivers lower the value depending on the GPU capabilities.
However, none of the drivers lower the value depending on the DP-MST
link capabilities. Thus, enabling a 4k@60Hz mode can fail on some
DP-MST setups due to the "max bpc" property.

Additionally, it's not a good idea to unconditionally set "max bpc"
to the max. A high bpc consumes more lanes and more clock speed,
which means higher power consumption and the busy lanes cannot be
used for something else (e.g. other data transfers on a USB-C cable).

For now, let's tie the "max bpc" to the pixel format of the buffer.
Introduce a heuristic to make "high bit-depth buffer" a synonym of
"I want the best quality".

This is not perfect: a "max bpc" higher than 8 might be desirable
for pixel formats with a color depth of 8 bits, for instance when
the color management KMS properties are used. But we don't really
support that yet, so let's leave this for later.

Closes: https://github.com/swaywm/sway/issues/7367
2023-01-31 09:32:11 +00:00
Simon Ser 0e54b861e9 seat/keyboard: constify wlr_seat_keyboard_notify_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 695d28c250 seat/keyboard: constify wlr_seat_keyboard_notify_modifiers() 2023-01-26 15:06:45 +00:00
Simon Ser e44834595d seat/keyboard: constify args in wlr_seat_keyboard_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 12e04d8f83 seat/keyboard: constify wlr_seat_keyboard_send_modifiers() 2023-01-26 15:06:45 +00:00
Alexander Orzechowski 5007e713b4 wlr_scene: Send intersecting list of scene outputs for outputs_update signal 2023-01-21 16:23:30 -05:00
Kirill Primak 843b874f22 output-layout: improve closest point for no outputs case
Without outputs, all points are equally invalid anyway, but for e.g.
cursor warping it makes more sense to preserve the original position.
2023-01-21 12:48:43 +00:00
Simon Ser e93ecc669c tablet-tool: revert bitfield in enum wlr_tablet_tool_tip_state
This was changed to a bitfield by mistake.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3484#note_1697926
2023-01-03 20:15:55 +00:00
Isaac Freund 869af1cfbb
session-lock: send more protocol errors
The invalid_destroy and invalid_unlock protocol errors aren't currently
sent by wlroots and instead left up to the compositor. However, we can
handle these as well without much additional complexity.

This also adds a missing wl_resource_destroy() call if the lock is inert
in lock_handle_unlock_and_destroy().
2022-12-23 16:56:42 +01:00
Simon Ser 7081687843 keyboard: improve documentation 2022-12-15 19:49:45 +00:00
Simon Ser 8b8921d57b backend/drm: remove wlr_drm_crtc.legacy_crtc
We only need it for one thing: gamma size. Moreover, some bits in
the drmModeCrtc will become out-of-date, for instance the current
mode, so let's avoid caching the whole struct and only keep what
we know won't change.
2022-12-15 19:31:06 +01:00
xiliuya 7f6d646e0a keyboard: only update LEDs when changed 2022-12-14 17:51:06 +01:00
Simon Ser 99fb2fefc3 backend/drm: rename wlr_drm_backend.outputs to connectors
This list contains wlr_drm_connector entries, and there is no
guarantee that the wlr_output fields are initialized.
2022-12-13 19:15:09 +00:00
Simon Ser f361efe965 backend/drm: add drm_connector_status_str()
Helper to stringify a connector status.
2022-12-13 16:50:27 +00:00
Kirill Primak 8f58c060fd util/region: forbid "shrinking" a region with wlr_region_expand()
The logic isn't correct.
2022-12-09 16:46:36 +00:00
Simon Ser 037b21647b backend/drm: store pending FB in state
Instead of having a pending_fb field on the struct wlr_drm_plane,
move it to struct wlr_drm_connector_state. That way, there's no
risk having a stale pending FB around: the state doesn't survive
across tests and commits.

The cursor is a special case because it's disconnected from the
atomic state: the wlr_backend_impl.set_cursor hook sets the cursor
for the next commit. Move the field to
wlr_drm_connector.cursor_pending_fb.
2022-12-07 17:45:59 +01:00
Simon Ser ae61cd6bfb backend/drm: use separate field to store pending cursor FB
We'll move the pending primary FB into the connector state in the
next commit, dropping wlr_drm_plane.pending_fb in the process.
Introduce a dedicated field for the cursor, which has to be managed
in a special way due to our set_cursor API.
2022-12-07 17:44:51 +01:00
Simon Ser 86fc2199f8 build: unify naming for HAVE_* defines
We sometimes used HAS_, sometimes polluted the LIBINPUT_ namespace,
etc.
2022-12-06 22:39:45 +00:00
Simon Ser a4a40618ad backend/libinput: use internal_config
Removes project arguments.
2022-12-06 22:39:45 +00:00
Simon Ser 4da9b32a15 xwayland: use internal_config
Avoids the need to have a separate config.h, and removes C compiler
arguments.
2022-12-06 22:39:45 +00:00
Simon Ser 6c897756b6 build: use a configuration file for internal features
This avoids re-building the whole project when switching one
Meson option. This shrinks down the compiler invocation command
line, making it more readable and making it easier to inspect
which flags are passed in (the generated file can be opened).
Additionally this is more consistent with our external feature
handling, which uses <wlr/config.h> already.
2022-12-06 22:39:45 +00:00
Simon Ser afe1ae4479 backend/x11: ensure buffers are released on shutdown 2022-12-06 20:22:55 +01:00
Simon Ser d72b4409ce util/env: make env_parse_switch() return a size_t
This function is guaranteed to never return a negative value.

This is important because we use arr[env_parse_switch(...)] in a
few places.
2022-12-06 16:14:18 +01:00
Simon Ser dc09585d14 util/env: add docs
I always forget what env_parse_switch() does on error.
2022-12-06 16:14:16 +01:00
Simon Ser 8456ac6fa9 render/vulkan: wait for DMA-BUF fences
The Vulkan spec doesn't guarantee that the driver will wait for
implicitly synchronized client buffers before texturing from them.
radv happens to perform the wait, but anv doesn't.

Fix this by extracting implicit fences from DMA-BUFs, importing
them into Vulkan as a VkSemaphore objects, and make the render pass
wait on these VkSemaphores.
2022-12-06 14:54:09 +00:00
Simon Ser 30219cf76b render/dmabuf: add dmabuf_export_sync_file() 2022-12-06 14:54:09 +00:00
Ronan Pigott f8e70af318 wlr_xdg_activation_v1: add new_token event 2022-12-06 05:45:37 +00:00
Kirill Primak 097ea84cda output-layout: improve API
- wlr_output_layout_add{,_auto}() now return a bool indicating whether
  the function has succeeded.
- wlr_output_layout_move() is removed.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1083
2022-12-05 18:21:04 +00:00
Kirill Primak 27ea18cc33 output-layout: remove wlr_output_layout_output_state
wlroots uses "// private state" comments to denote structure fields
which shouldn't be accessed by compositors, so let's drop
wlr_output_layout_output_state and inline its fields into
wlr_output_layout_output; this also simplifies layout output creation.
2022-12-05 18:21:04 +00:00
Kirill Primak 604df8b327 output-layout: fix function decl indentation 2022-12-05 18:21:04 +00:00
Simon Ser 532f3d3c20 xwayland/xwm: replace role with addon
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3545
2022-12-05 18:48:15 +01:00
Simon Ser 512deebd82 compositor: add wlr_surface.events.precommit 2022-12-05 10:51:46 +01:00
Simon Ser c4727240af compositor: document wlr_surface_{enter,leave,send_frame_done} 2022-12-03 16:52:32 +00:00
Alexander Orzechowski ec846adb54 wlr_drm: Add missing wlr_buffer import 2022-12-03 07:57:40 -05:00
Simon Ser 337ef33edc render/vulkan: make shm/dmabuf split clearer in wlr_vk_format_props
struct wlr_vk_format_props contains a mix of properties for shm
and dmabuf, and it's not immediately clear which fields are for
which kind of buffer. Use a nested struct to group the fields.
2022-12-02 15:18:59 +00:00
Simon Ser db9d277614 render/vulkan: make vulkan_format_props_find_modifier() return value const 2022-12-02 15:18:59 +00:00
Simon Ser f36a5915da wl-drm: don't store wlr_renderer
Query the formats at init time, then forget about the renderer.
This will allow wl_drm to be created with a list of formats instead
of a renderer, and will behave better after a GPU reset.
2022-12-02 14:27:07 +00:00
Simon Ser c9b378d21a render/drm-format-set: add wlr_drm_format_set_copy() 2022-12-02 14:27:07 +00:00
Simon Ser 8b9a48c984 render/vulkan: drop "_format" in wlr_vk_format fields
"format" is already in the name, no need to repeat ourselves.
`format->vk_format` sounds a bit redundant.
2022-12-02 10:24:00 +01:00
Simon Ser c8eb24d30e output: drop enable/mode events
The backend no longer changes the output state behind the
compositor's back. Instead, compositors can listen to the "commit"
event and check for WLR_OUTPUT_STATE_ENABLED/WLR_OUTPUT_STATE_MODE.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2300
2022-12-01 20:05:04 +00:00
Simon Ser 19dfe99496 output-damage: stop listening for output mode events
These will go away.
2022-12-01 20:05:04 +00:00
Simon Ser fecbaa2bd6 scene: stop listening for output enable/mode events
These will go away.
2022-12-01 20:05:04 +00:00
Alexander Orzechowski fe891ebd4e output_init_render: Allow re-initialization
This lets the compositor call this function after the fact to replace
the renderer/allocator after a renderer context lost.
2022-12-01 10:01:35 +00:00
Alexander Orzechowski db0e962368 wlr_texture: Expose owning renderer 2022-12-01 04:41:43 -05:00
Simon Ser f103dc74d8 linux-dmabuf-v1: introduce wlr_linux_dmabuf_v1_create()
Some compositors may want to use the linux-dmabuf-v1 implementation
with a completely custom renderer. Add a function to create the
global with a default feedback.
2022-11-30 14:19:46 +01:00
Simon Ser 9c04fd2496 linux-dmabuf-v1: drop wlr_renderer field
This isn't used anymore.
2022-11-30 14:19:46 +01:00
Simon Ser 88493d1f7c linux-dmabuf-v1: don't use wlr_renderer to send legacy format list
The wlr_renderer field will go away in a subsequent commit.

Build the legacy device list from the default feedback instead.
2022-11-30 14:19:46 +01:00
Simon Ser d45cffb865 linux-dmabuf-v1: don't use wlr_renderer to sanity check DMA-BUFs
The wlr_renderer field will go away in a subsequent commit.

Instead of trying to create a texture, try to import the DMA-BUF
into the DRM device FD.
2022-11-30 14:14:07 +01:00
Simon Ser c99c60090c linux-dmabuf-v1: add version arg to create()
To be able to add support for newer versions without breaking
changes.
2022-11-30 14:14:04 +01:00
Simon Ser 444d94ef89 linux-dmabuf-v1: add "_with_renderer" suffix to create() function
Make it clear this is a helper consuming a wlr_renderer. We'll
add a lower-level create() function which doesn't take it in the
next commit.
2022-11-30 14:14:02 +01:00
Simon Ser d2238bf722 render/vulkan: import semaphore to DMA-BUF instead of blocking
Right now the Vulkan renderer blocks until the frame is complete
after rendering. This is necessary because Vulkan doesn't
interoperate well with implicit sync we use everywhere else.

Use the new kernel API to import a sync_file into a DMA-BUF to
avoid blocking.
2022-11-28 23:50:41 +00:00
Simon Ser aaf828d3d2 render/dmabuf: add dmabuf_import_sync_file
References: https://lore.kernel.org/dri-devel/20220506180216.2095060-1-jason@jlekstrand.net/
2022-11-28 23:50:41 +00:00
Simon Ser 10f543d579 render/vulkan: release stage buffers after command buffer completes
We need to wait for the pending command buffer to complete before
re-using stage buffers. Otherwise we'll overwrite the stage buffer
with new contents before the texture is fully uploaded.
2022-11-28 23:50:41 +00:00
Simon Ser 2a414c896e render/vulkan: destroy textures after command buffer completes
We need to wait for any pending command buffer to complete before
we're able to fully destroy a struct wlr_vk_texture: the Vulkan
spec requires the VkDescriptorSet to be kept alive.

So far we've done this in vulkan_end(), after blocking until the
command buffer completes. We'll soon stop blocking, so move this
logic in get_command_buffer(), where we check which commands buffers
have completed in a non-blocking fashion.
2022-11-28 23:50:41 +00:00
Simon Ser 0730552e85 render/vulkan: drop unused fields from wlr_vk_format_modifier_props
export_imported is never used, and dmabuf_flags is already checked
in query_modifier_support().
2022-11-28 10:22:56 +01:00
Simon Ser ab6607b950 build: exclude <wlr/types/wlr_drm_lease_v1.h> without DRM backend
When the DRM backend is disabled, so is the DRM lease protocol.
Prevent the header from being installed in that case.
2022-11-27 10:57:32 +00:00
Manuel Stoeckl c02872e033 render/vulkan: align staging buffers for texture upload
vkCmdCopyBufferToImage requires that the buffer offset be a multiple
of the texel block size, which for single plane uncompressed formats
is the same as the number of bytes per pixel. This commit adds an
alignment parameter to vulkan_get_stage_span which ensures that the
provided span (and the sequence of image copy operations derived which
use it) have this alignment.
2022-11-25 12:29:02 -05:00
Simon Ser f0375eed24 backend/session: make optional
Some compositors are not interested in wlr_session, for instance
nested compositors.

Disabling wlr_session removes the udev dependency.
2022-11-25 16:15:29 +00:00
Simon Ser 769cabbadf util/time: use int64_t return value for get_current_time_msec()
0xFFFFFFFF milliseconds is 4,294,967,295 ms so about 50 days.
A little bit too close for comfort.

Use int64_t instead of uint64_t to avoid C's implicit conversion
footguns in computations.
2022-11-25 16:15:29 +00:00
Simon Ser 76b3687739 shm: add create() function without a wlr_renderer
This allows compositors which don't use wlr_renderer to still use
wlroots' wl_shm implementation.
2022-11-25 15:16:42 +00:00
Manuel Stoeckl 3ed69b4946 render/vulkan: add support for RGB565 texture format
Since this does not have a matching _SRGB-type vulkan format, add a
new shader variant/pipeline to perform the sRGB->linear texture
conversion.
2022-11-25 14:19:27 +00:00
Kirill Primak 060df4c6c0 scene: introduce wlr_scene_buffer.events.outputs_update
This event is useful for e.g. sending the preferred buffer scale to the
client.
2022-11-24 22:28:13 +00:00
Simon Ser 42016fa262 compositor: make renderer optional
This is a first step towards moving texture uploading out of
wlr_compositor.

This commit allows compositors to opt-out of the texture uploading
by passing a NULL wlr_renderer. An immediate user of this is
gamescope, which currently implements a stub wlr_renderer just to
make wlr_compositor happy.
2022-11-24 21:55:24 +00:00
Simon Ser 359df5ef84 compsitor: document wlr_compositor_create() 2022-11-24 21:55:24 +00:00
Simon Ser d47016abb2 backend/multi: stop pulling <wlr/backend/session.h>
Unused.
2022-11-24 21:50:28 +00:00
Simon Ser 0fa5743c26 render/gles2, render/pixman: stop pulling <wlr/backend.h>
No reason why the GLES2/Pixman renderers should depend on the
backend.
2022-11-24 21:50:28 +00:00
Simon Ser b89a050e58 backend: stop pulling <wlr/backend/session.h>
We can just forward-declare the struct instead.
2022-11-24 21:50:28 +00:00
Simon Ser ba13f471ea backend/session: drop unused <libudev.h>
We don't actually need to pull that header here.
2022-11-24 21:50:28 +00:00
Simon Ser 99134c26b8 render: stop pulling <wlr/backend.h>
Let's just forward-declare struct wlr_backend instead.

We need to fixup the Vulkan renderer: it needs makedev(), which
got included by chance via <wlr/backend.h> → <wlr/backend/session.h>
→ <libudev.h>.
2022-11-24 21:50:28 +00:00
Simon Ser 4ff46e6cf9 xwayland/xwm: add support for xwayland-shell-v1 2022-11-18 15:35:20 +00:00
Simon Ser 85b37127a6 xwayland/shell: add wlr_xwayland_shell_v1_surface_from_serial() 2022-11-18 15:35:20 +00:00
Simon Ser d19191ff6b xwayland/server: delay non-lazy startup
This allows users to setup event listeners before the server is
actually started.
2022-11-18 15:35:20 +00:00
Simon Ser 3f40b0031f xwayland/server: add start signal
This can be used to know when wlr_xwayland_server decides to start
a new Xwayland process. At that point the wl_client has already
been created but the Xwayland process hasn't been started yet.
2022-11-18 15:35:20 +00:00
Simon Ser d3b84463f8 xwayland: add wlr_xwayland_shell_v1_destroy() 2022-11-18 15:35:20 +00:00
Simon Ser 44c7e233ff xwayland: add wlr_xwayland_shell_v1_set_client() 2022-11-18 15:35:20 +00:00
Simon Ser 69b0b296a2 xwayland-shell-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/163
2022-11-18 15:35:20 +00:00
Kirill Primak 236918d52e Nuke deprecated include/wlr/types/wlr_surface.h
Use wlr_compositor.h and wlr_subcompositor.h instead.
2022-11-17 10:12:06 +00:00
Simon Ser 6c3d6be74b output: drop wlr_output_damage_whole()
This function is not used anymore. Backends have no good reason to
damage outputs.
2022-11-17 09:17:32 +00:00
Simon Ser e7c556fcf6 backend: drop wlr_backend_get_session()
This no longer has purpose.
2022-11-15 21:16:25 +00:00
Simon Ser 41b7acbab7 backend: return wlr_session in wlr_backend_autocreate() call
Up until now, wlr_backend_autocreate() created the wlr_session and
then stuffed it into struct wlr_multi_backend so that compositors
can grab it later.

This is an abuse of wlr_multi_backend and the wlr_backend API:
wlr_backend_get_session() and wlr_multi_backend.session only exist
to accomodate the needs of wlr_backend_autocreate(). What's more,
the DRM and libinput backends don't implement
wlr_backend_impl.get_session.

Instead, return the struct wlr_session to the compositor in the
wlr_backend_autocreate() call. wlr_backend_get_session() will be
removed in the next commit.
2022-11-15 21:16:25 +00:00
Simon Ser 6c277e3c39 buffer: drop wlr_shm_client_buffer
It's been superseded by wlr_shm.
2022-11-15 16:30:00 +00:00
Simon Ser 0ae3c7b1a2 Introduce wlr_shm
This is a re-implementation of wl_shm. The motivations for using
this over the one shipped in libwayland are:

- Properly handle SIGBUS when accessing a wl_buffer's underlying
  data after the wl_buffer protocol object has been destroyed.
  With the current code, we just crash if the client does that
  and then shrinks the backing file.
- No need to fight the wl_shm_buffer API anymore. This was awkward
  because we weren't notified when clients created a wl_shm buffer,
  and this doesn't play well with our wlr_buffer abstraction.
- Access to the underlying FD. This makes it possible to forward
  the wl_shm buffer to a parent compositor with the Wayland/X11
  backends.
- Better stride checks. We can use our format table to ensure that
  the stride is consistent with the bpp and width.
2022-11-15 16:30:00 +00:00
Simon Ser 6e88eeadeb render/pixel_format: import pixel_format_info_check_stride()
We'll use this function from wlr_shm too.

Add some assertions, use int32_t (since the wire protocol uses that,
and we don't want to use 16-bit integers on exotic systems) and
switch the stride check to be overflow-safe.
2022-11-15 16:30:00 +00:00
Kirill Primak 8cfd44980b input-inhibitor: deprecate
The protocol itself has been deprecated.
2022-11-15 16:06:53 +00:00
Simon Ser 165352e32f render/egl: enable EGL_LOSE_CONTEXT_ON_RESET
This allows the GLES2 renderer to figure out when a GPU reset
happens.
2022-11-15 15:50:19 +00:00
Simon Ser 261d6998fb render/gles2: query glGetGraphicsResetStatusKHR
Call glGetGraphicsResetStatusKHR in wlr_renderer_begin to figure
out when a GPU reset occurs. Destroy the renderer when this
happens (the OpenGL context is defunct).
2022-11-15 15:50:19 +00:00
Simon Ser 31ea61b390 render: add wlr_renderer.events.lost 2022-11-15 15:50:19 +00:00
Simon Ser a541c9510a render: make wlr_renderer_begin return a bool 2022-11-15 15:50:19 +00:00
Simon Ser 23540b5579 render: allow wlr_renderer_impl.begin to fail
Make it return a bool to indicate success/failure. Adapt the
various implementations to check errors.
2022-11-15 15:50:19 +00:00
Simon Ser 4a70172e26 render: make some wlr_renderer fields private 2022-11-15 15:50:19 +00:00
Simon Ser 5451cbd183 render: add docs for wlr_renderer 2022-11-15 15:50:19 +00:00
Simon Ser bf623ec782 content-type-v1: add version param to wlr_content_type_manager_v1_create() 2022-11-15 16:43:04 +01:00
Simon Ser ff55663906 output: introduce request_state event
This allows backends to request the compositor to change the state
of an output.

References: https://github.com/swaywm/wlroots/issues/2300#issuecomment-761819673
2022-11-15 15:39:55 +00:00
Simon Ser 024627e872 content-type-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/150
2022-11-15 15:36:09 +00:00
Simon Ser 258bf9be1e compositor: drop wlr_surface.{sx,sy}
The concept of a persistent accumulated surface offset is wrong
from a protocol point-of-view. wl_surface.offset is tied to a
commit, its interpretation depends on the surface role.

For example, with the following sequence:

    wl_surface@1.offset(1, 1)
    wl_surface@1.commit()
    wl_pointer@2.set_cursor(wl_surface@1, 42, 42)

The final cursor hotspot is (42, 42): the commit which happened
before the set_cursor request has no impact on the hotspot
computation.

The wlr_output_cursor logic already uses wlr_surface.current.{dx,dy}.
wlr_scene's drag icon doesn't, update it accordingly.
2022-11-15 13:41:09 +00:00
zccrs 5b34fe5513 render/vulkan: add wlr_vk_texture_has_alpha
Allow to get whether has alpha channel of the VkImage, it can help an
optimization to disable blending when the texture doesn't have alpha.
Because the VkFormat isn't enough because it's always set to
VK_FORMAT_B8G8R8A8_SRGB or VK_FORMAT_R8G8B8A8_SRGB.
2022-11-15 10:58:45 +08:00
Alexander Orzechowski c8a5dfcc87 wlr_scene: Add drag icon helper 2022-11-14 15:44:43 +00:00
Simon Ser 9f793d3503 layer-shell-v1: specify version in constructor
This allows compositors to indicate which features they support,
and is required to eventually make this API stable.

References: https://github.com/swaywm/sway/issues/7260
2022-11-14 09:52:13 +01:00
fakechen 4026da53f8 egl: remove eglQueryWaylandBufferWL define
This define doesn't exist anymore.

Signed-off-by: fakechen <chenzigui@kylinos.cn>
Signed-off-by: sunzhguy <sunzhigang1@kylinos.cn>
2022-11-14 09:22:01 +08:00
Kirill Primak 627a5c5112 xwayland: fix wlr_xwayland_surface_from_wlr_surface() docs
32daa43a45 has removed the asymmetry in
the relationship of a wlr_surface and an unmapped wlr_xwayland_surface,
when wlr_surface.role_data wasn't NULL but wlr_xwayland_surface.surface
was. However, this also means that
wlr_xwayland_surface_from_wlr_surface() now returns NULL if the
wlr_surface is unmapped. Fix the documentation to reflect this.
2022-11-13 01:35:12 +03:00
Simon Ser 2b22a10478 scene: constify region APIs 2022-11-11 23:11:17 +00:00
Simon Ser c5d79bfb26 region: constify 2022-11-11 23:11:17 +00:00
Simon Ser fe4225d5de output: constify damage APIs 2022-11-11 23:11:17 +00:00
Simon Ser 9e10e9af7f output-damage: constify wlr_output_damage_add() 2022-11-11 23:11:17 +00:00
Simon Ser fb7bd920a6 damage-ring: constify wlr_damage_ring_add() 2022-11-11 23:11:17 +00:00
Simon Ser 93597952aa buffer: constify wlr_client_buffer_apply_damage() 2022-11-11 23:11:17 +00:00
Simon Ser 6baf045590 render/texture: constify wlr_texture_update_from_buffer() 2022-11-11 23:11:17 +00:00
Simon Ser 9fd28d1e81 util/region: constify 2022-11-11 23:11:17 +00:00
Simon Ser f4f3c15c1e render/vulkan: always wait for last stage to complete before rendering
When we have multiple command buffers in flight, we need to make
sure we don't start rendering before the previous texture uploads
are complete.
2022-11-11 19:18:04 +00:00
Simon Ser 7fdcb45e66 render/vulkan: use command buffer pool for stage 2022-11-11 19:18:04 +00:00
Simon Ser f1eae0eeeb render/vulkan: add a command buffer pool
Before re-using a VkCommandBuffer, we need to wait for its
operations to complete. Right now we unconditionally wait for
rendering to complete in vulkan_end(), however we have plans to
fix this [1]. To fully avoid blocking, we need to handle multiple
command buffers in flight at the same time (e.g. for multi-output,
or for rendering followed by texture uploads).

Implement a pool of command buffers. When we need to render, we
pick a command buffer from the pool which has completed its
operations. If we don't find one, try to allocate a new command
buffer. If we don't have slots in the pool anymore, block like we
did before.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3574
2022-11-11 19:18:04 +00:00
Simon Ser a8a194d695 render/vulkan: switch to timeline semaphores
Up until now we were using a VkFence for GPU-to-CPU
synchronization. This has some limitations that become a blocker
when trying to have multiple command buffers in flight at once
(e.g. for multi-output). It's desirable to implement a command
buffer pool [1], but VkFence cannot be used to track command buffer
completion for individual subpasses.

Let's just switch to timeline semaphores [2], which fix this issue,
make synchronization a lot more ergonomic and are a core Vulkan 1.2
feature.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3802
[2]: https://www.khronos.org/blog/vulkan-timeline-semaphores
2022-11-11 19:18:04 +00:00
Kirill Primak a707b7b101 output-damage: deprecate 2022-11-11 05:31:10 +00:00
Alexander Orzechowski ea40ba4f6a wlr_scene: Fix texture reuse
Add private interface to ignore a buffer that's locking a client_buffer
for damage tracking. This should eventually be replaced by wlr_raster.
2022-11-11 00:08:04 +00:00
illiliti eec95e3d5e backend/drm: use pnp.ids to fetch EDID data 2022-11-09 00:25:18 +03:00
Simon Ser d75b4d8e86 Revert "backend/drm: fetch EDID manufacturer from udev_hwdb"
This reverts commit e646d882cf.

This commit has added a dependency on udev_hwdb. This API isn't
available on all platforms (e.g. FreeBSD), and further deepens
our udev dependency. A better solution is being worked on in [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3638
2022-11-08 19:08:43 +01:00
Kirill Primak 4152db92ef damage-ring: add missing headers 2022-11-08 17:10:56 +00:00
zccrs 270914d379 render/vulkan: add some interfaces to allow compositors to integrate
Added wlr_vk_renderer_get_* functions to allow get the VkInstance,
VkPhysicalDevice, VkDevice, queue family of a wlr_vk_renderer.

Added wlr_vk_renderer_get_current_image_attribs function to allow get
the VkImage of current renderer buffer to use on compositors.

Added wlr_renderer_is_vk function, it's like the wlr_renderer_is_gles2,
returns true if the wlr_renderer is a wlr_vk_renderer.

Added wlr_vk_image_get_attribs function to get a VkImage and it's
extras information (e.g. a VkImageLayout and VkImageFormat of the
VkImage) from a wlr_texture.
2022-11-08 12:56:38 +01:00
Simon Ser 6c31f3b078 render/vulkan: use wl_array for wlr_vk_shared_buffer.allocs
Avoids the need to open-code the realloc() logic.
2022-11-07 21:22:33 +00:00
Simon Ser ea68506b73 render/vulkan: fix and add missing wl_list comments
In wlroots we add comments near struct wl_list members to indicate
which type it's linked to. The Vulkan renderer had some comments
with mistakes, and some members without a comment.
2022-11-07 14:08:03 +00:00
Kirill Primak 32daa43a45 xwayland/xwm: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak acd5a64fd1 xdg-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 92fbfda2ca drag-icon: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 75af6a0a39 input-method: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak bcf6b2bbf8 session-lock: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 2518ace573 subcompositor: use role object destroy handler 2022-11-06 17:00:00 +03:00