Commit Graph

26 Commits

Author SHA1 Message Date
Biswapriyo Nath dd2061b073 render/vulkan: Fix clang compiler error in 32 bit ARM Android
This adds proper calling convention attribute for callbacks used in vulkan
and fixes the following compiler error.

../src/render/vulkan/vulkan.c:175:22: error: incompatible function pointer types
initializing 'PFN_vkDebugUtilsMessengerCallbackEXT' (aka 'unsigned int (*)
(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct
VkDebugUtilsMessengerCallbackDataEXT *, void *) __attribute__((pcs("aapcs-vfp")))')
with an expression of type 'VkBool32 (*)(VkDebugUtilsMessageSeverityFlagBitsEXT,
VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *, void *)'
(aka 'unsigned int (*)(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int,
const struct VkDebugUtilsMessengerCallbackDataEXT *, void *)')
[-Wincompatible-function-pointer-types]
    .pfnUserCallback = &debug_callback,
                       ^~~~~~~~~~~~~~~
2024-04-10 14:03:38 +00:00
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Manuel Stoeckl fd4548bb93 render/vulkan: detect which _UNORM formats support _SRGB views 2023-12-04 15:13:31 +00:00
eri 3232697252 render/vulkan: use VK_KHR_global_priority
References: #3386
2023-10-26 16:17:57 +00:00
Simon Ser d7bebb0a4c render/vulkan: drop unnecessary comments
Some comments in here are noise.
2023-05-22 18:53:15 +02: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 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 99134c26b8 render: stop pulling <wlr/backend.h>
Let's just forward-declare struct wlr_backend instead.

We need to fixup the Vulkan renderer: it needs makedev(), which
got included by chance via <wlr/backend.h> → <wlr/backend/session.h>
→ <libudev.h>.
2022-11-24 21:50:28 +00:00
Simon 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 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
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
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 bca60c4eec render/vulkan: improve format logging 2022-09-14 12:13:48 +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
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
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