Commit Graph

799 Commits

Author SHA1 Message Date
Alexander Orzechowski 340700cb70 wlr_drm_format: Change wlr_drm_format_dup to copy 2023-05-11 18:24:43 +02:00
Alexander Orzechowski 099a147439 wlr_drm_format: Change wlr_drm_format_create to init 2023-05-11 18:24:40 +02:00
Alexander Orzechowski e427e019c4 wlr_drm_format: Don't take double pointer in wlr_drm_format_add 2023-05-11 03:51:01 -04:00
Alexander Orzechowski e6879616e7 wlr_drm_format: Make structure constant length
Don't store modifiers as part of the struct.
2023-05-11 03:51:01 -04:00
Alexander Orzechowski b45396c790 wlr_drm_format: Introduce drm_format_finish 2023-05-11 03:51:01 -04:00
Simon Ser e353c5c631 render/vulkan: enable NV12 on big-endian
This format doesn't change its layout on big endian because it's
not packed and has 8-bit channels.
2023-05-11 07:25:32 +00:00
Simon Ser 095a63a11c render/vulkan: improve logging when creating texture
Remove debug logs when a texture is created, since this happens
pretty often. Use drmGetFormatName() and drmGetFormatModifierName()
to log DRM formats and modifiers.
2023-05-09 12:39:20 +02:00
Manuel Stoeckl e6fc5d1e49 render/vulkan: increase next descriptor pool size
This ensures that the pool sizes grow exponentially, making the number
of pools needed logarithmic in the number of descriptors, instead of
linear. Since the first pool's size is 256, this change only has an
effect when the compositor creates a large number of textures.
2023-05-06 18:16:45 +00:00
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
Simon Ser 403eac51c4 render/vulkan: fix code style for function brackets 2023-05-04 13:31:29 +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 6b7d1d732a render/pixman: fix scaling in render_pass_add_texture()
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3642
Fixes: 6830bfc17f ("render/pixman: implement render pass API")
2023-05-02 15:49:17 +00: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 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 d795824346 render/vulkan: fix signedness of strcmp() return value
strcmp() returns a signed integer.
2023-04-19 15:29:53 +02:00
Simon Ser 62e60ba889 render/vulkan: use initializer in vulkan_change_layout_queue() 2023-04-19 15:29:26 +02:00
Simon Ser 74e8fd8a9a render/vulkan: remove extra newline 2023-04-19 15:29:11 +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
Manuel Stoeckl 40dde59475 render/gles2: use byte-aligned rows for glReadPixels
Setting the GLESv2 parameter GL_PACK_ALIGNMENT to 1 ensures that the
stride of the glReadPixels output matches the value computed in
`pack_stride`. Since the default value of GL_PACK_ALIGNMENT is 4, this
does not make a difference under normal use; but without this patch
the stride can be incorrect; for example, with RGB565 buffers and
screenshots of regions with odd width.
2023-04-12 14:04:25 +00:00
Simon Ser 59d2743c0c render/vulkan: avoid double-close on sync_file FD after semaphore import
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3610
2023-03-26 07:19:01 +00:00
Brett Ernst 7d9938c957 drm_format_set: fix realloc size 2023-03-16 18:13:11 -07: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
Jan Beich 59acc69737 vulkan: silence -Wint-conversion on 32-bit architectures
render/vulkan/renderer.c:388:70: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'VkFence' (aka 'unsigned long long') [-Werror,-Wint-conversion]
        VkResult res = vkQueueSubmit(renderer->dev->queue, 1, &submit_info, NULL);
                                                                            ^~~~
render/vulkan/renderer.c:1141:81: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'VkFence' (aka 'unsigned long long') [-Werror,-Wint-conversion]
        VkResult res = vkQueueSubmit(renderer->dev->queue, submit_count, submit_infos, NULL);
                                                                                       ^~~~
/usr/include/sys/_null.h:34:14: note: expanded from macro 'NULL'
 #define NULL    ((void *)0)
                 ^~~~~~~~~~~
