Commit Graph

54 Commits

Author SHA1 Message Date
Manuel Stoeckl d6859da3b4 render/vulkan: use _SRGB image view when possible
This is the last of a set of commits which ensures that both textures
and render buffers can be accessed through _UNORM and _SRGB image
views. While _UNORM image views are not yet used for 8-bpc image
formats, they will be needed in the future to support color transforms
for both textures and render buffers.
2023-12-04 15:13:31 +00:00
Manuel Stoeckl 566c413d8f render/vulkan: constify vulkan_format_props_find_modifier 2023-12-04 15:13:31 +00:00
Manuel Stoeckl fd4548bb93 render/vulkan: detect which _UNORM formats support _SRGB views 2023-12-04 15:13:31 +00:00
Manuel Stoeckl eab89d6c76 render/vulkan: track and use _UNORM variants of _SRGB formats
Later commits will start using _SRGB image views again,
where appropriate.
2023-12-04 15:13:31 +00:00
Alexander Orzechowski d3a339a03e renderer: Drop buffer binding 2023-11-30 20:11:50 -05:00
Alexander Orzechowski 09f16b2a9c render/vulkan: Implement texture_read_pixels 2023-11-30 19:56:54 -05:00
Simon Ser 9a0a4ce221 render/vulkan: drop current_command_buffer
This was used by the legacy rendering API. Since begin()/end()
only need to set current_render_buffer and nothing else, we can
drop all of these bits.
2023-11-28 12:56:30 +00:00
Manuel Stoeckl e0adaaffb6 render/vulkan: constrain blend to output subpass to redrawn region
This commit only applies to the render pass API.
2023-10-05 11:45:32 +00:00
Simon Ser 65bbbbbf0c render/vulkan: de-duplicate VkImageUsageFlags
The flags passed to vkCreateImage() must match the flags used when
querying formats. Make this clearer by using the same variable.
2023-09-09 23:32:28 +00:00
Alexander Orzechowski 6bd44c4fcd renderer: Introduce wlr_scale_filter_mode 2023-06-19 12:25:38 -04:00
Alexander Orzechowski 3ee0f52e09 render/vulkan: Dynamically create texture views
Now that we are dynamically creating pipeline layouts, we need separate
texture views for each pipeline layout we choose to use with a texture.
2023-06-17 21:21:35 -04:00
Alexander Orzechowski 8a387b5558 render/vulkan: Dynamically create pipeline layouts
These will happen lazily when pipelines get created.
2023-06-17 21:21:31 -04:00
Alexander Orzechowski 3623005858 render/vulkan/pipeline_key: Add blending
This will become necessary when we switch away from scissoring. For the
time being, this cleans things up a bit and allows for a trivial
blending implementation for textures when that comes.
2023-06-16 19:20:04 -04:00
Alexander Orzechowski 9d31372930 render/vulkan: Handle quad pipeline through generic pipeline path 2023-06-16 19:20:03 -04:00
Alexander Orzechowski 97fdd57eb2 render/vulkan: Dynamically handle pipeline creation for textures
If we ever wanted to handle dynamic state that requires new pipelines
such as using different texture filters those can be added here with more
ease.
2023-06-16 19:09:23 -04:00
Simon Ser 0ba3ea3bcd render/vulkan: improve error handling in render_pass_submit()
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3644
2023-06-01 10:42:56 +02:00
Simon Ser e07c77f846 render/vulkan: implement render pass API 2023-05-30 09:42:19 +00:00
Simon Ser f60b367db7 render/vulkan: drop unused vulkan_has_extension() 2023-05-26 12:25:53 +00:00
Simon Ser 42eec38ab6 render/vulkan: drop unused vulkan_change_layout_queue() 2023-05-26 12:25:53 +00:00
Simon Ser c7ae9dfaf8 render/vulkan: generalize YCbCr format support 2023-05-24 08:58:59 +00:00
Simon Ser 5ea0eb3468 render/vulkan: add vulkan_get_pipeline_layout()
Will make it easier to add more pipeline layouts for other YCbCr
formats.
2023-05-24 08:58:59 +00:00
Simon Ser fd38761676 render/vulkan: introduce struct wlr_vk_pipeline_layout
This will make it easier to create one pipeline layout (plus related
objects) per YCbCr format.
2023-05-24 08:58:59 +00:00
Manuel Stoeckl 10dd416694 render/vulkan: allow rendering to non-8-bit buffers
This is implemented by a two-subpass rendering scheme; the first
subpass draws (and blends) onto a linear R16G16B16A16_SFLOAT buffer,
while the second subpass performs linear->srgb conversion, writing
onto the actual output buffer.
2023-05-12 15:09:02 +00:00
Simon Ser b03f71fe5f render/vulkan: add support for NV12 2023-05-04 20:07:20 +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 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 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 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 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 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 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 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
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 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 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
Simon Ser 3b75ab97e2 render/vulkan: drop outdated comments 2022-11-04 14:29:54 +01: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 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 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