Commit graph

132 commits

Author SHA1 Message Date
Ginu Jacob
27aecc165e Support timestamp calibration for present stage local time domains
In this change, the support for present stage local time doimain
is enabled. The Vulkan entry-points vkGetCalibratedTimestampsEXT and
vkGetCalibratedTimestampsKHR are introduced. These entry-points are
intercepted for the structure VkSwapchainCalibratedTimestampInfoEXT
to calibrate any stage local time domains.

Internally, the stage local time domains are mapped to VK time
domains with an offset. On intercepting the APIs when the structure
VkSwapchainCalibratedTimestampInfoEXT is available, timestamps
are internally queried based on VK time domain from the driver and are
then converted to the corresponding stage local timestamps using the
internally maintained offset for the time domain.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I635e1bc27dd40540cc5e016ab5f784f9d8ebd333
2025-04-03 16:11:31 +01:00
Dennis Tsiang
bd54fc460b Update entrypoint list documentation with the alias parameter
The comment explaining the format for the entrypoint entries are
updated to include the new alias parameter.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I34b0d1247a010b0e60b19bb284bb6bdaf32eab23
2025-04-03 11:55:02 +01:00
Dennis Tsiang
928514385b Make layer use non-KHR commands for promoted entrypoints
Some entrypoints when promoted lose the KHR suffix. Some ICDs only
provide the non-KHR versions and the KHR versions are unavailable
unless the associated extension is explicitly enabled. This change
makes the layer's dispatch table internally convert any promoted KHR
entrypoint calls to the non-KHR version when the the Vulkan API is of
sufficient level.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I556c9071b738e15ef5fd2f970a8443b1c5215b16
2025-04-02 18:44:47 +01:00
Alex Bates
4eb145cf8b Handle VkPhysicalDevicePresentWaitFeaturesKHR
Advertises support for present wait in vkGetPhysicalDeviceFeatures2KHR when all surface extensions are supported. If there are unsupported extensions, present wait feature advertisement is left to lower layers.
2025-04-01 09:29:51 +00:00
Dennis Tsiang
201914d7cc Make layer require VK_KHR_bind_memory2 extension and intercept KHR
Enables the layer to intercept vkBindImageMemory2KHR, and by requiring
the extension we ensure we can always call the entrypoint down the
chain as well.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I1ec5f8c6ba648151e08101549cb795e990c84aeb
2025-03-31 13:42:18 +01:00
Rosen Zhelev
0562f6c433 Merge 'Fix the bugs with function dispatcher and swapchain handling' into 'main'
See merge request mesa/vulkan-wsi-layer!145
2025-03-14 16:15:36 +00:00
Normunds Rieksts
637b847465 Fix the bugs with function dispatcher and swapchain handling
Fixes two bugs:
  - The handling when swapchains are destroyed when VK_NULL_HANDLE is
    passed for the vkDestroySwapchain function to terminate early rather
    than forward it to any dispatch functions below us which could
    potentially not be exported by the layers/ICDs below us.
  - The dispatcher did not implement get_fn() correctly as if the
    function that we attempted to acquire was NULL, this function still
    returned a valid std::optional with the function pointer itself
    being set to NULL if no layers/ICDs under ours did not implement
    these entrypoints. This fixes other issues that could arise in the
    layer when this function is used.

Change-Id: If4fb67c246ef48a97f88914acfb8db3df734b133
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-03-13 17:47:43 +00:00
Dennis Tsiang
ce542a16a3 Change the condition to add extensions to the layer 2025-03-12 10:25:28 +00:00
Normunds Rieksts
279896dda6 Merge branch 'main' of upstream into 'ext_refactor'
Merges upstream 'main' into 'ext_refactor' branch and fix merge
conflict.

Change-Id: I718ec54cb11b7f456d713728b976c61ea7811eb0
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-02-17 15:49:21 +00:00
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
Angeliki Agathi Tsintzira
03804c74fe Remove guards on swapchain maintenance features
The development of the swapchain maintenance features
has been finalized. As a result, the temporary guards
used during development have been removed, as they are
no longer necessary.

Change-Id: I768358d4b650ba13c84af1a65ff407f2c44b2283
Signed-off-by: Angeliki Agathi Tsintzira <angelikiagathi.tsintzira@arm.com>
2025-02-06 21:51:35 +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
Rosen Zhelev
8b18c35cb3 Merge 'Re-add assertion to check for valid synchronisation primitives' into 'main'
See merge request mesa/vulkan-wsi-layer!128
2024-12-02 16:23:05 +00:00
Angeliki Agathi Tsintzira
3051ca8b67 Add vkGetSwapchainTimeDomainPropertiesEXT support 2024-11-15 12:49:31 +00:00
Normunds Rieksts
91edd710b7 Pass frame boundary events unconditionally 2024-11-13 17:09:48 +00:00
Normunds Rieksts
484d906a86 Re-add assertion to check for valid synchronisation primitives
Re-adds assertion that checked that valid synchronisation primitives
were passed to vkAcquireNextImageKHR due to failing CTS tests that were
breaking the Vulkan spec. After fixing the tests, the assertion is no
longer necessary

