Commit graph

18 commits

Author SHA1 Message Date
Dennis Tsiang
4423a52816 Update clang-format rules
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I76f87648a8ddaeddb6774123d263957b845d10a1
2024-07-04 10:30:42 +01:00
Dennis Tsiang
292a3c14d7 Decouple creation, allocation and binding of images from Wayland backend
A lot of the steps involved in creating a VkImage, allocating backing
memory, and binding the VkImage to the memory do not rely specifically
on Wayland features and could be common to other WSI backends.

This commit attempts to decouple the create_and_bind_swapchain_image()
function in the wsi/wayland/swapchain.cpp from Wayland and wsialloc
specific parts, and instead move the independent parts related to
external memory management to a new external_memory class. This will
allow the independent code to be re-used in future WSI backends.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I8c13ccbbfaef0d345fcd06192e6de484dd53645f
2022-10-21 15:28:09 +00:00
Aron Virginas-Tar
e40628a135 Remove duplication of create_aliased_image_handle implementations
Signed-off-by: Aron Virginas-Tar <aron.virginas-tar@arm.com>
Change-Id: I37043259e349874a9a7eb495a0e3b939c144798f
2022-08-03 13:43:38 +00:00
Dennis Tsiang
2bc2109194 Add support for VK_EXT_image_compression_control_swapchain
Implement support for VK_EXT_image_compression_control_swapchain
for both the Wayland and the headless windowing systems.
The extension can be conditionally enabled through the new build option
BUILD_WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN. Compiling with this
option enabled requires recent Vulkan headers (1.3.213)
Note also that support in the layer is enabled conditionally to
the ICD supporting VK_EXT_image_compression_control.

Update the WSIALLOC interface to version 2 and add support to
prefer selection of a format with the highest fixed rate compression
from the formats provided. This is used to pick a fixed rate
compression when VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT is
specified during swapchain creation.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Change-Id: Ie37e6901042a65f2a408e428a705b5a24227b262
2022-05-25 16:49:52 +01:00
Normunds Rieksts
92e8614cf9 Remove the roundtrip to Wayland when creating wl_buffers for each image
Change the implementation to create wl_buffers immediately on client
side and defer the creation of wl_buffers on the server
when the first image is presented as that's when all buffered
requests will be flushed to the display

Additionally remove the swapchain event queue as we no longer need it to
dispatch any events

Change-Id: Ic0683e7ec457df63638ce0b972c4925ac836b198
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2021-11-25 09:52:29 +00:00
Iason Paraskevopoulos
0c8259a994 Merge master branch into multiple_swapchains_present_req
Change-Id: I153e7a78609651bbfdf4fc0b6675d0ea97763905
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2021-11-12 12:21:10 +00:00
Normunds Rieksts
86fa15a8a2 Fix OOM issue
Fixes an issue where there was a chance that an exception would be
thrown when out of memory rather than returning an
appropriate VkResult code.

Additionally introduces a noncopyable utility class that can be used to
mark classes that should not have copy semantics

Change-Id: I1f84dc9bb1ea96db2a88a90d56adbee78b17c5e3
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2021-11-11 18:27:31 +00:00
Iason Paraskevopoulos
b481ec0bd2 Move queue for frame events to the surface object
Moves the handling of frame done events from the swapchain object to the
surface object. This will prevent failures where a frame done event
arrives after the swapchain has been destructed but the surface hasn't.

Uses wayland_owners objects for managing the surface event queue and the
frame done event callback.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I61459440e7a6fe8d9447d13f65b797cfcf05f0ed
2021-11-05 11:39:38 +00:00
Iason Paraskevopoulos
65c5f1e4f1 Implement MAILBOX presentation for Wayland swapchains
Adds support for image presentation without relying on the page flipping
thread to communicate with the WSI backend.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I4fd2b937351fc484897dc7e9597aa6e81b37fbdf
2021-10-14 15:45:34 +00:00
Dennis Tsiang
b4db2258ab Add support for some Vulkan 1.1 structs
This commit adds support for VkBindImageMemorySwapchainInfoKHR and
VkImageSwapchainCreateInfoKHR.

Change-Id: I3d87cd7df380e59ceb386f08437c5d6f09dcee1f
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2021-09-23 15:35:51 +01:00
Rosen Zhelev
d7aabddf40 Use explicit synchronization for Wayland surfaces
This change adds the use of zwp_linux_explicit_synchronization_v1 to
attach a Sync FD fence on presented image submitted to the compositor.

