Add support for format modifiers in framebuffers using
drmModeAddFB2WithModifiers.
Add compilation flag to force VK_KHR_display to not support format
modifiers for framebuffers.
Change-Id: Ie8eb2e96e543a15ab3534a7e73425f277a4b7d58
Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
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>
Make the drm_display class a singleton and automatically initialize the
display. Add environment variable for configuring display device.
Change-Id: I869fbf7414bc4a2270b3583577050b7cd8c5b184
Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Implementation of the surface_properties interface for VK_KHR_display.
Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Change-Id: Idd3b53bec0d0a829478d51b4263db767c872d0e5
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>
Changed log level type from long to int, since value is
expected to be a small integer in range [0-3].
Since codebase requires C++17 also replaced strtol with
std::from_chars(), which will parse string as int, and skip updating
the defaut value if VULKAN_WSI_DEBUG_LEVEL env var does not represent
int.
Signed-off-by: Daniel Levin <daniel.levin@amd.com>
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
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
This keeps it closer to where the rest of the external_memory
parameters are set.
Change-Id: Ibc46e90cebc6d715003772cc78294e164085cfa6
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Fixes a bug in queue submission where the wrong amount of
VkPipelineStageFlags were passed to vkQueueSubmit when the number of
semaphores to wait on were more than 1.
Change-Id: Ic66e0c6a5e4f60659a0fb31c64c565820d4708a8
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
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>
A lot of the steps involved in creating a VkImage, allocating backing
memory, and binding the VkImage to the memory do not rely specifically
on Wayland features and could be common to other WSI backends.
This commit attempts to decouple the create_and_bind_swapchain_image()
function in the wsi/wayland/swapchain.cpp from Wayland and wsialloc
specific parts, and instead move the independent parts related to
external memory management to a new external_memory class. This will
allow the independent code to be re-used in future WSI backends.
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I8c13ccbbfaef0d345fcd06192e6de484dd53645f
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
3 is not enough for performance testing. Let us double the maximum
number we can make.
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I11a055ede33c9d10311109085e59d3f8c1fbcb7e
Replaced call to unsafe function strcpy() with call to snprintf().
Signed-off-by: Aron Virginas-Tar <aron.virginas-tar@arm.com>
Change-Id: I0de5f869200e74b6d0c8224da2e41d6c4b8b6f4d
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>
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
Adds a guide on implementing a WSI backend and extra documentation in
a few functions in swapchain_base.
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: Ibdc702a05605989940966aae168331268c1ce2ba
The layer needs functionality that is not part of Vulkan 1.0 and is
provided by either Vulkan 1.1 or separate Vulkan extensions.
The layer used to solve this issue by bumping the API version passed
by the application in VkCreateInfo to 1.1 if this was set to 1.0.
This workaround does not seem to be working anymore with recent
versions of the loader. Fortunately, the loader now allows layers
to change the extension lists passed by the application.
This patch changes the layer to use this approach and removes the
API bump logic.
Documentation is updated accordingly.
Change-Id: I61c426311612c7f288a0f7d969782d6c5365acf5
Signed-off-by: Matteo Franchin <matteo.franchin@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
Adds support for the VK_KHR_get_surface_capabilities2 extension.
Change-Id: Iae882a41819baf413a0ba949ec44d6e722ebca5a
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
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>
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
When a file descriptor is imported in Vulkan as a dma buf the Vulkan
implementation takes ownership. We use this property to manage the
lifetime of file descriptors allocated by WSIALLOC by importing them as
VkDeviceMemory. After import the WSI Layer doesn't need to close any
file descriptors and instead only needs to destroy the VkDeviceMemory
object.
However after import the original file descriptor should not be used by
the application. Currently the WSI Layer Wayland implementation violates
this by using the FD to pass to the compositor. This commit fixes the
issue by initiating the Wayland requests before importing the fd.
Internally libwayland will duplicate the fd.
Change-Id: I3ca877f90f0139cf23b8b39c6024e8815b82d692
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Users should use CMAKE_BUILD_TYPE to set the build type
Change-Id: I526b3a96f798a39ceca11674bf1e0b6964a3da7d
Signed-off-by: Ben Davis <ben.davis@arm.com>
Fixes a nulltpr dereference when a buffer release event is processed on
deprecated swapchains. In such a case some of the swapchain images are
invalid and associated resources have been freed.
Change-Id: I8f1c66e42e900d63c8c43cb53068a8aee9ea25a9
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Previously the calculation for total_size was done in 32-bits, as the
operands were all 32-bit signed or unsigned integers. This led to
integer overflow when the extent being allocated is too large.
total_size is finally cast to size_t, as the kernel UAPI for ION uses
size_t.
Change-Id: I7a76b2c18be25fda0bf6ef70cd8a6fe717c2903c
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
Include the modifiers in the call to zwp_linux_buffer_params_v1_add
Change-Id: If4407af5f402a418b69a670d316fe56cce9f2a14
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
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>
Add additional checks ensuring required protocols are supported.
Currently Version 3 of zwp_linux_dmabuf_v1 and Version 1 of
zwp_linux_explicit_synchronization_v1 are required.
Change-Id: Ie1ed37a22254eb14ebdb9cc7d3a35fc99fcb4481
Signed-off-by: Ben Davis <ben.davis@arm.com>
The extension list now calls abort() if an extension name exceeding
the length limit is copied.
Change-Id: I105946b647ebd0087dc892d7c8a227628da31966
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
By removing this option, the layer will be enabled by default.
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
Change-Id: I6d62e770d914098ad6f0d7d74fb45ce3f8fdbc01