Commit graph

220 commits

Author SHA1 Message Date
Alex Bates
ee3f6c5ab9 * Enables new warnings (which are made errors by -Werror)
* Wshadow warns when a variable shadows another
  * Wconversion warns on implicit int conversions
* Fixes warnings generated by them

Signed-off-by: Alex Bates <alex.bates@arm.com>
2025-12-17 09:55:55 +00:00
Iason Paraskevopoulos
80b43daffa Merge 'constness adjustment for clang20' into 'main'
See merge request mesa/vulkan-wsi-layer!223
2025-12-16 14:27:45 +00:00
Iason Paraskevopoulos
9c9dff2291 Add surfaces the layer supports in unsupported_surfaces
Extends the unsupported_surfaces_ext_array to contain surfaces
supported by the layer, when the layer is built without supporting them.

Also handles the presentWait2 feature similar to presentWait.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I2e61d56425ff657de949797be86436c9675d1b1f
2025-12-16 14:26:53 +00:00
Iason Paraskevopoulos
f596f8289f constness adjustment for clang20
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: Ib6fbcf6512a39fac7306ddcefb00846b336a92b3
2025-12-15 12:02:24 +00:00
Iason Paraskevopoulos
04d2ba65d5 Merge 'Detach proxies from queue' into 'main'
See merge request mesa/vulkan-wsi-layer!221
2025-12-11 16:28:57 +00:00
Normunds Rieksts
01a96ed37b The change makes the following adjustments:
* Changes the image state of ACQUIRED once the image has been presented as in shared present modes they are always in an acquired state.
* Removes thread free image semaphore signalling logic for shared present modes as there is only single image available and is always in an acquired state.
* Removes the reliance on the presentation thread for the shared present modes as it shouldn't be necessary for them as the headless mode does not share the buffer resource with any consumers.
* Adds the ability for swapchain_image class to not signal present fence for presentation request. On shared presentation modes we do not need to use the present fence and it cannot be used as the swapchain only has a single image.
* Adds support for present timing extension for shared present modes.
* When shared preset mode is used, the timings returned are always
* undefined as image is always in a state of being presented.

Change-Id: I6a5a7c744fe0fc115001de55a305d253695faf9f Signed-off-by: Normunds Rieksts normunds.rieksts@arm.com
2025-12-10 11:22:49 +00:00
Iason Paraskevopoulos
5e225e0896 Detach proxies from queue
Instead of destroying the wayland buffers from the private data
we just remove the proxies from the queue.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I0e9dd158feaffa697ea30b3c49d41661ec3d924c
2025-12-02 16:24:43 +00:00
Iason Paraskevopoulos
0866cfc352 Merge 'Fix a case where OOM condition was not checked' into 'main'
See merge request mesa/vulkan-wsi-layer!218
2025-12-02 14:36:52 +00:00
Iason Paraskevopoulos
d900831556 Fix queue destroy warning on the Wayland backend
Fixes an issue where the wl_queue used for the buffer events was
destroyed before destroying the wl_buffer objects.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: Ibe25f1f1f2100dda734c5f5788209ddf89c6d47d
2025-11-28 16:41:05 +00:00
Normunds Rieksts
e030203d82 Fix a case where OOM condition was not checked
Fixes a case where backing image memory creator allocation was not
checked for out of memory condition which results in failing OOM CTS
tests.

Change-Id: I6c203599eca5562f334d4e5e3f21c200dc667ee5
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-11-28 15:07:25 +00:00
Iason Paraskevopoulos
a0947a5ae8 Merge 'Fix and enhance Vulkan present timing and time domain handling' into 'main'
See merge request mesa/vulkan-wsi-layer!214
2025-11-25 10:12:34 +00:00
Ginu Jacob
71a0881d5c This change updates the present timing implementation with several fixes and improvements for better spec compliance:
* Updated present timing logic and corrected macros to match Vulkan specification values.
* Added support for vkGetPhysicalDeviceCalibrateableTimeDomainsKHR to include stage-local time domains.
* Updated handling of VK_TIME_DOMAIN_DEVICE_KHR to return timestamps in nanoseconds.
* Modified vkGetPastPresentationTimingEXT to allow retrieval of records without requiring presentIds.
* Improved vkQueuePresentKHR to terminate early when the present timing queue is full.
* Fixed VkPastPresentationTimingEXT::presentStageCount to correctly report the number of stages containing definitive results.

Signed-off-by: Ginu Jacob ginu.jacob@arm.com
2025-11-25 10:12:33 +00:00
Normunds Rieksts
2d4cbd5afa Decouple swapchain images and their memory from swapchain class
Decouples the swapchain images and their memory binder/allocator logic into separate classes. This allows us to reduce code duplication across different backends that use the same type of allocation logic and also allows us to make use of RAII to release the resources for swapchain images.

The swapchain_base and other swapchain classes have been refactored to handle the new swapchain images.

The patch makes the following adjustments:

* Introduces a new swapchain_image class that holds all swapchain image resources
* Introduces a swapchain image factory class that constructs swapchain images
* Introduces a Vulkan image handle class that is responsible for constructing VkImage handles
* Introduces a new interface that describes how swapchain backing memory is being allocated
* As part of this backing memory interface, introduces device and external (wsialloc) backing memory classes
* Introduces a new interface that holds swapchain image data like wl_buffers
* Refactors lots of swapchain image parts out of the base swapchain class and moves it into the respective backends to simplify the swapchain classes.
2025-11-20 13:55:45 +00:00
Lior Dekel
65078fb361 Adding debug interface
Added new debug file with function that exposes the
DRM modifier of a swapchain image buffer.
Building the layer with DEBUG=1 flag will result
building this file and tests can now get the modifier
value for assertions.

Signed-off-by: Lior Dekel <lior.dekel@arm.com>
Change-Id: I97a44dbda87b7cdb8984576aab613612f2f12a55
2025-11-04 12:20:24 +00:00
Normunds Rieksts
9d9172fcbb Add a workaround when wp_feedback events are not delivered
Adds a workaround for compositors that do not deliver
wp_presentation_feedback events when images are submitted to the
compositor in quick succession resulting in some of them being
discarded by handling it in buffer_release event instead.

Additionally fixes a double-free bug when presentation_feedback was
replaced using move semantics.

Change-Id: I97715ffbc45c3c869f84e57dca532d3a58ad3b67
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2025-10-31 10:35:08 +00:00
Iason Paraskevopoulos
3da272878d Reset query pool on creation
Makes use of the VK_QUERY_POOL_CREATE_RESET_BIT_KHR when creating the
query pool. It disables present timing when VK_KHR_maintenance9 is not
supported by the device.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I9d364050f0cd4a2be74e1b1d44cf3f6a0795e6f4
2025-10-17 15:02:40 +00:00
Ginu Jacob
ff882b5f84 Updating the api version to 1.4.325
Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I0808c23a48ea7c11341cf93b342ca6c76a577c8a
2025-10-10 12:36:02 +01:00
Rosen Zhelev
93a5d29657 Merge 'Support nonzero present timing queue family' into 'main'
See merge request mesa/vulkan-wsi-layer!186
2025-10-06 11:27:35 +01:00
Alex Bates
ace729f7f8 Support nonzero present timing queue family
Adds a per-device check for a 'best' queue family to
use for present timing, rather than always using index 0.

wsi_ext_present_timing holds resources (such as the command
buffer) per queue family, rather than supporting only one. However,
currently, only one queue family is supported at a time.
In future, we can hook vkGetDeviceQueue calls to map
VkQueues to their family index. Doing this will transparently
give present timing support for multiple queue families.

Signed-off-by: Alex Bates <alex.bates@arm.com>
Change-Id: I5becb29dfc4a082e301031e0c693acd23eb95a51
2025-10-06 11:27:34 +01:00
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
Nir Ekhauz
8c65fb2af7 Update the layer's readme and release notes with VK_KHR_present_wait2 support
1. Update the README file.
2. Remove the guards from the code.

Signed-off-by: Nir.Ekhauz <nir.ekhauz@arm.com>
Change-Id: Idf65baee25d09a3b4bc3b563455468bac4d5bddf
2025-09-18 10:20:43 +01:00
Nir Ekhauz
ee6d45430f Fix Wayland swapchain to support present_id2
Adding support for present_id2

Signed-off-by: Nir.Ekhauz <nir.ekhauz@arm.com>
Change-Id: Ie30caf423902fea9f2bc3341c3b61390b09c0f7c
2025-09-17 10:20:46 +01:00
Ginu Jacob
7a46cdb679 Implement schedule present at relative time on headless
In this change, the schedule present at relative time is enabled for
headless backend.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I15ff8170dfe93539e4c9a7ff20868b0916129546
2025-09-15 12:40:06 +01:00
Iason Paraskevopoulos
681648c9e9 Merge 'Query pool reads for QUEUE_OPERATIONS_END_BIT_EXT skipped when not ready' into 'main'
See merge request mesa/vulkan-wsi-layer!198
2025-09-11 15:47:13 +00: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
Rosen Zhelev
22502056af Merge 'Set the default DRM device node for the VK_KHR_display backend' into 'main'
See merge request mesa/vulkan-wsi-layer!196
2025-09-11 11:50:02 +01:00
Fufu Fang
5e53d9637f Scan DRM device nodes for the VK_KHR_display backend
To specify a DRM device node for the VK_KHR_display backend,
WSI_DISPLAY_DRI_DEV environment variable needs to be set. If
WSI_DISPLAY_DRI_DEV is not set, the VK_KHR_display backend
now scans all DRM device node, and uses the first node
that has a display connected.