/usr/local/include/vulkan/vulkan_core.h:4054:49: note: passing argument to parameter 'fence' here
    VkFence                                     fence);
                                                ^

Fixes: a8a194d695 ("render/vulkan: switch to timeline semaphores")
2023-02-24 16:41:40 +00:00
Simon Ser 8619ffab21 swapchain: remove allocator listener on destroy
Past that point the wlr_allocator is gone and the listeners are
invalidated.
2023-02-24 00:07:41 +01: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 Zeni 782b5e6565 Revert "render/egl: skip incompatible EGL devices"
Reverts commit c73e20628a.

This caused a regression in the GLES2 renderer because `egl->exts.EXT_device_drm` is set in
`egl_init_display()`, which is invoked after `get_egl_device_from_drm_fd()`. So the function will
always return `EGL_NO_DEVICE_EXT`.
2023-02-18 11:49:51 -05:00
Eric Engestrom c73e20628a render/egl: skip incompatible EGL devices
Without EGL_EXT_device_drm, eglQueryDeviceStringEXT(EGL_DRM_DEVICE_FILE_EXT) further below is invalid.
2023-02-16 19:43:06 +00:00
Simon Ser 677a3f2f88 render/gles2: default to highp if available
The spec [1] says that the maximum value for a mediump float
is at least 2¹⁴ in section 4.5.2. However, when using a 4k
resolution texture coordinates will exceed this value. This causes
issues on drivers which implement mediump as a 16-bit [2].

Switch to highp. There's a twist: on GLES2, support for highp is
optional. So we need to guard it with cute GL_FRAGMENT_PRECISION_HIGH
ifdefs.

[1]: https://registry.khronos.org/OpenGL/specs/es/2.0/GLSL_ES_Specification_1.00.pdf
[2]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21082
2023-02-02 22:54:13 +01:00
Simon Ser 0534d12b28 render/gles2: use correct type for shader type
Doesn't matter a lot, but let's try to be consistent with the
GL headers.
2023-02-02 22:42:42 +01:00
Simon Ser 377668aaf6 render/vulkan: check that requested size is smaller than max
Fail with a clearer error when the requested size is too large.
Without this, we allocate a buffer with a size smaller than what
was requested.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3975
2023-01-19 18:50:59 +00:00
Brett Ernst 1ba322e9ff vulkan: increase max stage size to support large buffers 2023-01-18 19:45:26 -08:00
llyyr 10e16db738 render/vulkan: use correct source offset in read_pixels 2023-01-18 06:56:49 +05:30
Kirill Primak faa31d123f render/vulkan: always finish buffer addon on texture destroy 2022-12-22 12:42:08 +03:00
Kirill Primak 0702eb9219 render/vulkan: remove NULL renderer check on texture destroy 2022-12-22 11:45:12 +03:00
Simon Ser f12cdc53f3 render/egl: stop advertising render support for external-only formats
Some formats like YUV are only supported by Mesa for sampling, not
for rendering. However we always unconditionally added the INVALID
modifier to the list of render formats.

Check whether all modifiers are external-only, in that case, don't
add INVALID to the list of render formats.
2022-12-13 16:43:22 +00:00
Simon Ser 80074d95fb egl: consistently use EGLint for DMA-BUF format
EGL_EXT_image_dma_buf_import_modifiers [1] uses EGLint to carry
formats. We were casting it to int (which may not be the same
width) and uint32_t (which may change the value).

Instead, use EGLint everywhere.

[1]: https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
2022-12-12 23:08:48 +01:00
Simon Ser 32fc23a383 render/pixman: skip mask for opaque texture rendering 2022-12-08 16:53:14 +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 cb6b1193c8 render/allocator/gbm: use internal_config
Removes a project argument.
2022-12-06 22:39:45 +00:00
Simon Ser 1bd0ba3949 render: simplify renderer_autocreate_with_drm_fd()
Use early returns to remove the !renderer checks.
2022-12-06 14:58:30 +00: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
Simon Ser a37a22e344 render/vulkan: use initializers for VkSubmitInfo 2022-12-03 09:53:32 +01:00
Simon Ser 666c45bb29 render/vulkan: remove stage_cb conditional
We always have a stage_cb at this point.
2022-12-03 09:39:12 +01:00
Simon Ser dd5be430b4 render/vulkan: remove pre_cb in vulkan_end()
pre_cb was an alias for stage_cb->vk. Let's just use a single
variable instead.

