Commit graph

25 commits

Author SHA1 Message Date
Normunds Rieksts
a92fa2a8d9 Add support for querying swapchain timing properties
Adds initial support to the headless and Wayland backends to query
swapchain timing properties. This patch also moves all present timing
backend specific code into its own file and refactors the private_data
code that is specific to present timing entrypoints into a more common
format.

Change-Id: I377197a6e14b3cbd968e35735d43060d19dfe5bc
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-02-11 16:47:42 +00:00
Ginu Jacob
02ae04d08f Introduce an extensions abstraction in the layer
In this change, an abstraction layer is added to the swapchain
extensions. The extensions present_timing, present_id,
image_compression_control, frame_boundary, and swapchain_maintenance1
are moved to the new extensions abstraction framework.

Additionally, the compression control extension has been formalized in
the layer as it is part of Vulkan spec so compression control guards
have been removed.

Change-Id: Ib28739ca35dfbf5df987241a9010619279f3e1bb
Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-01-31 17:31:32 +00:00
Rosen Zhelev
196af34b9f Merge 'Add -Wextra flag and fix warnings' into 'main'
See merge request mesa/vulkan-wsi-layer!130
2025-01-21 13:47:22 +00:00
Angeliki Agathi Tsintzira
5c3d3a9d7c Add -Wextra flag and fix warnings
With the addition of the -Wextra flag, additional compiler warnings
are enabled, which help identify potential issues in the code.
However, enabling -Wextra caused compilation failures due to the
-Werror flag, which treats warnings as errors. This commit enables
-Wextra and addresses all the warnings produced, ensuring the
code compiles successfully while maintaining higher code quality standards.

Change-Id: I0bbaead9b2b15530d2565a3dddf1ed676901269b
Signed-off-by: Angeliki Agathi Tsintzira <angelikiagathi.tsintzira@arm.com>
2025-01-20 10:19:25 +00:00
Angeliki Agathi Tsintzira
1f37310208 Check for unsupported surfaces in the layer
Change-Id: I64eca7bf0f5f095c4dbc916c84377ae17350b3ec
Signed-off-by: Angeliki Agathi Tsintzira <angelikiagathi.tsintzira@arm.com>
2025-01-13 10:53:31 +00:00
Angeliki Agathi Tsintzira
3051ca8b67 Add vkGetSwapchainTimeDomainPropertiesEXT support 2024-11-15 12:49:31 +00:00
Normunds Rieksts
94dd9840c9 Implement support for marking frame boundaries 2024-10-01 15:18:22 +00:00
Dennis Tsiang
b1f9e5811a Add initial support for VK_KHR_present_id
Layer updated to advertise support for the VK_KHR_present_id
extension. vkGetPhysicalDeviceFeatures2KHR and vkCreateDevice updated
to handle the new struct.

Also add the extensions enabled by the layer to the
instance_data and device_data objects so that the layer can correctly
check which extensions have been enabled.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I71ae2b28c94d3f16b485a06094712d6c3f6c7e77
2024-08-20 11:46:07 +00:00
Dennis Tsiang
8f2722de92 Add support for VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT
Check for VkPhyscialDeviceSwapchainMaintenance1FeaturesEXT struct in
the pNext chains of VkCreateDeviceInfo and VkPhysicalDeviceFeatures2

Change-Id: I540b800d882855c6782043ca6c88bafc850c4bcd
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:26:53 +01:00
Normunds Rieksts
fecfd94079 Fix issue with OOM CTS test
Fixes issues reported by the
create_instance_device_intentional_alloc_fail.basic CTS test. One of the
issues can happen if allocation fails at the time when dispatch table is
allocated at device/instance creation time which can result in dispatch
table being a null pointer which later is used to resolve Vulkan entrypoints.

This patch also makes sure that dispatch table is passed around the
{instance/device}_private_data::associate functions as a value-type
rather than a pointer which forces the user of the table to use the move
operator as otherwise the ownership transfer from the user to
the{instance/device}_private_data classes was not obvious and the user
could continue to invoke dispatch table functions erroneously.

Fixes the issue of the layer making use of the dispatch table when its
initialization has failed in the cases when calls to
dispatch_table::populate returned an error.

Any calls to vkDestroyInstance within vkCreateInstance
have been removed as the Vulkan loader handles the unloading of the
instance which would otherwise result in a double-free exception being
thrown.

Change-Id: I36bb7219db9d852bc31f09c8154b2f93776c162f
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2024-04-29 16:07:49 +00:00
Dennis Wildmark
2837bab5c4 Refactor dispatch table to fix extension entry point visibility
Add functionality to the dispatch tables enabling the layer to hide
entrypoints from user. Add filtering to
vkGetDeviceProcAddr/vkGetInstanceProcAddr to only return pointers to
entrypoints which belongs to user enabled extensions.

Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Change-Id: Ieec305cc9479363de0b8e1618c671c08f7af3997
2024-02-14 14:33:40 +00:00
Dennis Tsiang
92a3da6ad2 Fix issues reported by static analysis tools
Fix CERT C/CPP issues flagged by static analysis tools.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I6758bb83bd0647e4e6b7ccbf84e94f05ba90e160
2022-11-11 14:27:03 +00:00
Iason Paraskevopoulos
32c5ad9d1b 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
2022-07-07 08:33:57 +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
Iason Paraskevopoulos
2aa963ba92 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>
2022-03-10 10:28:33 +00:00
Iason Paraskevopoulos
feee8f5d36 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>
2022-03-10 10:22:22 +00:00
Iason Paraskevopoulos
96657394ec 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
2021-11-17 11:51:30 +00:00
Ben Davis
6ef056b517 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>
2021-11-11 10:15:22 +00:00
Rosen Zhelev
c7be05e3ff 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>
2021-08-17 16:42:21 +01:00
Normunds Rieksts
d63261cce5 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>
2021-07-22 19:05:26 +01:00
Normunds Rieksts
af2af23333 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>
2021-06-28 11:51:33 +01: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
Joe Jenner-Bailey
950cdd406a 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>
2021-02-05 11:22:32 +00:00
Matteo Franchin
7670a0ac84 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
2019-09-11 13:26:22 +00:00
Matteo Franchin
9b698b4a2f 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>
2019-05-31 15:48:05 +01:00