Commit Graph

617 Commits

Author SHA1 Message Date
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
Manuel Stoeckl b97ef59393 render/vulkan: update shm texture data in one batch 2022-11-21 17:55:46 -05:00
Simon Ser fdb24d19ca allocator/drm_dumb: use libdrm dumb buffer helpers
References: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/272
2022-11-17 08:05:55 +00:00
Simon Ser da3616d183 render: use wlr_shm in wlr_renderer_init_wl_shm() 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
Simon Ser d6e2ab5145 render/vulkan: detect device loss 2022-11-15 15:50:19 +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
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
Simon Ser 6baf045590 render/texture: constify wlr_texture_update_from_buffer() 2022-11-11 23:11:17 +00:00
Simon Zeni f3ba14e491 render/vulkan: remove hardcoded validation layers
Users should use the VK_INSTANCE_LAYERS env var to set layers at runtime
2022-11-11 22:56:37 +00:00
Simon Zeni ed71915742 render/egl: fix uninitialized pointers in init_dmabuf_formats
`modifiers` and `external_only` are never initialized, and free'd later. This
commit explicitly initializes them to NULL to prevent segfaults on `free()`
2022-11-11 20:22:23 +00:00
Simon Ser e1ba64c4b7 render/vulkan: use initializer for VkBufferImageCopy
Missed that one it seems.
2022-11-11 19:26:48 +00:00
Simon Ser d112c2d922 render/vulkan: wait for device to become idle in vulkan_destroy()
It's not safe to destroy any resources which might still be in-use
by the GPU. Wait for any asynchronous tasks to complete before
destroying everything.
2022-11-11 19:18:04 +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
Simon Ser f92d1499cd render/vulkan: add helper to load command function pointer
If NULL is returned by vkGetDeviceProcAddr(), either the driver
is buggy, either the wlroots code is buggy. For a valid device and
command name, drivers are not allowed to return NULL per the spec.

This mirrors what the GLES2 renderer does in load_gl_proc().
2022-11-11 19:18:04 +00:00
Kirill Primak c284700deb Revert "render/pixman: apply source image cropping"
This reverts commit 9fefeb69d6.

It doesn't really crop anything, actually.
2022-11-08 18:24:44 +03: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
Kirill Primak 9fefeb69d6 render/pixman: apply source image cropping 2022-11-08 09:17:04 +00: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 9a5cc36818 render/vulkan: simplify texture VkPipelineShaderStageCreateInfo
I simplified the quad VkPipelineShaderStageCreateInfo in [1], but
missed the one for texture.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3823
2022-11-07 14:24:39 +01:00
Simon Ser cfb768aab9 render/vulkan: use struct initializers
Instead of filling the fields one by one, use a struct initializer.
This avoids repeating the name of the variable and is more
consistent with the wlroots code style.
2022-11-06 14:20:34 +00:00
Simon Ser 7f5180af77 render/vulkan: simplify extension checks
find_extensions() is clunky to use when checking only a single
extension, and it's surprising that it returns NULL on success.