Additionally, early return when vulkan_record_stage_cb() fails.
We were crashing in vkCmdPipelineBarrier() if that happened.
2022-12-03 09:36:18 +01:00
Simon Ser 27e057319a render/vulkan: fix vkCmdClearAttachments validation error
Skip clears with an empty scissor.

Fixes the following validation error:

    00:00:09.734 [wlr] [render/vulkan/vulkan.c:61] Validation Error: [ VUID-vkCmdClearAttachments-rect-02682 ] Object 0: handle = 0x62600001b100, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0xadbd476f | CmdClearAttachments(): pRects[0].rect.extent.width is zero. The Vulkan spec states: The rect member of each element of pRects must have an extent.width greater than 0 (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdClearAttachments-rect-02682) (VUID-vkCmdClearAttachments-rect-02682)
2022-12-03 09:30:30 +01:00
Simon Ser d6ff20268b render/vulkan: fix comma 2022-12-02 23:26:34 +01:00
Simon Ser 56326c7998 render/vulkan: use initializers for VkImageMemoryBarrier 2022-12-02 23:26:01 +01:00
Simon Ser 79aea58834 render/vulkan: fix missing pSignalSemaphores for stage CB
We were filling VkTimelineSemaphoreSubmitInfoKHR.pSignalSemaphoreValues,
but we were missing VkSubmitInfo.pSignalSemaphores.

