- 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
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
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
* 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
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
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
Changes wait_for_pending_buffers to not call wait_for_free_buffer
if there are already free buffers. The reason is that
wait_for_free_buffer consumes the m_free_image_semaphore, which is ok
when it is done by acquire_next_image but wrong when it is done
by wait_for_pending_buffers which doesn't acquire any images. A side
effect of this could be that subsequent calls might
block if it they called after wait_for_pending_buffers and
there was only one free image remaining.
Renames wait_for_free_buffer to wait_and_get_free_buffer to better
communication that the semaphore is decremented after in the function.
Change-Id: Ie88fa435ba5805066d7bf13fce9fb2ce4c966cef
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
In this change, handling for the present timings stages are improved.
Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I68e9ae67fa94d39e23504890d922a85bdce938cd
Adds missing documentation and changes
swapchain_image_creator::add_extensions to take a reference instead of a
pointer.
Change-Id: I0f2fc2017e00901c74113bbd0ed99a18cb9bf01e
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Modifies swapchain_base::init to get a device queue only when external sync is not supported.
Signed-off-by: Iason Paraskevopoulos iason.paraskevopoulos@arm.com
Change-Id: I638f4e75cfa9848f415ce1c9776cb8de82f24ca1
Adds a new class named swapchain_image_creator, which will be
responsible for owning and extending image create info.
Change-Id: Icdda2304698e110d4c0d52caa6b7c1fe59c383a9
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
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>
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>
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>
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
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>
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>
Add support for handling VkSwapchainPresentScalingCreateInfoEXT and
VkSurfacePresentScalingCapabilitiesEXT, as part of the
swapchain_maintenance1 and surface_maintenance1 features.
On Wayland, we will report support for ONE_TO_ONE scaling (i.e. no
scaling) and a default gravity of top left. On Headless, we report 0
scaling support as there's no presentation engine anyway.
Change-Id: Ife41e7e06109bd917fa480b07e447008c9a4f9e1
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
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>
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>
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>
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>
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
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
When fences are imported with a handle type with copy payload transference semantics then the flags must contain VK_FENCE_IMPORT_TEMPORARY_BIT
Change-Id: I950a01465ed68e7c5b35ea17a778ee7327639108
Signed-off-by: Normunds Rieksts normunds.rieksts@arm.com
Vulkan spec mandates that if handleType of VkImportSemaphoreFdInfoKHR
refers to a handle type with copy payload transference semantics
(which VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT is), then flags
must contain VK_SEMAPHORE_IMPORT_TEMPORARY_BIT.
Change-Id: I426bc4749da48aa12aee55eaa3a1739c7226e8e8
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
VK_ERROR_DEVICE_LOST implies that the GPU device has entered an
unrecoverable state and further API usage is considered invalid. Thus,
it should be used sparingly. For the layer code, we were returning
VK_ERROR_DEVICE_LOST for implementation specific errors as sort of a
catch all, even when the GPU was still usable. Instead, it would be
better to return other error codes to denote a failure somewhere.
For the page_flip_thread, if we receive a VK_TIMEOUT waiting for the
image's present fence, then we continously retry. All
other error codes will still be propagated.
For the wayland swapchain, instead of returning VK_ERROR_DEVICE_LOST
when we encounter an error in the dispatch_queue call, return
VK_ERROR_SURFACE_LOST_KHR, as this is more suitable.
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: Iccc3e75b60fe9296b10963e7f0b3041fbcd29198
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>
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
The VK_KHR_external_[fence|semaphore]_fd extensions allow sync
primitives to be signalled without the use of QueueSubmit. Using these
extensions in AcquireNextImage instead of using QueueSubmit offers two
advantages: (1) there is no waiting for work to complete in the queue
before the primitives are signalled and (2) there is no data race if
the application happens to call QueueSubmit on the same queue at the
same time.
The QueueSubmit method of signalling sync primitives continues to be
used for ICDs that do not support the external FD extensions.
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
Change-Id: Ib4a922d44430110e2353a4e0221e27017e72abab
If there exists two swapchains where one is a descendant of another, we
need to return VK_ERROR_OUT_OF_DATE_KHR error if the application tries
to present from the ancestor when the descendant has started presenting.
The has_descendant_started_presenting() function checks whether the
descendant has started presenting by looking for pending images in the
descendant's list of swapchain images. However, the descendant could
have already presented its pending image(s) before the ancestor arrives
at this check. In this scenario, the descendant will have marked the
swapchain image(s) as now free, and therefore when the ancestor looks
for pending images it will fail to find any. This causes the function to
incorrectly return false.
This bug can be resolved by creating a new boolean member variable to
track whether the swapchain has started presenting.
Change-Id: Ibc3399a4bb05f89940f0b595d25aa07b8e2a2cb8
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Fixes an issue, where acquire_next_image was always returning
VK_ERROR_OUT_OF_HOST_MEMORY when the swapchain had gone into a faulty
state.
Change-Id: Iafe016e4e31158d1a5f0d6d785f60d6a724c62ab
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Fix warnings given by clang-tidy 8 with checks 'bugprone-*,modernize-*'
Change-Id: I2e5660c5872728f957869c66b1143cfcc76bc20e
Signed-off-by: Ben Davis <ben.davis@arm.com>
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
Adds support for image presentation without relying on the page flipping
thread to communicate with the WSI backend.
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: I4fd2b937351fc484897dc7e9597aa6e81b37fbdf
We need to synchronise access to the ring buffer pool in order to avoid
concurrency bugs as multiple threads can mutate the state of the ring
buffer and if we do not serialise these changes then they can result in
errors.
Change-Id: If96e1707716370bcf57416cd505d16aa75c0d68c
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
The swapchain teardown waits for pending images incorrectly. The
regression caused the wait to complete before pending images were
processed as well as a hang when all images are acquired by the
application or pending presentation. In this case the swapchain
teardown would hang waiting on the last image presented by a compositor
that would never be released.
Fixing this exposes additional hangs when swapchain images update the
free semaphore after being marked as free. There are also potential
hangs if multiple threads are waiting for all pending images or
acquiring an image at the same time. These issues are addressed by
serializing those actions with a mutex.
Change-Id: I266c93a61333d59823f404ea6ba19fb343f46a13
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Fixes an issue, where in Wayland the new swapchain hanged during its
first image presentation in the page flipping thread when it waited for
the old swapchain to finish presenting its pending images. As the new
swapchain had started presenting destroy_image was called during the
unpresent function for the old swapchain and the image's status was set
to INVALID instead of FREE. So free_image_found never returned true and
subsequently get_free_buffer was blocked in the loop. The issue is fixed
by removing the call to destroy_image in unpresent_image as it is
redundant and is done in swapchain teardown.
Change-Id: I192607f50eb5e5f0e4e9baf66aedf02221f20b63
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>