Commit graph

30 commits

Author SHA1 Message Date
Ginu Jacob
7d88e2a619 present_id2 dependency handling in present_timing extension
The present_timing extension depends on present_id2. The dependency
handling is incorrect and is fixed in this change.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: Id645450eeb5b22551f328a860ffec75ebdbfbc79
2025-09-29 16:11:01 +01:00
Ginu Jacob
5a2bc13570 VK_EXT_frame_boundary: Fixing the sType used in VkFrameBoundaryEXT
In this change, the sType used in VkFrameBoundaryEXT instance is fixed.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: Id1dab87b9b4144d6030c57dbe4e33a41e7045a9f
2025-09-22 16:31:11 +01:00
Ginu Jacob
1346705513 Query pool reads for QUEUE_OPERATIONS_END_BIT_EXT skipped when not ready
In this change, the return status from query pool reads for
QUEUE_OPERATIONS_END_BIT_EXT are checked and skipped when not ready.
To cater for correctness of any later reads, the value returned is
cached and compared. Additionally, a fix is added to avoid data
corruption with presentation feedback object in present timing when
vector was used.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I5f26b6a3c81eb73eff8a4073be7d7ffc81f9eef8
2025-09-11 15:47:13 +00:00
Maged Elnaggar
78b21da4ef Adding exception-safe custom mutex to the WSI layer
Introduce util::mutex, util::recursive_mutex
and util::unique_lock; switch WSI layer call sites to it.
All locks are acquired via try_lock(), no system_error leaks.

Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com>
Change-Id: Ide9ef4318be7cc47e9577059695cc298f8b8e579
2025-09-05 16:06:38 +01:00
Iason Paraskevopoulos
b02e682d30 Update present timing types
Updates the present timing implementation and types to be aligned with
the latest commit.

Fixes an issue, where the queue used for the presentation feedback
events was destroyed before getting the last events.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I1dba2fd0e4ad9ec8c02d71c58c93edceaa75d07e
2025-09-04 17:48:10 +01:00
Nir Ekhauz
5060dbbc3a Implement vkWaitForPresent2KHR
Add the entry point for VK_KHR_present_wait2.

Signed-off-by: Nir.Ekhauz <nir.ekhauz@arm.com>
Change-Id: I8b0ad681a6c02ea646d072e69b25113a8c8ad3ce
2025-08-28 15:46:50 +01:00
Normunds Rieksts
dfe88e3c1c The patch changes the following:
* Implement scheduling support for headless present stages.
* Fix a bug where present query stages were added to the internal queue when application did not request any.
* Change the implementation of present timing extension to store device_private_data rather than VkDevice as all queries require it.
* Document the shortcomings of implenting scheduling support for Wayland backends.

Change-Id: I050cc700a88bce476b350caf8cc23dfb551f4a0c 
Signed-off-by: Normunds Rieksts normunds.rieksts@arm.com
2025-07-30 12:27:09 +00:00
Ginu Jacob
d807a089c3 Timestamp for VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_OUT_BIT_EXT in Wayland
In this change, support for the presentation stage
VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_OUT_BIT_EXT is added for the Wayland
backend.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I866f8c55cfb6b69ba03761706d838ea17acf9651
2025-07-24 08:39:09 +00:00
Iason Paraskevopoulos
d344eeae70 Fix check for present_id feature in present timing
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I04f02372758d64ec8230d6f0ba9a6b5f882668cd
2025-07-18 15:26:54 +01:00
Alex Bates
c43dd058ed Implement monotonic stage timestamps on headless
Sets timestamps for `vkGetPastPresentationTimingEXT` for the remaining
present stages on headless:

- VK_PRESENT_STAGE_IMAGE_LATCHED_BIT_EXT
- VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_OUT_BIT_EXT
- VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_VISIBLE_BIT_EXT

These are all set to the same value: when swapchain::present_image is
called. It uses the best monotonic clock supported by the driver.

No need for slot member variables to be atomic any more because they
are only accessed while a lock on m_queue_mutex is held.

Signed-off-by: Alex Bates <alex.bates@arm.com>
Change-Id: I90ffc876890ee74620b7ba8da753794cae51dd36
2025-07-18 11:39:41 +00:00
Maged Elnaggar
3ffd85a26d Update time domain handling to comply with Vulkan spec
- Refactor vkGetSwapchainTimeDomainPropertiesEXT to follow spec
- Ensure all time values are returned in nanoseconds
  according to the active time domain

Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com>
Change-Id: Id4c6b86577bd509ec7bb5a946785dbe6642cfb1c
2025-07-11 10:13:34 +00:00
Iason Paraskevopoulos
7c58549ec2 Add VkPastPresentationTimingFlagBitsEXT
Handles VkPastPresentationTimingFlagBitsEXT in
VkPastPresentationTimingInfoEXT.

Changes present_timing_queue_set_size to return VK_NOT_READY when
queue_size is bigger thank m_queue.size().

Change-Id: I4f8038c2b0060cfdac30754234536aa9ce42acbb
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2025-07-02 16:51:17 +01:00
Iason Paraskevopoulos
b4896d3ab8 Reintroduce is pending
Change-Id: Ie5f2e9363df827d6b0e4e3ff83859bcd20106d62
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2025-06-26 18:21:09 +01:00
Iason Paraskevopoulos
1eee8ffea1 Improve implementation of vkGetPastPresentationTimingsEXT
Fixes a few issues with the vkGetPastPresentationTimingsEXT
implementation. In particular:
    - Entries with presentId = 0 are used to match entries in the
      internal queue that didn't have a presentId supplied in the
      presentation request.
    - pPresentationTimings is returned to the application without any
      holes.
    - The appropriate return code is returned.

