summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-01-05Fix issues flagged by static analysisupstreamDennis Tsiang1-3/+13
Add error handling to snprintf. Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com> Change-Id: Id0c0478254c57cb62af6f9cadde16f73b071f466
2023-11-01Fix validation error when importing sync fdsDennis Tsiang1-0/+1
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>
2023-10-31add missing <system_error> includeJiyu Yang1-0/+1
fix build error with GCC 13: ``` wsi/swapchain_base.cpp:150:35: error: expected unqualified-id before ‘&’ token 150 | catch (const std::system_error &) | ``` Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-10-31fix Use after freeJiyu Yang1-3/+3
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-10-31Use wayland-scanner public-codeDaniel Levin1-2/+2
2023-10-31Use find_program instead of pkg_get_variable for wayland-scannerDaniel Levin1-2/+1
2023-10-19Fix formatting long as %d in util/log.cppDaniel Levin2-5/+6
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>
2023-09-28Enable instance extensionsAngeliki Agathi Tsintzira8-49/+118
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-04-20Avoid returning VK_ERROR_DEVICE_LOSTDennis Tsiang2-12/+6
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
2023-04-17Replace VK_LAYER_EXPORT with VWL_VKAPI_EXPORTNormunds Rieksts2-3/+13
2023-02-16Move memory handle type setting into allocate_wsiallocDennis Tsiang1-3/+2
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>
2023-02-12Change vulkan wsi project to use "main" branchNir Ekhauz2-7/+7
Signed-off-by: Nir Ekhauz <nir.ekhauz@arm.com> Change-Id: I82fa871371bf025a5c181f3b55812a2bee80d566
2023-02-07Use strtol instead of std::atoi in loggingDennis Tsiang2-20/+15
strtol does not throw exceptions. Change-Id: I6d6d3c32c2b61ed0307370bbfc3ce333adb5c504 Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2023-01-10Fix a bug in queue submissionNormunds Rieksts1-3/+20
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>
2022-11-24Extend TRY macro to print out error messagesNormunds Rieksts8-202/+116
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-11Fix issues reported by static analysis toolsDennis Tsiang8-44/+67
Fix CERT C/CPP issues flagged by static analysis tools. Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com> Change-Id: I6758bb83bd0647e4e6b7ccbf84e94f05ba90e160
2022-10-31Add pre-commit hook to check for copyright headerBen Davis3-0/+198
Change-Id: I1d3b9d51305d257c9c322caf4cf4d97667fb687b Signed-off-by: Ben Davis <ben.davis@arm.com>
2022-10-21Decouple creation, allocation and binding of images from Wayland backendDennis Tsiang7-322/+561
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
2022-10-20Add codebase guidelines to the projectNormunds Rieksts1-0/+29
2022-09-13Adding VK_KHR_shared_presentable_image basic supportLior Dekel1-0/+7
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-08-25Add Pre-commit config and add to CI pipelineBen Davis2-24/+40
2022-08-19Update WSI layer to use C++17Aron Virginas-Tar9-233/+38
2022-08-15Increase max swapchain image countDennis Tsiang1-2/+2
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
2022-08-03Remove duplication of create_aliased_image_handle implementationsAron Virginas-Tar7-109/+44
Signed-off-by: Aron Virginas-Tar <aron.virginas-tar@arm.com> Change-Id: I37043259e349874a9a7eb495a0e3b939c144798f
2022-08-03Fix issue found by static analysisAron Virginas-Tar1-3/+6
Replaced call to unsafe function strcpy() with call to snprintf(). Signed-off-by: Aron Virginas-Tar <aron.virginas-tar@arm.com> Change-Id: I0de5f869200e74b6d0c8224da2e41d6c4b8b6f4d
2022-07-21Fix issues found by static analysisMatteo Franchin6-21/+34
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>
2022-07-13Create common functions in surface_capabilities classLior Dekel4-93/+87
Signed-off-by: Lior Dekel <lior.dekel@arm.com> Change-Id: Ia5053b202f4e64fd7a255ede513653a951ab3d41
2022-07-12Update Khronos headers API versionRosen Zhelev1-1/+1
Change-Id: Ifa3f945a1216677c9410c09f4b4341a70d918514 Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
2022-07-07Remove swapchain from device_data after destructionIason Paraskevopoulos3-0/+20
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
2022-06-15Add WSI integration guideIason Paraskevopoulos3-0/+262
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
2022-05-30Enable instance extensions required by layerMatteo Franchin5-89/+110
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>
2022-05-25Add support for VK_EXT_image_compression_control_swapchainDennis Tsiang23-159/+707
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
2022-03-10Implement VK_KHR_get_surface_capabilities2 entrypointsIason Paraskevopoulos11-21/+114
Adds support for the VK_KHR_get_surface_capabilities2 extension. Change-Id: Iae882a41819baf413a0ba949ec44d6e722ebca5a Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2022-03-10Use common code for get_surface_formats implementationsIason Paraskevopoulos8-86/+92
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>
2022-02-08Mark fences and semaphores as already signalled in AcquireNextImageDavid Harvey-Macaulay5-37/+147
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
2022-01-24Fix FD ownership issue in Wayland Vulkan importDennis Tsiang1-28/+33
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>
2021-12-15Remove DEBUG build optionupstream/v1.0.5upstream/1.0.5Ben Davis1-4/+0
Users should use CMAKE_BUILD_TYPE to set the build type Change-Id: I526b3a96f798a39ceca11674bf1e0b6964a3da7d Signed-off-by: Ben Davis <ben.davis@arm.com>
2021-12-13wayland: Fix nulltpr dereference on deprecated swapchainsRosen Zhelev1-1/+1
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>
2021-12-10Casting operands to a wider type to prevent integer overflowFufu Fang1-3/+8
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>
2021-12-09Include modifiers in params creationDennis Tsiang1-1/+3
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>
2021-12-06Fix bug in has_descendant_started_presenting in headless backendDennis Tsiang2-10/+9
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>
2021-12-02Check for required protocols in vkGetPhysicalDeviceWaylandPresentationSupportKHRBen Davis1-1/+69
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>
2021-11-29Improve error handling when copying extension nameFufu Fang1-3/+2
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>
2021-11-26Remove ENABLE_WSI_LAYER optionDavid Harvey-Macaulay1-3/+0
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
2021-11-25Return appropriate error code in acquire_next_imageIason Paraskevopoulos3-17/+54
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>
2021-11-25Remove the roundtrip to Wayland when creating wl_buffers for each imageNormunds Rieksts2-61/+5
Change the implementation to create wl_buffers immediately on client side and defer the creation of wl_buffers on the server when the first image is presented as that's when all buffered requests will be flushed to the display Additionally remove the swapchain event queue as we no longer need it to dispatch any events Change-Id: Ic0683e7ec457df63638ce0b972c4925ac836b198 Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2021-11-17Store enabled instance and device extensionsIason Paraskevopoulos12-33/+215
Stores the enabled instance and device extensions during vkCreateInstance and vkCreateDevice respectively. This fixes an issue where function pointers for functions of disabled extensions were returned during vkGetInstanceProcAddr/vkGetDeviceProcAddr. Adds functionality for adding extensions that belong to a subset of other extensions in util::extension_list. Adds function for checking if the proper surface extension has been enabled in each WSI backend. Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com> Change-Id: If5e23e0d07c9f09006be18c410c4e1d4c3a1e676
2021-11-15Add versioning to wsialloc interfaceDennis Tsiang5-9/+58
The wsialloc interface now has explicit versioning which is used to ensure that wsialloc implementations are compatible with the interface. wsialloc implementations should define which version they are using and upon version mismatch compilation will fail. Also: - add new WSIALLOC_MAX_PLANE macro to define the maximum number of planes that the wsialloc should support. Change-Id: I211fc4341f249deff0c005d946c483ba47366600 Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2021-11-12Update supported composite alpha flagsBen Davis1-3/+2
There is currently no protocol for setting composite alpha blending mode via Wayland but the expectation is that we use premultiplied alpha so we only report the premultiplied and inherit composite alpha bits Change-Id: If4e103b47cb8e99213ca96216abc06d812c68db1 Signed-off-by: Ben Davis <ben.davis@arm.com>
2021-11-12Merge master branch into multiple_swapchains_present_reqIason Paraskevopoulos20-63/+72
Change-Id: I153e7a78609651bbfdf4fc0b6675d0ea97763905 Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>