The change introduces the wsi/synchronization.hpp header and
implementation of the synchronization primitives used by WSI
implementations. Currently only Vulkan fences and fences exportable to
Sync FD are supported.

Change-Id: Ic7d6b712cc8ae8d171f799af51a70be62585b8a1
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
2021-09-14 10:52:28 +01:00
Rosen Zhelev
6282185808 wayland: Add format negotiation
Replaces the default format used on swapchain image allocation. Instead
the format is negotiated between the supported formats by the Wayland
compositor the Vulkan ICD and any external system allocator.

Change-Id: I4b1261c8832391d54b2932a7cacd34a7a8b13085
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
2021-08-17 16:42:21 +01:00
Rosen Zhelev
24f18c6c44 wsi: Move common objects to the wayland wsi::surface
Moves data and Wayland objects such as the registry to the
wsi::wayland::surface implementation. This also fixes a few issues
with queries where the Wayland display's default queue was wrongly
used and minimizes leaking of server memory from registry creation.

Moves the ownership of the zwp_linux_dmabuf_interface object to the
wsi::wayland::surface as it can be shared between swapchains.

Fixes issues with casting VkSurfaces in the Wayland backend that can
fail when using other layers that wrap the object.

Change-Id: Ibacf0d4229b73bd685254507f52e58d6341aa9b6
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
2021-08-17 16:42:21 +01:00
Dennis Tsiang
241e05d3e4 Resolve segfault in wsialloc_delete
A segfault can occur if wsialloc_delete is called but m_wsi_allocator's
ion field has not been allocated yet, as the function attempts to access
the ion properties.

This commit resolves the issue by changing m_wsi_allocator to an opaque
struct and removing the fd property, which was not being used.
wsialloc_new is then changed to return a pointer to the struct and
the swapchain then carries this pointer around, which will be
initialised to nullptr in the swapchain constructor.

Change-Id: I202e967cff4555babf0ddcd387275b74470b09d5
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2021-05-05 15:44:32 +01:00
Iason Paraskevopoulos
926cd66fcd Add support for multiplane swapchain images in Wayland
Updates wsialloc and wsi::wayland::swapchain to support multiplane
image allocations.

Uses the custom allocator for allocations in Wayland image creation.

Change-Id: I1950b14b75711a76521bbf1967c3c835d006f8a8
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2021-04-23 09:47:31 +01:00
Iason Paraskevopoulos
7c3a626118 Use zwp_linux_dmabuf_v1 interface to query supported formats
Adds functionality to query supported formats of a surface using the
Linux dmabuf extension (zwp_linux_dmabuf_v1).

Removes extern "C" before wayland headers includes.

Introduces Wayland object owners to remove the need of destroying
manually Wayland objects.

Change-Id: I60dc8562bac8746197fff8a0ae059d4edc58cd9a
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2021-03-30 16:54:21 +01:00
Normunds Rieksts
ab41b59bbf Replace swapchain roundtrip implementation in Wayland
Replace the implementation of how the roundtrips are done in
Wayland with one that is provided by the native Wayland client.

Additionally, fixes a small issue present in the Wayland swapchain
where WSI allocator would be freed by the destructor before
wsialloc_new was called resulting in an crash where WSI allocator
would be in an invalid state.

Change-Id: Idfadb88078f94ff15c9f18d1809b01941f2f8548
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2021-03-15 16:18:32 +00:00
Iason Paraskevopoulos
8dc4d923ff Adds initial support for VK_KHR_wayland_surface.
Very basic Wayland support is implemented by importing
memory with VK_EXT_image_drm_format_modifiers.
The current implementation requires an external system
memory allocator. An API for this allocator is defined
in util/wsialloc/wsialloc.h and an implementation using
the ION memory allocator is included.

Outstanding issues:
 * This is an initial prototype for Wayland support and
   has many outstanding TODOs which need addressing to
   properly use the Wayland protocol.
 * Using ICD Exported memory instead of a system allocator
   is not implemented.

Wayland support is still experimental and outstanding issues
will be fixed in future commits.

Change-Id: I1b0d5991e15ff1cf25ebbab3392a631b021e8c17
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2021-02-09 18:22:09 +00:00