Commit Graph

449 Commits

Author SHA1 Message Date
nyorain 8e34692250 render/vulkan: add Vulkan renderer
This new renderer is implemented with the existing wlr_renderer API
(which is known to be sub-optimal for some operations). It's not
used by default, but users can opt-in by setting WLR_RENDERER=vulkan.

The renderer depends on VK_EXT_image_drm_format_modifier and
VK_EXT_physical_device_drm.

Co-authored-by: Simon Ser <contact@emersion.fr>
Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
2021-10-18 11:51:13 +02:00
Simon Ser 1b65a80e9d render/allocator: use empty DRM lease to re-open node
This allows us to obtain a new DRM file description without relying
on filesystem permissions.
2021-10-14 21:23:41 +02:00
Simon Ser 13cdb84ee8 render/allocator: use render node if available in reopen_drm_node
If we aren't trying to create a dumb buffer allocator, and if the
DRM device has a render node (ie, not a split render/display SoC),
then we can use the render node instead of the primary node. This
should allow wlroots to run under seatd when the current user
doesn't have the permission to open primary nodes (logind has a
quirk to allow physically logged in users to open primary nodes).
2021-10-04 12:25:27 +02:00
Simon Ser 323b8498ad Revert "render/drm_format_set: add wlr_drm_format_has"
This reverts commit 833437d592.
2021-10-01 09:26:05 -06:00
Simon Ser 1d7e438d8a Revert "Require INVALID for implicit format modifiers"
This reverts commit ea7357b703.
2021-10-01 09:26:05 -06:00
Simon Ser 62be833aef Revert "render/egl: always add LINEAR to supported modifiers"
This reverts commit 780052d4da.
2021-10-01 09:26:05 -06:00
Simon Ser 42138a073b Revert "render/drm_format_set: remove special LINEAR case"
This reverts commit 6d281d96cb.
2021-10-01 09:26:05 -06:00
Simon Ser 6d281d96cb render/drm_format_set: remove special LINEAR case
This was used to make the intersection of INVALID and LINEAR result
in LINEAR. We can now just require LINEAR to be in both lists.
2021-10-01 09:21:50 -06:00
Simon Ser 780052d4da render/egl: always add LINEAR to supported modifiers 2021-10-01 09:21:50 -06:00
Simon Ser ea7357b703 Require INVALID for implicit format modifiers
See [1] for the motivation.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-10-01 09:21:50 -06:00
Simon Ser 833437d592 render/drm_format_set: add wlr_drm_format_has 2021-10-01 09:21:50 -06:00
Simon Zeni 9579d62a16 types/buffer: make {begin,end}_data_ptr_access part of the public API 2021-09-15 11:50:44 +02:00
Simon Ser 4e7a8707cc buffer: add data_ptr access flags
This allows callers to specify the operations they'll perform on
the returned data pointer. The motivations for this are:

- The upcoming Linux MAP_NOSIGBUS flag may only be usable on
  read-only mappings.
- gbm_bo_map with GBM_BO_TRANSFER_READ hurts performance.
2021-09-10 13:16:10 -04:00
Simon Ser 38cd1b4f4f render/allocator/gbm: add log message for gbm_bo_get_fd_for_plane
Makes it easier to find out which branch is taken when debugging
issues like [1].

[1]: https://github.com/swaywm/wlroots/issues/3156
2021-09-03 22:13:38 +02:00
Simon Ser 7df2ae88fa render/allocator: use legacy authentication for primary nodes
Closes: https://github.com/swaywm/wlroots/issues/3156
2021-09-03 11:44:12 -04:00
Simon Ser d9d8fc1ab9 render/allocator: re-open GBM FD
Using the same DRM file description for the DRM backend and for the
GBM allocator will result in GEM handle ref'counting issues [1].
Re-open the DRM FD to fix these issues.