This was causing VkTimelineSemaphoreSubmitInfoKHR.pSignalSemaphoreValues
to be ignored. By chance, the render command buffer was using the
next timeline point, so we were waiting for that instead.
2022-12-02 19:28:13 +00:00
Simon Ser 47a038c90e render/vulkan: move VkDescriptorSetAllocateInfo down
Move it down, right before it's used.
2022-12-02 18:28:55 +00:00
Simon Zeni 4b3bbb0c4f render/drm_format_set: fill dst in wlr_drm_format_set_copy 2022-12-02 11:47:47 -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 b4ad4671dc render/vulkan: check for barrier array alloc failure 2022-12-02 15:14:27 +00:00
Simon Ser bc7f8de842 render/vulkan: improve message on format prop error
Use a more appropriate message on
vkGetPhysicalDeviceImageFormatProperties2() error.
2022-12-02 16:10:42 +01:00
Simon Ser 338a9616bd render/vulkan: simplify vulkan_format_props_query() 2022-12-02 16:10:41 +01:00
Simon Ser a3874cac6c render/vulkan: extract DMA-BUF format query to separate function 2022-12-02 16:09:58 +01:00
Simon Ser c9b378d21a render/drm-format-set: add wlr_drm_format_set_copy() 2022-12-02 14:27:07 +00:00
Simon Ser 21c4516838 render/vulkan: add 64-bit UNORM and SFLOAT formats 2022-12-02 10:36:36 +01:00
Simon Ser 9f938f7f2a render/vulkan: add more packed formats 2022-12-02 10:35:45 +01:00
Simon Ser 171c9081d1 render/vulkan: add more 8 bits per channel formats 2022-12-02 10:28:52 +01:00
Simon Ser e31c741d2a render/pixel-format: drop unnecessary fields in the table
DRM_FORMAT_INVALID is zero. Let's just omit the fields to make the
table more readable.
2022-12-02 10:28:52 +01:00
Simon Ser e97ce5f459 render/pixel-format: add various new formats 2022-12-02 10:24:00 +01:00
Simon Ser ad165f7daf render/vulkan: explain format mapping with DRM 2022-12-02 10:24:00 +01: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
Alexander Orzechowski db0e962368 wlr_texture: Expose owning renderer 2022-12-01 04:41:43 -05: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
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
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
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
Simon Ser 98f2efde98 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-11-26 16:40:53 +00:00
Simon Ser d5df8d5cbf render/egl: always add LINEAR to supported modifiers 2021-11-26 16:40:53 +00:00
Simon Ser affe9eda57 Require INVALID for implicit format modifiers
See [1] for the motivation.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-11-26 16:40:53 +00:00
Simon Ser d78cb808b1 render/drm_format_set: add wlr_drm_format_has 2021-11-26 16:40:53 +00:00
Simon Ser 2e33139ef7 render: introduce WLR_RENDER_DRM_DEVICE
This env var allows to override the DRM node used by the GLES2 and
Vulkan renderers. It's especially useful to select a DRM node when
running with the headless backend.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/2656
2021-11-25 15:12:32 +00:00
Simon Ser e4f748c6e9 render/allocator: fallback to renderer DRM FD in autocreate
If the backend doesn't have a DRM FD, fallback to the renderer's.
This accomodates for the situation where the headless backend hasn't
picked a DRM FD in particular, but the renderer has picked one.
2021-11-25 15:12:32 +00:00
Simon Ser bf57825560 render: pick DRM FD in autocreate
If the backend hasn't picked a DRM FD but supports DMA-BUF, pick
an arbitrary render node. This will allow removing the DRM device
selection logic from the headless backend.
2021-11-25 15:12:32 +00:00
Joshua Ashton f132d66816 render/vulkan: Optimize vertex shader
This ends up being a horrible global load:

  s_getpc_b64   s[4:5]                                  // 000000000000: BE841C80
  v_add_u32     v0, s2, v0                              // 000000000004: 68000002
  v_sub_co_u32  v1, vcc, 0, v0                          // 000000000008: 34020080
  v_max_i32     v1, v0, v1                              // 00000000000C: 1A020300
  v_and_b32     v1, 3, v1                               // 000000000010: 26020283
  v_cmp_lt_i32  s[0:1], v0, 0                           // 000000000014: D0C10000 00010100
  v_sub_co_u32  v0, vcc, 0, v1                          // 00000000001C: 34000280
  v_cndmask_b32  v0, v1, v0, s[0:1]                     // 000000000020: D1000000 00020101
  v_lshlrev_b32  v1, 3, v0                              // 000000000028: 24020083
  v_mad_u32_u24  v0, v0, 8, 4                           // 00000000002C: D1C30000 02111100
  v_min_u32     v1, 32, v1                              // 000000000034: 1C0202A0
  v_min_u32     v0, 32, v0                              // 000000000038: 1C0000A0
  s_getpc_b64   s[0:1]                                  // 00000000003C: BE801C00
  s_add_u32     s0, s0, 0x0000003c                      // 000000000040: 8000FF00 0000003C
  s_addc_u32    s1, s1, 0                               // 000000000048: 82018001
  global_load_dword  v1, v[1:2], s[0:1]                 // 00000000004C: DC508000 01000001
  global_load_dword  v0, v[0:1], s[0:1]                 // 000000000054: DC508000 00000000
  v_mov_b32     v2, 0                                   // 00000000005C: 7E040280
  v_mov_b32     v3, 1.0                                 // 000000000060: 7E0602F2
  s_waitcnt     vmcnt(0)                                // 000000000064: BF8C0F70
  exp           pos0, v1, v0, v2, v3 done               // 000000000068: C40008CF 03020001
  exp           param0, off, off, off, off              // 000000000070: C4000200 00000000
  s_endpgm                                              // 000000000078: BF810000
  v_cndmask_b32  v0, s0, v0, vcc                        // 00000000007C: 00000000
  v_cndmask_b32  v0, s0, v0, vcc                        // 000000000080: 00000000
  v_add_f16     v192, s0, v0                            // 000000000084: 3F800000
  v_cndmask_b32  v0, s0, v0, vcc                        // 000000000088: 00000000
  v_add_f16     v192, s0, v0                            // 00000000008C: 3F800000
  v_add_f16     v192, s0, v0                            // 000000000090: 3F800000
  v_cndmask_b32  v0, s0, v0, vcc                        // 000000000094: 00000000
  v_add_f16     v192, s0, v0                            // 000000000098: 3F800000
  v_cndmask_b32  v0, s0, v0, vcc                        // 00000000009C: 00000000

