Commit graph

29 commits

Author SHA1 Message Date
ginujacob
9abd1af3ce Handle VkPresentTimingsInfoEXT
Implements the entrypoint vkSetSwapchainPresentTimingQueueSizeEXT and
handles VkPresentTimingsInfoEXT. The presentation timing queue is
also implemented the present id from parsing VkPresentTimingsInfoEXT is
stored in the queue.

Signed-off-by: ginujacob <ginu.jacob@arm.com>
Change-Id: I81b6113b54db5e59f7018ef9a22e80af6dcdd568
2024-10-11 18:56:31 +01:00
Normunds Rieksts
94dd9840c9 Implement support for marking frame boundaries 2024-10-01 15:18:22 +00:00
Normunds Rieksts
af44f50be3 Add support for VkPresentIdKHR structure
Adds support for handling the present IDs privided by the VkPresentIdKHR
structure that is exposed by the VK_KHR_present_id extension.

Change-Id: If2dfe2cf942f376729b5c0dec79bcfa0c0b49738
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2024-08-29 14:22:30 +01:00
Dennis Tsiang
05e98f4d17 Support switching presentation modes
Add support for handling VkSwapchainPresentModeInfoEXT and
VkSwapchainPresentModesCreateInfoEXT when supplied as part of the
pNext chain of VkPresentInfoKHR and VkSwapchainCreateInfoKHR
respectively.

Since the headless backend has no effect when switching between FIFO
and FIFO_RELAXED, and the wayland backend does not support switching
presentation modes between MAILBOX and FIFO, the only real thing we
can do is check that the presentation mode requested is one that is
supported by the swapchain and is compatible with the current
presentation mode.

Change-Id: I8d5506e9b1a8fba079e2f9d6ee133038feb27dca
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
9edb068a38 Support deferred allocation
Adds support for VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT,
by deferring calling create_and_bind_swapchain_image in
acquire_next_image. Also, adds a function for checking if a swapchain
image can be bound to memory when deferred has been selected.

Change-Id: I22e40260d6b06091cc704bca3bf2baa80370c589
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
4adaa0b5eb Add support for VkSwapchainPresentFenceInfoEXT
Extends queue_submit to handle the fences passed by the application
through VkSwapchainPresentFenceInfoEXT.

Change-Id: If3f44e2634cc771ee7d01589a59a95d0f86f99df
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
01b4e9aeff Add a function for empty queue submit operations
Adds a helper function in synchronization.hpp, which makes an empty
vkQueueSubmit in order to chain wait with signal semaphores and fences.
This function is used in submit_wait_request and
fence_sync::set_payload.

Introduces queue_submit_semaphores for grouping the signal and wait
semaphores.

Change-Id: I6107a29f3410fad8250f998b0e4c2052ed1923b8
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:55 +01:00
Normunds Rieksts
d2b8eb3135 Add vkReleaseSwapchainImagesEXT entrypoint
Adds the vkReleaseSwapchainImagesEXT entrypoint in the WSI layer which
allows applications to release the acquired images back to the swapchain
without presenting them.

Change-Id: I52900547f95661e6ec40cb586b035da0ca2d266f
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:53 +01:00
Dennis Wildmark
8a74233de2 Add support for VK_KHR_shared_presentable_image for headless backend
Support for VK_KHR_shared_presentable image added in swapchain_base.
Headless backend will report support for it through
vkGetPhysicalDeviceSurfacePresentModesKHR.

Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Change-Id: Ibbbab0b8c8137fdd41df9889d7e183a8259c83ba
2024-04-30 08:28:21 +00:00
Embla Flatlandsmo
3fdda15be4 Add result store in VkBindImageMemory2KHR for maintenance6
For maintenance6, VkBindImageMemory2KHR should not return on
the first failure, but rather store the result and return it
after everything is bound.

Signed-off-by: Embla Flatlandsmo <embla.flatlandsmo@arm.com>
Change-Id: I2578d0ad0e6330ed9c091794e05cf5f24c876fb1
2024-03-01 07:27:36 +01:00
Jiyu Yang
5f1733d88b fix Use after free
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-10-31 08:54:05 +00:00
Normunds Rieksts
566a6ee68d Extend TRY macro to print out error messages
Extends the TRY macros exposed by the helper header to be able to print
out error messages.

Change-Id: I61c607376304ba744a95dd6782bb29653235096a
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2022-11-24 11:24:34 +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
Matteo Franchin
425b885f6e 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>
2022-07-21 19:05:53 +01: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
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
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
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
Iason Paraskevopoulos
1da8a30a6d Merge master branch into multiple_swapchains_present_req
Change-Id: Ibc6c094d85795e532e59184252896ecd05b50019
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2021-11-10 15:38:07 +00:00
Dennis Tsiang
080d5d2bf7 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>
2021-11-08 13:42:20 +00:00
Iason Paraskevopoulos
937552cc18 Use device allocator for stage flags vector
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I2b7882e10eca2f4cfbd3668b6265d5b6093c4272
2021-11-05 11:40:45 +00:00
Iason Paraskevopoulos
17204773df 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
2021-11-01 17:28:43 +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
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
Ben Davis
bcd934f2aa 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>
2021-08-09 11:38:04 +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
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
Rosen
3262341839 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>
2019-11-21 15:23:59 +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