Simplify by replacing it with a check_extension() function which
just checks whether a single extension is in the list.
2022-11-06 14:18:13 +00:00
Simon Ser 2ac2835a1f render/vulkan: remove exts arg from vulkan_instance_create() 2022-11-04 14:12:38 +01:00
David96 7a42392da2 render/vulkan: add caching to vulkan_read_pixels 2022-11-04 09:13:48 +00:00
Simon Ser 4d04144b92 render/gles2: de-duplicate vertex shaders
The vertex shaders for quads and textures are identical.
2022-10-28 13:49:03 +02:00
Simon Ser d69018c195 render/gles2: move color uniform from quad.vert to quad.frag
We have no use for a v_color varying. We can use the uniform
directly from the fragment shader without getting the vertex shader
involved.
2022-10-28 13:49:03 +02:00
Simon Ser a75f9be2e8 render/gles2: move shaders to individual files
Instead of having a C file with strings for each shader, move each
shader into its own file. Use a small POSIX shell script to convert
the files into C strings (can't wait for C23 #embed...).

The benefits from this are:

- Improved readability and syntax highlighting.
- Line numbers in shader compiler errors are easier to make sense of.
- Consistency with the Vulkan renderer.
- Shaders will become more complicated as we add color management
  features.
2022-10-28 11:46:06 +00:00
Simon Ser bc416ed752 render/gles2: log error on shader compilation failure 2022-10-27 16:43:03 +02:00
Simon Ser 6d90518c97 egl: add WLR_EGL_NO_MODIFIERS
Same as WLR_DRM_NO_MODIFIERS but for EGL. For debugging purposes
mostly.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3451
2022-10-21 09:52:18 +02:00
Simon Ser 9e5ad7a845 render/vulkan: add missing entries in vulkan_strerror()
And update the sort order to follow Khronos' <vulkan/vulkan_core.h>.
2022-10-18 16:57:00 +02:00
Gentaiii 11192e6930 Fixed false allocation failed 2022-10-11 09:36:36 +00:00
Simon Ser 221ee83d44 render/vulkan: drop wlr_vk_instance.extensions
This was unused. Even if it was, it'd be better to have bool fields
instead.
2022-10-10 14:39:47 +02:00
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
John Lindgren ab8341975e render/vulkan: Fix type-punned pointer warning/error 2022-10-09 12:07:57 -04: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
Simon Ser 6832ae14aa render: drop wlr_renderer_read_pixels() flags
These are unused.
2022-10-04 09:15:19 +02: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
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 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 bcc6a5832f render: drop trailing whitespace 2022-09-23 21:48:03 +02:00
Simon Ser 8d6d2101bc render/vulkan: add error handling for vulkan_find_mem_type()
The function returns -1 if it doesn't find a suitable memory type.
2022-09-19 10:33:29 +00:00
Simon Ser 5206cea566 render/egl: add support for EGL_KHR_display_reference
See the spec at [1]. tl;dr EGL has terrible defaults: eglTerminate()
may have side-effects on completely unrelated EGLDisplay objects.
This extension allows us to opt-in to get the sane behavior:
eglTerminate() only free's our own EGLDisplay without affecting
others.

[1]: https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_display_reference.txt
2022-09-19 10:04:47 +00:00
Simon Ser bca60c4eec render/vulkan: improve format logging 2022-09-14 12:13:48 +02:00
Simon Ser 80cb89acee render/allocator/gbm: log human-readable format and modifier 2022-09-14 12:13:17 +02:00
Simon Ser 4ad79d05ca render/egl: improve DMA-BUF format/modifier logging
For each format and modifier, log supported usage. Log a
human-readable format/modifier string.
2022-09-14 12:13:17 +02:00
Simon Ser 8026953df7 render/vulkan: remove unnecessary casts
No need to go back to the generic wlr_renderer/wlr_texture when
passing a Vulkan renderer/texture to an internal function.
2022-09-07 14:00:46 +00:00
Simon Ser 30769723c1 render/vulkan: fix format features check for shm textures
We were checking whether any of the features was supported. We need
to check if all of them are.

This makes the check consistent with query_modifier_support() above.
2022-09-07 15:46:38 +02:00
Simon Ser ed018a3ee2 render/vulkan: drop wlr_vk_device.extensions
We don't need to store the list of enabled extensions.

While at it, rename variables to be less confusing.
2022-09-07 14:41:40 +02:00
Simon Ser e19007dede render/vulkan: drop ext params from vulkan_device_create()
These are unused.
2022-09-07 14:39:58 +02:00
fakechen 30fafe4f4a egl: modify egl_init_display function definition
I think the second parameter of the function should be void* instead of
void **, because we use it as a right value in the function.

Signed-off-by: fakechen <chenzigui@kylinos.cn>
Signed-off-by: sunzg <sunzhigang1@kylinos.cn>
2022-09-07 06:27:09 +00:00
Alexander Orzechowski 9b091f528e pixel_format: RGBA4444 and RGBA5551 have alpha components 2022-09-06 18:48:41 -04:00
Bernardo Meurer eee0f5e71f
render/vulkan: fix memory type detection
From a comment by emersion:

> There is a logic error here: we pass 0xFFFFFFFF to vulkan_find_mem_type, which
> returns an index, and then we logical-and that with mem_reqs.memoryTypeBits.
> Instead we should pass mem_reqs.memoryTypeBits to vulkan_find_mem_type and use
> the result for the memoryTypeIndex field directly. Ideally checking for errors
> (-1 return value) in case no memory type is suitable.

Closes: #3470
2022-08-28 16:32:09 -03:00
Alexander Orzechowski 8bd7170fd9 Use env helpers 2022-08-22 10:18:52 -04:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser 98cf38601f render: replace wlr_texture_write_pixels with update_from_buffer
This lets the renderer handle the wlr_buffer directly, just like it
does in texture_from_buffer. This also allows the renderer to batch
the rectangle updates, and update more than the damage region if
desirable (e.g. too many rects), so can be more efficient.
2022-08-12 08:41:32 +00:00
Manuel Stoeckl 972a5cdf7a render/gles2: simplify alpha depth check
GL_ALPHA_BITS is the number of bits of the alpha channel of the
currently bound frame buffer's color buffer -- which is precisely
renderer->current_buffer->rbo . Thus, instead of binding the color
buffer and checking its properties, we can query the already bound
frame buffer.

Note that GL_IMPLEMENTATION_COLOR_READ_{FORMAT,TYPE} are also
properties of frame buffer's color buffer.
2022-07-20 20:02:46 -04:00
Simon Ser e26c3a02df build: fix enabled GBM when allocators=auto and auto_features=disabled 2022-06-29 11:32:06 +02:00
Simon Ser c20468cfa2 render: use internal_features to indicate EGL support
Instead of checking whether the wlr_egl dependencies are available
in the GLES2 code, introduce internal_features['egl'] and check
that field.

When updating the EGL dependency list, we no longer need to update
the GLES2 logic.
2022-06-24 07:20:42 +02:00
Simon Ser b9d55b8769 render/gles2: check GBM is found
The GLES2 renderer depends on EGL, which depends on GBM for device
selection.
2022-06-24 07:16:41 +02:00
Simon Ser 29291cb47c render/texture: drop wlr_texture_is_opaque
Whether a texture is opaque or not doesn't depend on the renderer
at all, it just depends on the source buffer. Instead of forcing
all renderers to implement wlr_texture_impl.is_opaque, let's move
this in common code and use the wlr_buffer format to know whether
a texture will be opaque.
2022-06-16 14:43:24 +02:00
bi4k8 369c6525d7 render/egl: don't leak memory on error return 2022-06-12 06:55:06 +00:00
bi4k8 f295aff762 Add missing & 2022-06-11 20:41:16 +00:00
bi4k8 35d1bcff6f render/vulkan/pixel_format: do not leak props->...
`vulkan_format_props_query` calls `query_modifier_support` which
initializes fields of `props` with allocated memory. this memory is
leaked if `query_modifier_support` does not find a supported format
and shmtex is not supported, as in this case `add_fmt_props` ends
up being false and the allocated fields of `props` are never freed.
2022-06-11 20:25:35 +00:00
Simon Ser 96b594110d matrix: remove wlr_matrix_projection()
69477051cc ("matrix: deprecate wlr_matrix_projection") marked it
as deprecated. 1 year later, we can now remove it from our public
API.
2022-06-08 19:27:36 +00:00
Simon Ser c2e046022f render/gles2: simplify flipped projection
Instead of computing the projection, then flipping, just provide
the correct transform to wlr_matrix_projection().
2022-06-08 19:27:36 +00:00
Alexander Orzechowski bd7b42eb9f dmabuf: Don't leak file descriptors on error path 2022-06-06 00:50:41 -04:00
Simon Ser 99f63b03e7 Remove remaining wl_signal_emit calls
Replace them with wlr_signal_emit_safe, which correctly handles
cases where a listener removes another listener.

Reported-by: Isaac Freund <ifreund@ifreund.xyz>
2022-06-05 10:36:11 +00:00
Simon Ser bb2946f737 build: make GBM optional
Now that the DRM backend no longer depends on GBM, we can make it
optional. The GLES2 renderer still depends on it because of our EGL
device selection.

This is useful for compositors with their own renderers, and for
compositors using the Vulkan renderer.
2022-05-30 13:30:08 +00:00
Simon Ser 452a8ec940 render/egl: add wlr_egl_get_{context,display}
This allows compositors to integrate with the wlroots GLES2
renderer, if they need to perform custom GL rendering.
2022-05-25 18:17:41 +00:00
Manuel Stoeckl 7ad67e0f1d render/gles: add support for some 16-bpc unsigned shm formats
These formats require EXT_texture_norm16, which in turn needs OpenGL
ES 3.1. The EXT_texture_norm16 extension does not support passing
gl_internalformat = GL_RGBA to glTexImage2D, as can be done for
formats available in OpenGL ES 2.0, so this commit adds a field to
wlr_gles2_pixel_format to provide a more specific internalformat
parameter to glTexImage2D.
2022-05-07 16:25:38 +00:00
zccrs 48c811ffb6 render/vulkan: fix undefined reference to wlr_texture_is_vk
Added the  implement of wlr_texture_is_vk.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3419
2022-05-01 14:46:18 +08:00
Simon Ser 6c350799b2 Zero-initialize structs in init functions
Ensures there is no field left to its previous undefined value after
calling an init function.
2022-04-28 10:09:50 +02:00
Dean 104060fec5 Free drmDevice in get_egl_device_from_drm_fd() 2022-03-14 05:55:50 +00:00
Samuel Čavoj 5c17452ae0
Pass O_CLOEXEC to drmModeCreateLease calls
The lease_fd is currently being leaked to child processes

Link: https://github.com/swaywm/sway/issues/4286#issuecomment-1065987957
2022-03-13 13:28:48 +01:00
Simon Ser 39b68ea47a buffer: extract interface to separate header
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3389
2022-03-03 15:39:05 +01:00
Roman Gilg 17a289e36e render: allow texture creation while rendering
This removes an artificial limitation in form of an assert that disallowed the
creation of textures while the renderer is rendering.

A consumer might run its own rendering pipeline and after start of the renderer
still want to create textures for internal usage.
2022-02-28 13:06:11 +01:00
Simon Ser d8d30463ac render/vulkan: log physical device driver name
This can be useful to figure out why a required feature is missing,
e.g. as in [1].

We check VK_EXT_physical_device_drm availability after printing
the driver name.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3358
2022-01-19 13:08:46 +01:00
Thomas Hebb 59b9518f07 render/gles2: don't constrain shm formats to ones that support reading
commit 44e8451cd9 ("render/gles2: hide shm formats without GL
support") added the is_gles2_pixel_format_supported() function to
render/gles2/pixel_format.c, whose stated purpose is to "check whether
the renderer has the needed GL extensions to read a given pixel format."
It then used that function to filter the pixel formats returned by
get_gles2_shm_formats().

The result of this change is that RGB formats are no longer reported for
GL drivers that don't implement EXT_read_format_bgra, even when those
formats are supported for rendering (which they have to be for
wlr_gles2_renderer_create() to succeed). This is a pretty clear
regression, since wlr_renderer_init_wl_shm() fails when either of
WL_SHM_FORMAT_ARGB8888 or WL_SHM_FORMAT_XRGB8888 are missing.

To fix the regression, change is_gles2_pixel_format_supported() to
accept all pixel formats that support rendering, regardless of whether
we can read them or not, and move the check for EXT_read_format_bgra
back into gles2_read_pixels(). (There's already a check for this
extension in gles2_preferred_read_format(), so we're not breaking any
abstraction that wasn't already broken.)

Tested on the NVIDIA 495.46 proprietary driver, which doesn't support
EXT_read_format_bgra.

Fixes: 44e8451cd9 ("render/gles2: hide shm formats without GL support")
2022-01-05 15:48:29 -08:00
nyorain 9988eb3378 vulkan: Fix imported image layout 2021-12-26 13:21:54 +01:00
Simon Ser 77d811a21b render: add wlr_renderer_init_wl_shm
This allows compositors to initialize wl_shm without initializing
other globals like linux-dmabuf.
2021-12-07 15:15:28 +01:00
Simon Ser 7201aae3d6 render/drm-format-set: add wlr_drm_format_set_intersect
This intersects two DRM format sets. This is useful for implementing
DMA-BUF feedback in compositors, see e.g. the Sway PR [1].

[1]: https://github.com/swaywm/sway/pull/6313
2021-12-03 14:42:41 +00:00
Simon Ser 1bf9676e87 render/egl: improve modifier support detection
Support for EXT_image_dma_buf_import_modifiers doesn't necessarily
indicate support for modifiers. For instance, Mesa will advertise
EXT_image_dma_buf_import_modifiers for all drivers. This is a trick
to allow EGL clients to enumerate supported formats (something
EXT_image_dma_buf_import is missing). For more information, see [1].

Add a new wlr_egl.has_modifiers flag which indicates whether
modifiers are supported. It's set to true if any
eglQueryDmaBufModifiersEXT query returned a non-empty list.

Use that flag to figure out whether the buffer modifier should be
passed to the EGL implementation on import.

[1]: https://github.com/KhronosGroup/EGL-Registry/issues/142
2021-12-02 14:21:51 +00:00
Simon Ser de0bc78319 render/pixman: advertise MOD_INVALID instead of MOD_LINEAR
The backends and allocators use INVALID, but the renderer uses
LINEAR. Running a compositor with WLR_RENDERER=pixman results in:

    00:00:00.744 [types/output/render.c:59] Failed to pick primary buffer format for output 'WL-1'
2021-12-02 14:12:14 +00:00
Simon Ser 051d1ce90e render/egl: add wlr_egl_create_with_context
This allows creating a wlr_egl from an already-existing EGL display
and context. This is useful to allow compositors to choose the exact
EGL initialization parameters.
2021-12-01 14:08:20 +01:00
Simon Ser ffd4a27714 render/egl: store IMG_context_priority in wlr_egl
The next commit will split extension lookup and context
initialization.
2021-12-01 14:03:37 +01:00