summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Matteo Franchin [Mon, 4 Jul 2022 10:11:51 +0000 (11:11 +0100)]
Fix issues found by static analysis
All of the issues that this patch fixes should not occur in practice,
but make the code a bit more robust. For example, this patch
default-initializes structures passed to Vulkan for initialization.
Normally, initialization should be done by the Vulkan entrypoint,
so it should be fine not initializing the structure as long as the
Vulkan API entrypoint exits with success status. It is still a good
idea to default-initialize anyway to make the behaviour deterministic
in cases where something is wrong in the system. All changes made
should have a negligible impact on performance for typical
applications.
Change-Id: Ia606ad2d3ea1627f9dfef0cadf93c7468ab568d8
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Lior Dekel [Tue, 5 Jul 2022 15:08:35 +0000 (18:08 +0300)]
Create common functions in surface_capabilities class
Signed-off-by: Lior Dekel <lior.dekel@arm.com>
Change-Id: Ia5053b202f4e64fd7a255ede513653a951ab3d41
Rosen Zhelev [Thu, 23 Jun 2022 16:47:45 +0000 (17:47 +0100)]
Update Khronos headers API version
Change-Id: Ifa3f945a1216677c9410c09f4b4341a70d918514
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Iason Paraskevopoulos [Mon, 27 Jun 2022 14:00:14 +0000 (15:00 +0100)]
Remove swapchain from device_data after destruction
Fixes an issue, where the swapchain addresses weren't removed from the
device_private_data::swapchains member after swapchain destruction. This
could cause clashes with swapchains handled by different components
(e.g. ICD).
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I0e05734368ef6100b67ded973283f99ef248e540
Iason Paraskevopoulos [Tue, 7 Jun 2022 15:18:05 +0000 (16:18 +0100)]
Add WSI integration guide
Adds a guide on implementing a WSI backend and extra documentation in
a few functions in swapchain_base.
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: Ibdc702a05605989940966aae168331268c1ce2ba
Matteo Franchin [Tue, 17 May 2022 14:18:00 +0000 (15:18 +0100)]
Enable instance extensions required by layer
The layer needs functionality that is not part of Vulkan 1.0 and is
provided by either Vulkan 1.1 or separate Vulkan extensions.
The layer used to solve this issue by bumping the API version passed
by the application in VkCreateInfo to 1.1 if this was set to 1.0.
This workaround does not seem to be working anymore with recent
versions of the loader. Fortunately, the loader now allows layers
to change the extension lists passed by the application.
This patch changes the layer to use this approach and removes the
API bump logic.
Documentation is updated accordingly.
Change-Id: I61c426311612c7f288a0f7d969782d6c5365acf5
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Dennis Tsiang [Fri, 18 Mar 2022 12:05:46 +0000 (12:05 +0000)]
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
Iason Paraskevopoulos [Thu, 3 Mar 2022 11:21:07 +0000 (11:21 +0000)]
Implement VK_KHR_get_surface_capabilities2 entrypoints
Adds support for the VK_KHR_get_surface_capabilities2 extension.
Change-Id: Iae882a41819baf413a0ba949ec44d6e722ebca5a
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Iason Paraskevopoulos [Mon, 28 Feb 2022 16:21:06 +0000 (16:21 +0000)]
Use common code for get_surface_formats implementations
Adds a template function for setting the supported surface formats for
a surface. This function is used in the get_surface_formats
implementation of both the WSI backends, which previously were
implementing the same logic independently.
Removes the unused surface argument from get_surface_formats and
get_surface_capabilities.
Change-Id: Ib220166675d1c24aeef230cf9f510abba9e42a61
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
David Harvey-Macaulay [Thu, 13 Jan 2022 10:08:03 +0000 (10:08 +0000)]
Mark fences and semaphores as already signalled in AcquireNextImage
The VK_KHR_external_[fence|semaphore]_fd extensions allow sync
primitives to be signalled without the use of QueueSubmit. Using these
extensions in AcquireNextImage instead of using QueueSubmit offers two
advantages: (1) there is no waiting for work to complete in the queue
before the primitives are signalled and (2) there is no data race if
the application happens to call QueueSubmit on the same queue at the
same time.
The QueueSubmit method of signalling sync primitives continues to be
used for ICDs that do not support the external FD extensions.
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
Change-Id: Ib4a922d44430110e2353a4e0221e27017e72abab
Dennis Tsiang [Mon, 24 Jan 2022 15:02:03 +0000 (15:02 +0000)]
Fix FD ownership issue in Wayland Vulkan import
When a file descriptor is imported in Vulkan as a dma buf the Vulkan
implementation takes ownership. We use this property to manage the
lifetime of file descriptors allocated by WSIALLOC by importing them as
VkDeviceMemory. After import the WSI Layer doesn't need to close any
file descriptors and instead only needs to destroy the VkDeviceMemory
object.
However after import the original file descriptor should not be used by
the application. Currently the WSI Layer Wayland implementation violates
this by using the FD to pass to the compositor. This commit fixes the
issue by initiating the Wayland requests before importing the fd.
Internally libwayland will duplicate the fd.
Change-Id: I3ca877f90f0139cf23b8b39c6024e8815b82d692
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Ben Davis [Fri, 10 Dec 2021 11:13:08 +0000 (11:13 +0000)]
Remove DEBUG build option
Users should use CMAKE_BUILD_TYPE to set the build type
Change-Id: I526b3a96f798a39ceca11674bf1e0b6964a3da7d
Signed-off-by: Ben Davis <ben.davis@arm.com>
Rosen Zhelev [Thu, 9 Dec 2021 13:18:52 +0000 (13:18 +0000)]
wayland: Fix nulltpr dereference on deprecated swapchains
Fixes a nulltpr dereference when a buffer release event is processed on
deprecated swapchains. In such a case some of the swapchain images are
invalid and associated resources have been freed.
Change-Id: I8f1c66e42e900d63c8c43cb53068a8aee9ea25a9
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Fufu Fang [Wed, 1 Dec 2021 11:09:09 +0000 (11:09 +0000)]
Casting operands to a wider type to prevent integer overflow
Previously the calculation for total_size was done in 32-bits, as the
operands were all 32-bit signed or unsigned integers. This led to
integer overflow when the extent being allocated is too large.
total_size is finally cast to size_t, as the kernel UAPI for ION uses
size_t.
Change-Id: I7a76b2c18be25fda0bf6ef70cd8a6fe717c2903c
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
Dennis Tsiang [Tue, 7 Dec 2021 17:25:30 +0000 (17:25 +0000)]
Include modifiers in params creation
Include the modifiers in the call to zwp_linux_buffer_params_v1_add
Change-Id: If4407af5f402a418b69a670d316fe56cce9f2a14
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Dennis Tsiang [Thu, 25 Nov 2021 15:30:46 +0000 (15:30 +0000)]
Fix bug in has_descendant_started_presenting in headless backend
If there exists two swapchains where one is a descendant of another, we
need to return VK_ERROR_OUT_OF_DATE_KHR error if the application tries
to present from the ancestor when the descendant has started presenting.
The has_descendant_started_presenting() function checks whether the
descendant has started presenting by looking for pending images in the
descendant's list of swapchain images. However, the descendant could
have already presented its pending image(s) before the ancestor arrives
at this check. In this scenario, the descendant will have marked the
swapchain image(s) as now free, and therefore when the ancestor looks
for pending images it will fail to find any. This causes the function to
incorrectly return false.
This bug can be resolved by creating a new boolean member variable to
track whether the swapchain has started presenting.
Change-Id: Ibc3399a4bb05f89940f0b595d25aa07b8e2a2cb8
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Ben Davis [Fri, 12 Nov 2021 17:21:40 +0000 (17:21 +0000)]
Check for required protocols in vkGetPhysicalDeviceWaylandPresentationSupportKHR
Add additional checks ensuring required protocols are supported.
Currently Version 3 of zwp_linux_dmabuf_v1 and Version 1 of
zwp_linux_explicit_synchronization_v1 are required.
Change-Id: Ie1ed37a22254eb14ebdb9cc7d3a35fc99fcb4481
Signed-off-by: Ben Davis <ben.davis@arm.com>
Fufu Fang [Wed, 24 Nov 2021 17:18:54 +0000 (17:18 +0000)]
Improve error handling when copying extension name
The extension list now calls abort() if an extension name exceeding
the length limit is copied.
Change-Id: I105946b647ebd0087dc892d7c8a227628da31966
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
David Harvey-Macaulay [Tue, 23 Nov 2021 13:27:02 +0000 (13:27 +0000)]
Remove ENABLE_WSI_LAYER option
By removing this option, the layer will be enabled by default.
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
Change-Id: I6d62e770d914098ad6f0d7d74fb45ce3f8fdbc01
Iason Paraskevopoulos [Wed, 22 Sep 2021 10:15:26 +0000 (11:15 +0100)]
Return appropriate error code in acquire_next_image
Fixes an issue, where acquire_next_image was always returning
VK_ERROR_OUT_OF_HOST_MEMORY when the swapchain had gone into a faulty
state.
Change-Id: Iafe016e4e31158d1a5f0d6d785f60d6a724c62ab
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Normunds Rieksts [Fri, 12 Nov 2021 13:31:02 +0000 (13:31 +0000)]
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>
Iason Paraskevopoulos [Mon, 8 Nov 2021 13:32:12 +0000 (13:32 +0000)]
Store enabled instance and device extensions
Stores the enabled instance and device extensions during
vkCreateInstance and vkCreateDevice respectively. This fixes an issue
where function pointers for functions of disabled extensions were
returned during vkGetInstanceProcAddr/vkGetDeviceProcAddr.
Adds functionality for adding extensions that belong to a subset of
other extensions in util::extension_list.
Adds function for checking if the proper surface extension has been
enabled in each WSI backend.
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: If5e23e0d07c9f09006be18c410c4e1d4c3a1e676
Dennis Tsiang [Mon, 15 Nov 2021 13:59:10 +0000 (13:59 +0000)]
Add versioning to wsialloc interface
The wsialloc interface now has explicit versioning which is used to
ensure that wsialloc implementations are compatible with the interface.
wsialloc implementations should define which version they are using and
upon version mismatch compilation will fail.
Also:
- add new WSIALLOC_MAX_PLANE macro to define the maximum number of
planes that the wsialloc should support.
Change-Id: I211fc4341f249deff0c005d946c483ba47366600
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Ben Davis [Tue, 9 Nov 2021 10:10:55 +0000 (10:10 +0000)]
Update supported composite alpha flags
There is currently no protocol for setting composite alpha blending mode
via Wayland but the expectation is that we use premultiplied alpha
so we only report the premultiplied and inherit composite alpha bits
Change-Id: If4e103b47cb8e99213ca96216abc06d812c68db1
Signed-off-by: Ben Davis <ben.davis@arm.com>
Iason Paraskevopoulos [Fri, 12 Nov 2021 12:19:58 +0000 (12:19 +0000)]
Merge master branch into multiple_swapchains_present_req
Change-Id: I153e7a78609651bbfdf4fc0b6675d0ea97763905
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Normunds Rieksts [Mon, 8 Nov 2021 17:53:12 +0000 (17:53 +0000)]
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>
Ben Davis [Tue, 12 Oct 2021 14:06:40 +0000 (15:06 +0100)]
Integrate clang-tidy-8 with cmake build
We will now run clang-tidy if available as part of the standard build
with the bugprone-* and modernize-* checks
Change-Id: I4c9d3cf8712f802b912d32a443bca1584169a8b3
Signed-off-by: Ben Davis <ben.davis@arm.com>
Ben Davis [Thu, 7 Oct 2021 13:48:44 +0000 (14:48 +0100)]
Update code to use modern c++ style
Fix warnings given by clang-tidy 8 with checks 'bugprone-*,modernize-*'
Change-Id: I2e5660c5872728f957869c66b1143cfcc76bc20e
Signed-off-by: Ben Davis <ben.davis@arm.com>
Iason Paraskevopoulos [Wed, 10 Nov 2021 14:31:19 +0000 (14:31 +0000)]
Merge master branch into multiple_swapchains_present_req
Change-Id: Ibc6c094d85795e532e59184252896ecd05b50019
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Normunds Rieksts [Wed, 27 Oct 2021 14:47:08 +0000 (15:47 +0100)]
Ensure that swapchain is not passed to the ICD when creating images
Ensures that all images created from a headless swapchain use the
same vkImageCreate info.
This ensures that when calling vkCreateImage with a swapchain that
is owned by the layer the VkImageSwapchainCreateInfoKHR is not
passed further down the chain to ICD on headless implementation.
Change-Id: I1bd723589e52577b98fd53ec1ec769e5594a0838
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Dennis Tsiang [Wed, 3 Nov 2021 11:25:48 +0000 (11:25 +0000)]
Set default visiblity of functions to hidden
Reduce the number of functions that are exported by the layer. This
helps resolve dynamic linking issues where multiple functions are named
the same in different shared libraries. Also add function specifiers and
calling conventions to all extern "C" functions.
Change-Id: I07b33ff8d066e33c5dbdf0cbc13aa7835a78220b
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Iason Paraskevopoulos [Fri, 5 Nov 2021 11:38:55 +0000 (11:38 +0000)]
Use device allocator for stage flags vector
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I2b7882e10eca2f4cfbd3668b6265d5b6093c4272
Iason Paraskevopoulos [Wed, 27 Oct 2021 11:21:59 +0000 (12:21 +0100)]
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
Matteo Franchin [Fri, 29 Oct 2021 11:45:24 +0000 (12:45 +0100)]
Add documentation for Wayland support
- Clarify requirement of Vulkan 1.1 support in Vulkan Loader and ICDs
- Add a list of Vulkan extensions required for Wayland
- Document option to provide a custom implementation of the wsialloc.h
interface and to disable support for VK_EXT_headless_surface
- Fix link to Vulkan Loader documentation
Change-Id: I791577a49570855fde86b2ffb1ac8e966f2073d9
Iason Paraskevopoulos [Wed, 20 Oct 2021 14:27:47 +0000 (15:27 +0100)]
Handle present request for multiple swapchains
Adds an additional semaphore for every swapchain image to be waited for
before the present engine access an image. During a present request with
multiple swapchains, these semaphores are grouped together and are
signaled after the incoming pWaitSemaphores signal.
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I94cabbf5f7d9a45dceef60eec7773b48ccc32078
Normunds Rieksts [Mon, 4 Oct 2021 11:30:14 +0000 (12:30 +0100)]
Add ability to specify custom wsialloc implementations
Adds the ability to link the project with a custom wsialloc
library.
This makes it possible to customize the format selection and
allocation to the target system, according to its capabilities.
Change-Id: Iade5cd27aa3515d3debb7fe1f2b96453776d77be
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Dennis Tsiang [Mon, 4 Oct 2021 07:44:14 +0000 (08:44 +0100)]
Fix formatting issues
All files in the project should have an empty line at the EOF. Necessary
for some pre-processing tools.
Change-Id: Ic4502588f2733f669fc1edc898258f8589c484c6
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Fufu Fang [Fri, 22 Oct 2021 08:55:13 +0000 (09:55 +0100)]
Remove the TODO on the max Wayland image size.
It is valid to create windows exceeding the display size. It is correct
to set the image size limits to the GPU limits.
Change-Id: I53d0865ad1a540cd2eb92137ef325f000bd76159
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
Normunds Rieksts [Tue, 26 Oct 2021 10:07:14 +0000 (10:07 +0000)]
Add build option for headless extension
Adds a build option that provides the ability to build the layer
with or without headless extension support
Change-Id: Iedefbd38daf80d84f4763ea54117ca18c7fad088
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Iason Paraskevopoulos [Fri, 15 Oct 2021 12:34:37 +0000 (13:34 +0100)]
Always set use_presentation_thread flag in init_platform
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I1b917f5287c635dbb00b05607c5a36ce7b11767e
Iason Paraskevopoulos [Thu, 14 Oct 2021 15:45:34 +0000 (15:45 +0000)]
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
Ben Davis [Wed, 15 Sep 2021 09:08:15 +0000 (10:08 +0100)]
Fix issues found by static analysis
Change-Id: I222ec3b352aa220b6c08df3a71de48178b67f06d
Signed-off-by: Ben Davis <ben.davis@arm.com>
Dennis Tsiang [Thu, 30 Sep 2021 07:46:35 +0000 (08:46 +0100)]
Synchronise access to the ring buffer pool
We need to synchronise access to the ring buffer pool in order to avoid
concurrency bugs as multiple threads can mutate the state of the ring
buffer and if we do not serialise these changes then they can result in
errors.
Change-Id: If96e1707716370bcf57416cd505d16aa75c0d68c
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Iason Paraskevopoulos [Thu, 30 Sep 2021 16:24:42 +0000 (17:24 +0100)]
Update json manifest
Updates the api_version to 1.2 in the json manifest. Also, adds the
entrypoints node in the device extensions as it is mandated by the
loader's documentation when an extension adds Vulkan API functions.
Removes support for intercepting vkEnumerateInstanceLayerProperties,
vkEnumerateInstanceExtensionProperties and
vkEnumerateDeviceExtensionProperties as the loader can get the
information they provide from the layer's json manifest in its
terminator functions.
Change-Id: I2c304d1d2ea17d3ea0c723694f8fc4c8a92054a0
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Rosen Zhelev [Tue, 21 Sep 2021 08:03:49 +0000 (09:03 +0100)]
wsi: Fix swapchain teardown causing hangs
The swapchain teardown waits for pending images incorrectly. The
regression caused the wait to complete before pending images were
processed as well as a hang when all images are acquired by the
application or pending presentation. In this case the swapchain
teardown would hang waiting on the last image presented by a compositor
that would never be released.
Fixing this exposes additional hangs when swapchain images update the
free semaphore after being marked as free. There are also potential
hangs if multiple threads are waiting for all pending images or
acquiring an image at the same time. These issues are addressed by
serializing those actions with a mutex.
Change-Id: I266c93a61333d59823f404ea6ba19fb343f46a13
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Iason Paraskevopoulos [Mon, 27 Sep 2021 08:34:04 +0000 (09:34 +0100)]
Remove destroy_image from unpresent function
Fixes an issue, where in Wayland the new swapchain hanged during its
first image presentation in the page flipping thread when it waited for
the old swapchain to finish presenting its pending images. As the new
swapchain had started presenting destroy_image was called during the
unpresent function for the old swapchain and the image's status was set
to INVALID instead of FREE. So free_image_found never returned true and
subsequently get_free_buffer was blocked in the loop. The issue is fixed
by removing the call to destroy_image in unpresent_image as it is
redundant and is done in swapchain teardown.
Change-Id: I192607f50eb5e5f0e4e9baf66aedf02221f20b63
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Dennis Tsiang [Thu, 23 Sep 2021 14:35:51 +0000 (15:35 +0100)]
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>
David Harvey-Macaulay [Mon, 13 Sep 2021 14:30:06 +0000 (15:30 +0100)]
Return vkDestroyDevice from vkGetDeviceProcAddr
The vkDestroyDevice entrypoint was listed as a instance level
entrypoint, that is, to be returned by vkGetInstanceProcAddr; however,
vkDestroyDevice is a device level entrypoint. Consequently, the layer
implementation was not called by the loader upon application calls to
vkDestroyDevice and this caused memory leaks within the layer.
Change-Id: I9d5807ff17965281580cd80eb74b07fb038073b1
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
Rosen Zhelev [Wed, 1 Sep 2021 21:30:31 +0000 (22:30 +0100)]
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>
Dennis Tsiang [Mon, 16 Aug 2021 10:01:11 +0000 (11:01 +0100)]
Update layer to generate Wayland explicit sync files
CMakeLists.txt updated to extract the explicit sync code and header
files from linux-explicit-synchronization-unstable-v1.xml, which is a
Wayland extension that allow explicit synchronisation. This is needed to
support the MAILBOX presentation mode.
Change-Id: Id556b69748663796d14fa8b8ceaa0a9c03e9af6e
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Dennis Tsiang [Mon, 16 Aug 2021 11:22:25 +0000 (12:22 +0100)]
Add ring buffer utility
Add new utility class implementation ring_buffer and replace existing
struct implementation.
Change-Id: I725033738bff73d33f938e64cc96ca9acb8a910c
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
Rosen Zhelev [Fri, 23 Jul 2021 18:42:11 +0000 (19:42 +0100)]
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>
Rosen Zhelev [Thu, 22 Jul 2021 22:49:15 +0000 (23:49 +0100)]
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>
Rosen Zhelev [Wed, 21 Jul 2021 19:19:52 +0000 (20:19 +0100)]
Implement objects associated with VkSurface
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>
Ben Davis [Thu, 27 May 2021 13:57:53 +0000 (14:57 +0100)]
Fix potential hang on swapchain inheritance
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>
Ben Davis [Fri, 25 Jun 2021 10:35:11 +0000 (11:35 +0100)]
Add vulkan 1.1 function entrypoints
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>
Normunds Rieksts [Wed, 28 Jul 2021 15:39:11 +0000 (15:39 +0000)]
Implement a vendor agnostic wsialloc interface
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>
Dennis Tsiang [Mon, 26 Jul 2021 15:40:21 +0000 (16:40 +0100)]
Add documentation for unique_ptr and deleter class
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>
Normunds Rieksts [Mon, 19 Jul 2021 16:34:54 +0000 (17:34 +0100)]
Remove usages of generic allocator in the layer
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>
Fufu Fang [Tue, 1 Jun 2021 16:56:25 +0000 (17:56 +0100)]
Refactoring of extension_list
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
Normunds Rieksts [Thu, 27 May 2021 12:53:07 +0000 (13:53 +0100)]
Ensure allocations happen through custom allocators
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>
Dennis Tsiang [Wed, 5 May 2021 14:44:32 +0000 (15:44 +0100)]
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>
Fufu Fang [Thu, 29 Apr 2021 23:19:25 +0000 (00:19 +0100)]
Remove workaround for flushing wl_release events
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>
Fufu Fang [Tue, 23 Mar 2021 10:24:43 +0000 (10:24 +0000)]
Creating logging mechanism for debugging
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>
Iason Paraskevopoulos [Fri, 12 Mar 2021 14:19:59 +0000 (14:19 +0000)]
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>
Ben Davis [Wed, 21 Apr 2021 12:21:31 +0000 (13:21 +0100)]
Remove to-do to check if FIFO is ok on Wayland
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>
David Harvey-Macaulay [Mon, 15 Mar 2021 15:46:32 +0000 (15:46 +0000)]
Apply workaround for Wayland set_queue race
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>
Iason Paraskevopoulos [Wed, 3 Mar 2021 15:06:41 +0000 (15:06 +0000)]
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>
Normunds Rieksts [Tue, 9 Mar 2021 16:29:16 +0000 (16:29 +0000)]
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>
Normunds Rieksts [Wed, 3 Mar 2021 18:12:23 +0000 (18:12 +0000)]
Fixes segfaults in the layer due to uninitialized pointer
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>
Iason Paraskevopoulos [Sun, 31 Jan 2021 20:09:53 +0000 (20:09 +0000)]
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>
Joe Jenner-Bailey [Wed, 24 Jun 2020 08:36:21 +0000 (09:36 +0100)]
layer: improve how layer handles Vulkan extensions
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>
Joe Jenner-Bailey [Tue, 4 Aug 2020 11:25:34 +0000 (12:25 +0100)]
util: add class for storing extensions strings
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>
Matteo Franchin [Fri, 27 Nov 2020 09:59:18 +0000 (09:59 +0000)]
Use util::allocator in swapchain object
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>
Iason Paraskevopoulos [Thu, 26 Nov 2020 18:00:05 +0000 (18:00 +0000)]
Fix erroneous behaviour in error cases
Corrects error handling when image creation fails and fixes
shutdown behaviour in error cases.
Change-Id: I29b9fbd237b90f6007e4731d9019efb6b4c256ff
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Joe Jenner-Bailey [Fri, 10 Jul 2020 09:28:51 +0000 (10:28 +0100)]
Implement a vector utility that uses a custom allocator
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>
Iason Paraskevopoulos [Tue, 17 Nov 2020 09:27:44 +0000 (09:27 +0000)]
Fix layer's memory errors
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>
Dennis Tsiang [Tue, 27 Oct 2020 11:12:00 +0000 (11:12 +0000)]
Fix failing assert in swapchain_base.cpp
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>
Rosen Zhelev [Sun, 28 Jun 2020 20:41:21 +0000 (21:41 +0100)]
headless: Fix build with up-to-date Vulkan headers
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>
Dennis Tsiang [Fri, 1 May 2020 12:25:30 +0000 (13:25 +0100)]
Remove use of pthread_cancel in the swapchain page flip thread
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>
Rosen [Thu, 21 Nov 2019 15:23:59 +0000 (15:23 +0000)]
Move WSI type specific calls
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>
Matteo Franchin [Fri, 13 Sep 2019 18:34:18 +0000 (19:34 +0100)]
Add a simple build test to the Vulkan WSI Layer's CI
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
Matteo Franchin [Wed, 11 Sep 2019 13:26:22 +0000 (13:26 +0000)]
Fix small issues in documentation and code
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
Matteo Franchin [Fri, 24 May 2019 14:57:50 +0000 (15:57 +0100)]
Initial sources for the vulkan-wsi-layer project
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>