Change-Id: Ic600714be4012575b6d7e4f568ea54cbf2e0ca4f
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2024-11-06 15:06:33 +00:00
Rosen Zhelev
e8cacef0de Merge 'Handle VkPresentTimingsInfoEXT' into 'main'
See merge request mesa/vulkan-wsi-layer!116
2024-10-16 09:40:28 +00:00
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
Dennis Tsiang
c859eef158 Fix bug in frame boundary feature
In submit_wait_request we were passing the memory location of the
pointer to submission_pnext instead of the actual pointer. This commit
fixes it to pass the actual pointer. Additionally when creating the
frame boundary, set the pNext explicitly to nullptr.

Change-Id: I61ab9c898c3af4b3f401a3de6fdf7201fd2553ac
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2024-10-10 10:26:52 +01:00
Normunds Rieksts
94dd9840c9 Implement support for marking frame boundaries 2024-10-01 15:18:22 +00:00
ginujacob
0cee10aa6f Advertise VK_EXT_present_timing features.
Enabling the VK_EXT_present_timing features
VkPhysicalDevicePresentTimingFeaturesEXT and
VkPresentTimingSurfaceCapabilitiesEXT.

The feature values are updated based on the backend.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: Ie322f58118108c656530128b18ec905bd6815c63
2024-09-17 11:31:46 +01:00
Rosen Zhelev
e7c95099b6 Merge 'Guard swapchain maintenance features with experimental flag' into 'main'
See merge request mesa/vulkan-wsi-layer!108
2024-09-16 13:23:03 +00:00
Dennis Tsiang
7e27d1d762 Guard swapchain maintenance features with experimental flag
The feature is still experimental so we should guard it with the flag
until it's ready to be used.

Change-Id: I3f10f730ca916374241fdcdceaf332672788040d
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2024-09-05 16:52:48 +01: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
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
Fufu Fang
743f00f9bb Merge branch 'main' into 'swapchain_maintenance_new' 2024-08-19 12:20:16 +00:00
ginujacob
0a293fcfa9 VK_EXT_present_timing changes for the layer's json file.
Adding the entry-points and definitions required for the
VK_EXT_present_timing feature.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I5f388b50d12fe32556676c4de0d37c95e1ff611b
2024-08-15 12:01:36 +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 Tsiang
8e02a7ffe3 Add support for present mode compatibility
This commit adds support for querying a surface's compatible
presentation modes via VkSurfacePresentModeEXT and
VkSurfacePresentModeCompatibilityEXT, as part of the
VK_EXT_surface_maintenance1 extension.

A new struct present_mode_compatibility has been created to capture
this new functionality.

Our headless implementation supports compability between FIFO and
FIFO_RELAXED. On Wayland, we do not allow compatibility between FIFO
and MAILBOX presentation.

Change-Id: I53659cb2f2aa0ac41e37975cc34aee3ce8317a73
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:26:54 +01: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
Dennis Wildmark
e62cc2d42f VK_KHR_display swapchain implementation
Implementation of VK_KHR_display swapchain class. VK_KHR_display is
another WSI backend that provides surfaces to render directly to a
display. The swapchain class is responsible for creating and managing a
swapchain based on the specific type of surface provided by
VK_KHR_display.

Change-Id: I9b103c20c3444b1ca75f3df7edf6b66fc87a0992
Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-12 11:44:22 +00:00
Dennis Wildmark
8da77f2b8b VK_KHR_display surface_properties implementation
Implementation of the surface_properties interface for VK_KHR_display.

Change-Id: Idd3b53bec0d0a829478d51b4263db767c872d0e5
Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-12 11:44:22 +00: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
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
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
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
Jiyu Yang
5f1733d88b fix Use after free
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-10-31 08:54:05 +00:00
Angeliki Agathi Tsintzira
188ffe6a26 Enable instance extensions
Modify the layer so that instance extensions needed for Wayland are only enabled when Wayland is selected.

In the past, the layer was changed to explicitly enable the instance extensions it needs in the intercepted calls to vkCreateInstance. Therefore, the layers always enabled the extension VK_KHR_external_memory_capabilities, despite this is only required by Wayland.

In this patch, this extension is only enabled when Wayland is enabled, i.e. when VK_KHR_wayland_surface is part of the extensions passed to vkCreateInstance.

Signed-off-by: Angeliki Agathi Tsintzira <angelikiagathi.tsintzira@arm.com>
Change-Id: I57e98b36e42012ba46769e9dd760a628a09b9ba5
2023-09-28 09:35:19 +01:00
Normunds Rieksts
43d806de38 Replace VK_LAYER_EXPORT with VWL_VKAPI_EXPORT 2023-04-17 10:59:19 +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
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
Lior Dekel
908518c92e Adding VK_KHR_shared_presentable_image basic support
To comply with ICDs that expose the
VK_KHR_shared_presentable_image extension, the Layer needs to
handle VkSharedPresentSurfaceCapabilitiesKHR struct (holds
sType=VK_STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR)
for queries on the VkSurfaces managed by the Layer.
A simple implementation that sets the minimum required flags is
provided in this commit.
Since no WSI layer swapchain will support the shared presentable modes,
no other functionality is required. VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
must be included in the sharedPresentSupportedUsageFlags field but
implementations may support additional usages.

Signed-off-by: Lior Dekel <lior.dekel@arm.com>
Change-Id: I73b29e54a84376c663b3cada989c910d1ba27293
2022-09-13 13:46:39 +03: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