[1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/110
2021-09-01 15:17:05 -04:00
Simon Ser 749b3c00f0 render/egl: reopen DRM node for GBM
This will be necessary for the next patch, to avoid messing up BO
handles shared between the GL implementation and the DRM backend.
2021-08-25 10:05:37 -04:00
Simon Ser 3ce2ea9e16 Move allocator stuff into new directory
Add render/allocator/ and include/render/allocator/ to hold
everything allocator-related.
2021-08-25 09:57:20 -04:00
Simon Ser ad7651a370 render/gles2: make wlr_gles2_texture a wlr_buffer addon 2021-08-12 10:22:19 +02:00
Simon Ser ee1156b62b render/gles2: make wlr_gles2_buffer an addon
Saves us from walking a list.
2021-08-12 10:22:19 +02:00
Simon Ser 8a3cd28973 render/pixman/pixel_format: add more formats
Add a bunch of new formats for Pixman: a few missing 32-bit ones,
some 16-bit and 32-bit formats as well.

Mostly based on a Weston patch [1].

[1]: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/664
2021-08-03 02:53:03 -04:00
Simon Ser b913e64f95 render/pixel_format: add more formats for Pixman
These will be added to Pixman in the next commit.
2021-08-03 02:53:03 -04:00
Manuel Stoeckl f5df956c18 render/gles2: add a few 10-bit and FP16 formats
The half-float formats depend on GL_OES_texture_half_float_linear,
not just the GL_OES_texture_half_float extension, because the latter
does not include support for linear magni/minification filters.

The new 2101010 and 16161616F formats are only available on little-
endian builds, since their gl_types are larger than a byte and thus
endianness dependent.
2021-07-30 08:29:13 +02:00
Manuel Stoeckl 44e8451cd9 render/gles2: hide shm formats without GL support
This change introduces a new function to check whether the renderer
has the needed GL extensions to read a given pixel format.
2021-07-30 08:29:13 +02:00
Manuel Stoeckl 4dc52bcb6c render/pixel-format: add a few 10-bit and FP16 formats 2021-07-30 08:29:13 +02:00
Simon Ser f76960388f render/gles2: add support for some 24 and 16-bit formats
On little-endian, we can enable pixel formats which don't use
gl_type = GL_UNSIGNED_BYTE. See [1].

[1]: https://afrantzis.com/pixel-format-guide/
2021-07-29 10:47:34 -04:00
Simon Ser 6973361d60 render/pixel-format: add some 24 and 16-bit formats 2021-07-29 10:47:34 -04:00
Simon Zeni 6f19295647 render/egl: initialize wlr_egl with EGL_PLATFORM_DEVICE_EXT
Uses the EXT_device_query extension to get the EGL device matching the
requested DRM file descriptor. If the extension is not supported or no device
is found, the EGL device will be retrieved using GBM.

Depends on the EGL_EXT_device_enumeration to get the list of EGL devices.
2021-07-27 20:45:53 +02:00
yuiiio 7667ab73bd
render/egl: fix typo 2021-07-27 00:35:36 +02:00
Simon Ser 3cf2535c23 render/egl: add support for EGL_EXT_device_drm_render_node
This EGL extension has been added in [1]. The upsides are:

- We directly get a render node, instead of having to convert the
  primary node name to a render node name.
- If EGL_DRM_RENDER_NODE_FILE_EXT returns NULL, that means there is
  no render node being used by the driver.

[1]: https://github.com/KhronosGroup/EGL-Registry/pull/127
2021-07-26 11:44:16 -04:00
Simon Ser ace2eda073 render/egl: set EGL_IMAGE_PRESERVED_KHR
Without setting this the EGL implementation is allowed to perform
destructive actions on the buffer when imported: its contents
become undefined.

This is mostly a pedantic change, because Mesa processes the attrib
and does absolutely nothing with it.
2021-07-23 11:27:17 -04:00
Simon Zeni 04d4fb536d render/wlr_texture: put wlr_texture_from_buffer into the public API 2021-07-22 22:28:24 +02:00
Simon Ser 2fa47c1837 render: drop wlr_renderer_impl.init_wl_display
Now that we have our own wl_drm implementation, there's no reason
to provide custom renderer hooks to init a wl_display in the
interface. We can just initialize the wl_display generically,
depending on the renderer capabilities.
2021-07-22 14:10:26 -04:00
Simon Ser 5544973814 render/gles2: disable blending opportunistically
We don't always need to enable blending: when the texture doesn't
have alpha or when the color is opaque, we can disable it.
2021-07-12 09:16:09 -04:00
Simon Ser 9dba176e8d render/gles2: set has_alpha for DMA-BUFs
Use our internal pixel format table to figure out whether an
imported DMA-BUF has alpha.
2021-07-12 09:16:09 -04:00
Simon Ser 9b70eab194 render/gles2: rename wlr_egl.exts to better match Khronos
Khronos refers to extensions with their namespace as a prefix in
uppercase. Change our naming to align with Khronos conventions.
This also makes grepping easier.
2021-07-12 09:13:49 -04:00
Simon Ser 4c51a0f6eb render/egl: rename wlr_egl.exts to better match Khronos
Khronos refers to extensions with their namespace as a prefix in
uppercase. Change our naming to align with Khronos conventions.
This also makes grepping easier.
2021-07-12 09:13:49 -04:00
Vyivel a362d21d6b render/pixman: fix texture_is_opaque()
A texture is opaque when it does *not* have alpha.

Fixes https://github.com/swaywm/wlroots/issues/2907
2021-07-09 08:23:45 +02:00
Simon Zeni e192d87731 move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
Simon Ser 8a4957570f render/egl: remove EGL_WL_bind_wayland_display support
Our GLES2 renderer doesn't use it anymore, so we can drop it.
2021-07-05 11:13:41 -04:00
Simon Ser e5b5592a95 render: remove wl_drm support from wlr_renderer
Everything needs to go through the unified wlr_buffer interface
now.

If necessary, there are two ways support for
EGL_WL_bind_wayland_display could be restored by compositors:

- Either by using GBM to convert back EGL Wayland buffers to
  DMA-BUFs, then wrap the DMA-BUF into a wlr_buffer.
- Or by wrapping the EGL Wayland buffer into a special wlr_buffer
  that doesn't implement any wlr_buffer_impl hook, and special-case
  that buffer type in the renderer.
2021-07-05 11:13:41 -04:00
Simon Ser 4e07d4cbf9 render/gles2: use wlr_drm for wl_drm implementation
This allows use to remove all of our special wl_drm support code.
2021-07-05 11:13:41 -04:00
Simon Ser a38baec1f8 buffer: make enum wlr_buffer_cap public
Custom backends and renderers need to implement
wlr_backend_impl.get_buffer_caps and
wlr_renderer_impl.get_render_buffer_caps. They can't if enum
wlr_buffer_cap isn't made public.
2021-07-01 16:40:19 -04:00
Simon Ser 29be2d47e4 render: drop wlr_renderer_impl.texture_from_dmabuf 2021-07-01 14:57:52 -04:00
Simon Ser 7ad44051a2 render: use wlr_dmabuf_buffer in wlr_texture_from_dmabuf 2021-07-01 14:57:52 -04:00
Simon Ser 18adb43a44 render: drop wlr_renderer_impl.texture_from_pixels 2021-07-01 14:57:52 -04:00
Simon Ser 29c8df7e0a render: use wlr_readonly_data_buffer in wlr_texture_from_pixels 2021-07-01 14:57:52 -04:00
Simon Ser 1db976cecb render/egl: replace wlr_egl_create with wlr_egl_create_with_drm_fd
We never create an EGL context with the platform set to something
other than EGL_PLATFORM_GBM_KHR. Let's simplify wlr_egl_create by
taking a DRM FD instead of a (platform, remote_display) tuple.

This hides the internal details of creating an EGL context for a
specific device. This will allow us to transparently use the device
platform [1] when the time comes.

[1]: https://github.com/swaywm/wlroots/pull/2671
2021-06-30 14:02:26 -04:00
Simon Ser a2419eb4ea render/egl: make most functions private
The wlr_egl functions are mostly used internally by the GLES2
renderer. Let's reduce our API surface a bit by hiding them. If
there are good use-cases for one of these, we can always make them
public again.

The functions mutating the current EGL context are not made private
because e.g. Wayfire uses them.
2021-06-24 13:53:05 -04:00
zccrs 3c03639cd5 render: add get native paint target of renderer
Add wlr_pixman_buffer_get_current_image for wlr_pixman_renderer.
Add wlr_gles2_buffer_get_current_fbo for wlr_gles2_renderer.

Allow get the FBO/pixman_image_t, the compositor can be add some
action for FBO(for eg, attach a depth buffer), or without pixman
render to pixman_image_t(for eg, use QPainter of Qt instead of pixman).
2021-06-19 10:04:35 +02:00