Signed-off-by: Fufu Fang <fufu.fang@arm.com>
Change-Id: Idbcda60cf3b1656784e6d3b0547cc70e99f0fc52
2025-09-11 11:50:01 +01:00
Maged Elnaggar
fb23a9b14e Support VK_KHR_swapchain_mutable_format extension
- Add support for VK_KHR_swapchain_mutable_format extension to the Layer.
- Expose support for the VK_KHR_swapchain_mutable_format extension.
- Improve find_extension helper API to be spec-correct, const-correct,
  and clearer by using the right base type (VkBaseInStructure for input,
  VkBaseOutStructure for output),
  and concise docs explaining it returns the first matching struct or nullptr.
- Correctly use image_create_info instead of m_image_create_info in
  create_swapchain_image function for Wayland.

Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com>
Change-Id: Id40b28977e63ba76012d3a8f693327f757d75dcd
2025-09-11 09:28:03 +01:00
Maged Elnaggar
9608f70237 Add clang-tidy linting to merge requests CI
Introduce a new clang_tidy job that runs on merge requests
and the default branch. The job configures CMake to export
compile_commands.json and runs run-clang-tidy restricted to
repo files. Any warnings or errors cause the job to fail.

Artifacts include clang-tidy.log and compile_commands.json
to aid local reproduction. Shared Vulkan Loader setup was
factored into a YAML anchor for reuse across jobs.

Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com>
Change-Id: I61b48656e68e0e83725500ae1b37f8626f9a248c
2025-09-10 14:31:35 +01: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
Nir Ekhauz
64c1c46609 Initial support for VK_KHR_present_wait2
Add support for present wait2 ext. for physical, surface and sc.

Signed-off-by: Nir.Ekhauz <nir.ekhauz@arm.com>
Change-Id: I0f7cdadb2d3ea0ecbc32b8b2efe9fc3bb4ba0369
2025-08-26 13:42:14 +01:00
Nir Ekhauz
7fac7b1339 Update the layer's readme and release notes with VK_KHR_present_id2 support
Removed experimental flags around this extension.

Signed-off-by: Nir.Ekhauz <nir.ekhauz@arm.com>
Change-Id: If314e8c05d0f0fd7405379fe1c714f0e56519b4b
2025-08-20 12:45:46 +01:00
Rosen Zhelev
a0700e3e86 Merge 'Add initial support for VK_KHR_present_id2 in the layer' into 'main'
See merge request mesa/vulkan-wsi-layer!181
2025-08-13 09:41:22 +01:00
Nir Ekhauz
472597ed42 Add initial support for VK_KHR_present_id2 in the layer
Add support for present id2 ext.

Signed-off-by: Nir.Ekhauz <nir.ekhauz@arm.com>
Change-Id: Ic4cf137158188e9b6db1fa999f2c61248456c139
2025-08-13 09:41:21 +01:00
Maged Elnaggar
d1ade3d218 Append WSI layer warning flags
- switch CMAKE_CXX_FLAGS and C_FLAGS to string(APPEND)
- concatenate flags without semicolons or list issues
- preserve existing: -Wall -Werror -Wextra -pthread -fPIC
- add new diagnostics:
  Wdouble-promotion, Wnon-virtual-dtor,
  Wdelete-non-virtual-dtor, Woverloaded-virtual,
  Wcast-qual, Wmissing-field-initializers,
  Werror=return-type, Wmissing-format-attribute
- add C-only check: -Wstrict-prototypes

Change-Id: Icae6cf649b9ab88c1d0bc736b91b4bc50e24c9dd
Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com>
2025-08-05 13:34:59 +01:00
Iason Paraskevopoulos
050b43c769 Merge 'Implement scheduling for headless present stages' into 'main'
See merge request mesa/vulkan-wsi-layer!184
2025-07-30 12:27:09 +00: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
27430b2138 Retry mechanism for Wayland image presented event
In this change, when performing dispatch_queue for the present timing
VK_PRESENT_STAGE_IMAGE_FIRST_PIXEL_OUT_BIT_EXT stage a retry mechanism
is implemented to dispatch Wayland events until there are no more
events in the queue or till we get the Wayland presented event.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: Ieb9c2f3360d6f7c06167fb8096a398adaf71cdd2
2025-07-28 11:53:10 +01: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
Rosen Zhelev
d0a267380c Merge 'Missing return wsi_alloc_utils.hpp in WSI layer' into 'main'
See merge request mesa/vulkan-wsi-layer!183
2025-07-22 14:47:13 +01:00
Maged Elnaggar
5dbb34a16d Missing return wsi_alloc_utils.hpp in WSI layer
Ensure the move-assignment operator in
swapchain_wsialloc_allocator returns *this on all
code paths. This avoids undefined behavior and satisfies
the function’s return type requirements.

Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com>
Change-Id: I99762484d7a02c24a4632a7a84b415a3842d02a3
2025-07-21 14:30:08 +01: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
Iason Paraskevopoulos
8b7103e0e3 Merge 'Improve wait_for_pending_buffers' into 'main'
See merge request mesa/vulkan-wsi-layer!175
2025-07-18 11:44:25 +00: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
f879ceeeee Merge 'Tighten extension gating, filtering, and exposure logic' into 'main'
See merge request mesa/vulkan-wsi-layer!174
2025-06-27 15:21:58 +00:00