Defines an abstract wsi::surface object to be implemented by each WSI
backend. This object is then associated with the corresponding VkSurface
object in the instance specific data.
To keep track of these objects the layer now intercepts
vkDestroySurfaceKHR, while specific surface creation entrypoints are
intercepted by individual WSI backends.
In addition this change should allow for fixing incompatibility issues
with layers that wrap VkSurface which breaks casting to the Loader's ICD
VkSurface type.
Make greater use of util::unique_ptr and allow for such pointers to be
constructable when casting derived types.
Change-Id: I163e9c47088ad9989583ebce1319b1fc05559d73
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Introduce a mutex to control access to a swapchain's image statuses,
also only wait for swapchain images marked as "PENDING"
Change-Id: I7bd530ea50eb44cb98ed4f674167d14de4a30d53
Signed-off-by: Ben Davis <ben.davis@arm.com>
Implement vkGetDeviceGroupSurfacePresentModesKHR,
vkGetDeviceGroupPresentCapabilitiesKHR, vkAcquireNextImage2KHR and
vkGetPhysicalDevicePresentRectanglesKHR function entrypoints in the
layer.
We assume that if the layer should not handle the surface the device or
instance should handle it as appropriate and fallback to this
implmentation.
Change-Id: Iafc585d8738ad80413ad616d834d966f92c4f8cb
Signed-off-by: Ben Davis <ben.davis@arm.com>
Refactors the wsialloc interface in the layer.
This patch ensures that wsialloc interface could be ported
to different GPU architectures and systems that could
have different requirements
Change-Id: I6593f2373abc75fb2074700d156ba3797d7ff058
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Add brief documentation to explain what the custom util::unique_ptr and
deleter class is used for.
Change-Id: I7f4d456a34d55c09ad470b7c34e32b069203ca6b
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Remove all the leftover instances in layer that still use the
generic allocator rather than the VkAllocationCallbacks
Add additional memory utility that allows to release memory
allocated by custom allocators using RAII
Change-Id: I43594ddd3c506048ca0f02e31b64597a7abc481b
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Unused methods removed. Specialised methods moved out
of the extension_list utility and closer to the point
of usage.
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
Change-Id: I8e6d2786881b5306de21797cfdda46d0e678da8d
Document instance_private_data and device_private_data.
Add additional utility containers (util::unordered_set,
util::unordered_map) that ensure that the storage containers
we use allow the use of the Vulkan allocation callbacks.
Additionally, ensure that these allocations don't throw in
case host runs out of memory but rather return the appropriate
Vulkan error code.
Also keep a copy the allocators so they can be used in other layer
functionality to facilitate following the Vulkan specification around
memory allocation.
Add additional utility util::optional that currently makes it easier
to handle errors in the containers described above.
Fix some small issues with the vkCreateInstance/vkCreateDevice
handling and ensure that vkDestroyDevice is called in the layer
handler.
Change-Id: Ic9d8ece405c82e743a2c016cc3dabf984cf77fc1
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
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>
This workaround was required when using Weston 3.0.91 or earlier
versions.
Change-Id: Ie89afb8644aaac156fd35a15b4bb8959065a9393
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
Introduce a logging mechanism in the layer for replacing the
old ones used in individual files.
Change-Id: I7559f8a99396eeb0b9da6e5ef58cc4b7bd5a82af
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
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>
Although Mailbox mode is recommended for use on Wayland, FIFO is
required by the Vulkan spec and after investigation our implementation
seems to be compliant with the spec.
Change-Id: Ib3230e31c4dd516bc40dc50c9e920fb145506145
Signed-off-by: Ben Davis <ben.davis@arm.com>
Wayland objects receive events from the server into an event queue.
Unless specified otherwise, events from the server arrive to the event
queue belonging to the parent object. It is beneficial for us to
override this default queue assignment so that we receive only the
events we are interested in.
We currently override the default event queue assignment using
wl_proxy_set_queue after object construction:
struct wl_object *child_object = wl_create_object(parent_object);
wl_proxy_set_queue((struct wl_proxy *)child_object, queue);
There is a race condition here: events may be received into the parent's
queue before we have a chance to perform this override. This will lead
to hangs if we are expecting an event to arrive to our specific queue.
To workaround this issue, we can use a wrapper object to specify the
desired event queue at the time of object creation:
struct wl_object *parent_wrapper = wl_proxy_create_wrapper(parent_object);
wl_proxy_set_queue((struct wl_proxy *)parent_wrapper, queue);
struct wl_object *child_object = wl_create_object(parent_wrapper);
wl_proxy_wrapper_destroy(parent_wrapper);
This commit applies this workaround to all object allocations whose
intended event queues differ from the default assignment to avoid the
aforementioned race condition.
Change-Id: I3e6a7c679280f0d66b02ab7eab06a010e9e24b36
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
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>
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>
The layer would segfault when running due to pointer being left
uninitialized when attempting to query device extensions
Change-Id: If72d822a36224034bf27bef5035015cdb0bffb07
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
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>
In vkCreateInstance:
- ppEnabledExtensionNames is checked to determine which window-system
platforms the layer should enable support for.
- support in the layer is always enabled if possible, even if this may
be provided by the ICDs. Platforms not supported by the layer should
still be correctly supported by the ICDs (untested.)
- pApplicationInfo is changed to bump the Vulkan API version
in order to enable instance extensions that are necessary for some
of the platforms implemented in the layer.
In vkCreateDevice:
- ppEnabledExtensionNames is extended with device extensions required
by the layer.
- if the extensions are not supported by the physical device, the
layer fails to initialize the device.
Change-Id: Ibdd69fca38e7909d5b8f0ac7698805ea5f425ac6
Signed-off-by: Joe Jenner-Bailey <joe.jenner-bailey@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
This utility will be used in future commits.
Also add -Wno-undefined to the linker flags to prevent leaving
undefined symbols in the layer .so file. Fix issues highlighted while
using this flag.
Change-Id: I682e266f7b3f313742cb2da83e5ad2569fc72da3
Signed-off-by: Joe Jenner-Bailey <joe.jenner-bailey@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Change util::allocator's create and destroy methods so that they can
allocate multiple objects, in line with the allocate and deallocate
methods of std::allocator.
Also add documentation for util::allocator and its methods.
Finally, use util::allocator in swapchain.cpp, rather than allocating
memory directly via VkAllocationCallbacks.
Change-Id: I0bc25abe3cbc3af9608218411da8d70e04dd9749
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Add util::vector to provide functionality similar to std::vector,
i.e. growable arrays. util::vector does its allocations via a custom
allocator provided via VkAllocationCallbacks and provides methods to
check whether the allocation fails, e.g. try_push_back() returns false
when the allocation fails and replaces std::vector's push_back() method
that would rather raise an exception to report an allocation failure.
Note that this commit switches on exceptions in the layer by removing
the flag -fno-exceptions.
util::vector is also used to store swapchain images.
Change-Id: I2bf2b24bd06e198c198c4f4aedd8f7fced96a346
Signed-off-by: Joe Jenner-Bailey <joe.jenner-bailey@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Fixes the wrong allocation of extensions properties.
Adds a call to the dispacher's DestroyInstance function before the
destruction of the instance.
Change-Id: I169bb3ba670d89e30af1f6ce47c536477978c169
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Erroneous assert was left in swapchain_base.cpp after some refactoring
was done. This commit removes the assert and updates the CMakeLists.txt
file to turn on compiler warnings so that developers can spot these
leftover code earlier.
Change-Id: I7f4051c89a86f21f66f20b0e92f01bc101436c71
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Vulkan Headers removed VK_FORMAT_RANGE_SIZE. The VkFormat enum now
has valid values in multiple ranges for different extensions.
Fixes headless implementation for itterating over core Vulkan 1.0
formats.
Change-Id: I417cfd881e479e5fb243c0b775600504af3877b1
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
The WSI layer may call pthread_cancel and kill the page flip
thread while it's still being used in Vulkan-API calls. This can cause the
layer to fail to clean up internal resources of the associated device,
leading to memory leaks. To resolve this, the layer now instead checks
if the page flip thread needs to end on every loop iteration. The
m_page_flip_semaphore has also been changed to a timed_semaphore to avoid
hanging indefinitely. In addition, m_page_flip_thread is now type
std::thread, which follows the gradual move towards C++ standard code
and moved to a private member function of the class.
Change-Id: Iefbdd0d68e1f92fdf79bcebb7eaf33429fc61fd3
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Move all WSI type specific calls to WSI factory methods. This
removes headless references in layer/ and allows for simpler
support of multiple windowing systems.
Change-Id: I757a7a3bb4267783420b52cceb3bde8ce233297e
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
The test just ensures the code can be built. For now we start from a
Fedora image and install quite a number of packages. This is not very
friendly in terms of network bandwidth. We should address this by
uploading a custom image in the future.
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Change-Id: I5c9fa86b081650ce12ef92e333475670a4daa5fb
A couple of details in the installation instructions needed updating.
Also fixed a warning message due to a missing return statement (the
return value is currently not used in calls to the function).
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Change-Id: I715b954579253e664ebe01f757587e0602ad82e7
This commit adds the initial sources for the vulkan-wsi-layer project:
a Vulkan layer which implements some of the Vulkan window system
integration extensions such as VK_KHR_swapchain.
The layer is designed to be GPU vendor agnostic when used as part of the
Vulkan ICD/loader architecture.
The project currently implements support for VK_EXT_headless_surface and
its dependencies. We hope to extend support for further platforms such
as Wayland and direct-to-display rendering in the future.
This initial commit collects contributions from different individuals
employed by Arm.
More information on the project (building instructions, how to
contribute, etc.) can be found on the README.md file at the top of the
project tree.
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>