Adds an m_set member in swapchain_presentation_timing in order to allow
marking entries as completed that didn't have a timestamp, e.g.
a presentation request was rejected by the presentation engine.

Adds a mutex for guarding accesses to the internal queue by functions
that can be called by the application.

Minor documentation updates.

Change-Id: Id56bfd039b341e7f540a5ed028e954c490d00dd5
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2025-06-26 08:14:17 +00:00
Alex Bates
441d95f1bb Adds support for present timing on Wayland even if the compositor does not support wp_presentation. Previously, support for wp_presentation was assumed.
If the time domain used by the compositor matches one of the time domains supported by the ICD:

* Advertise `VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_VISIBLE_BIT_EXT` in `VkPresentTimingSurfaceCapabilitiesEXT`
* List `VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_VISIBLE_BIT_EXT` in `swapchain_time_domains`

Also handles the case where neither `VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR` or `VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR` is supported for all backends.

Additionally fixes the issue where Wayland protocol was not dispatched correctly which resulted in Clock_ID event not being communicated back to the layer.

Signed-off-by: Alex Bates <alex.bates@arm.com>
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-06-18 12:15:41 +00:00
Normunds Rieksts
cedf53a2be Enables the present wait extension by default - experimental flag is no longer needed.
Fixes the following issues:

* For Wayland backend, populates the presentation feedback listener with all callbacks as it is considered a fault by the protocol to not implement those
* For Wayland backend presentation feedback listener, forwards the feedback_discarded event to present ID as there could be situations where previously submitted buffers are discarded, such as when swapchains are using the MAILBOX presentation mode.
* For all swapchains, communicate critical errors back to present wait extension as otherwise, all callers waiting that are waiting on present to be delivered in vkWaitForPresentKHR call will never exit.
* Expanded the implementation in vkWaitForPresentKHR to be able to return critical swapchain errors if they have occured during the wait time.
* Fix issues in present ID where infinite waits could result in the vkWaitForPresentKHR call returning immediately due to UINT64_MAX timeout resulting in overflowing the system clock used in std::condition_variable

Change-Id: I1e475c3073c05394db259657eae1da21764a5a5c
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Alex Bates <alex.bates@arm.com>
2025-06-06 16:41:12 +00:00
Ginu Jacob
ef9b6eed8c Improvement for present timing stages
In this change, handling for the present timings stages are improved.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I68e9ae67fa94d39e23504890d922a85bdce938cd
2025-06-06 09:56:17 +00:00
Ginu Jacob
5d4b84408a Acquiring timings for VK_PRESENT_STAGE_QUEUE_OPERATIONS_END_BIT_EXT 2025-05-28 15:59:16 +00:00
Normunds Rieksts
3c82178968 Fix compile error due to missing include 2025-05-16 18:06:42 +00:00
Ginu Jacob
29ee099f25 Use the KHR version for vkGetCalibratedTimestamps
In this change, instead of checking the available version for
vkGetCalibratedTimestamps between KHR and EXT, unconditionally use the
KHR version in VK_EXT_present_timing as the extension has a dependency
on VK_KHR_calibrated_timestamps extension.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I279182ae6d5311613c430546a8054dee0276c499
2025-05-14 16:32:07 +01:00
Normunds Rieksts
ab138f30ef Implement vkWaitForPresentKHR entrypoint 2025-05-09 16:04:39 +00:00
shamao01
c95e1a9f96 Add missing array include to present_timing_handler
Change-Id: I0d01c29c1b115053aae3c4b606b8d24467ffe48c
Signed-off-by: shamao01 <shai.maor@arm.com>
2025-04-10 13:14:38 +00:00
Dennis Tsiang
2d1b682129 Use wp_presentation_feedback to update the presented ID value 2025-04-01 09:27:18 +00:00
Rosen Zhelev
64175e7666 Merge 'Fix regression with swapchain_maintenance' into 'main'
See merge request mesa/vulkan-wsi-layer!144
2025-03-13 16:46:30 +00:00
Normunds Rieksts
5885ad4836 Fix issue with swapchain_time_domain not having virtual destructor 2025-03-10 16:12:27 +00:00
Normunds Rieksts
ad47eb201f Fix regression with swapchain_maintenance
Fixes a regression with swapchain_maintenance1 extension after extension
refactor that did not communicate the changed presentation mode back to
the swapchain and improperly checked whether swapchain supports
presentation modes at swapchain creation time when this extension was
being used.

Change-Id: If06d3c72b44c8f3a06728b4c5c2455346c97ad63
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-03-07 17:51:20 +00:00
Normunds Rieksts
6ae7c7f452 Fix compiler warnings when building the layer
Fixes issues that generate warnings when building under specific
compiler versions.

Change-Id: I2a90429c7b56658be06ddd46fa8acfd660cafdd0
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-02-24 13:38:23 +00:00
Normunds Rieksts
67fb41be2d Fix bugs with vkGetSwapchainTimeDomainPropertiesEXT entrypoint
Fixes bugs with the vkGetSwapchainTimeDomainPropertiesEXT entrypoint:
  - The time domains counter identifies the current list of available
    time domains
  - The time domain properties correctly reports the available time
    domains and returns them to the application

Change-Id: Ic69578bd93804e823e27879f9f2ee1a5d49a01ce
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-02-11 16:48:00 +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
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