With some bit magic, we can get something much nicer:

  v_add_u32     v0, s2, v0                              // 000000000000: 68000002
  v_add_u32     v1, 1, v0                               // 000000000004: 68020081
  v_and_b32     v1, 2, v1                               // 000000000008: 26020282
  v_cvt_f32_i32  v1, v1                                 // 00000000000C: 7E020B01
  v_mul_f32     v1, 0.5, v1                             // 000000000010: 0A0202F0
  v_and_b32     v0, 2, v0                               // 000000000014: 26000082
  v_cvt_f32_i32  v0, v0                                 // 000000000018: 7E000B00
  v_mul_f32     v0, 0.5, v0                             // 00000000001C: 0A0000F0
  v_mov_b32     v2, 0                                   // 000000000020: 7E040280
  v_mov_b32     v3, 1.0                                 // 000000000024: 7E0602F2
  exp           pos0, v1, v0, v2, v3 done               // 000000000028: C40008CF 03020001
  exp           param0, off, off, off, off              // 000000000030: C4000200 00000000
  s_endpgm                                              // 000000000038: BF810000

The above output was based on just shoving it in ShaderPlayground -- I was not able to use pipeline feedback as I was unable to get RenderDoc working due to the EXT_physical_device_drm requirement.

I additionally considered using >> 1 instead of * 0.5, but AMD has dedicated modifiers to merge a * 0.5, * 2.0, etc in a single instruction. (Albeit, not taken advantage of in the code above, but might with ACO)

Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-11-23 15:46:24 +00:00
Simon Ser 5332935afc render/vulkan: quiet glslangValidator
This suppresses the output filename printed to stdout. Errors and
warnings should still be printed to stderr as usual.
2021-11-23 15:38:56 +00:00
Demi Marie Obenour b5d4bc3c62 Improve wlr_drm_format documentation
A wlroots user can easily get confused and think that `cap` refers to
wlroots buffer capabilities, not array capacity.
2021-11-17 16:35:20 +00:00
Simon Ser a04cfca4da Remove support for DMA-BUF flags
They are never used in practice, which makes all of our flag
handling effectively dead code. Also, APIs such as KMS don't
provide a good way to deal with the flags. Let's just fail the
DMA-BUF import when clients provide flags.
2021-11-17 16:12:59 +00:00
Cole Mickens 3a685b10b6
egl: use alts for EGL_EXT_device_enum, if missing 2021-11-09 16:47:32 -08:00
Simon Zeni 02a1ae169e render/allocator: make wlr_allocator part of the public API 2021-11-09 15:26:36 +00:00
Jan Beich 760e166578 render: completely disable gles2 if requested but libEGL is found
For `required` to disable search the value needs to be of `feature` type.
Checking `gles2` via `in` keyword returns a `bool` but `required: false`
makes the dependency optional instead of disabled.
2021-11-02 09:36:38 +00:00
Haelwenn (lanodan) Monnier 6666604f17 render/egl.c: Fix memory leaks in egl_create
calloc is moved to right before egl is called to avoid requiring to free()
unused memory.

Found via scan-build
2021-10-27 07:30:36 -06:00
Haelwenn (lanodan) Monnier 4fb652c27f render/pixman/renderer.c: Fix memory-leak in create_buffer
Found via scan-build
2021-10-27 07:30:36 -06:00
Simon Ser 36cf387427 render/vulkan: check vulkan-headers dependency
There's no pkg-config file we can check for sadly, so check
vulkan/vulkan.h as a fallback.

Closes: https://github.com/swaywm/wlroots/issues/3272
2021-10-19 06:51:14 -06:00
Joshua Ashton b62ce3c3c8 render/vulkan: Use image view swizzles instead of shader hack
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-18 15:57:46 +02:00