Commit graph

154 commits

Author SHA1 Message Date
Dennis Tsiang
3f9d76b9fa Fix build issue with newer Wayland headers 2024-10-14 11:21:53 +00:00
Rosen Zhelev
0c4356ed7d Merge 'Fix bug in frame boundary feature' into 'main'
See merge request mesa/vulkan-wsi-layer!114
2024-10-11 09:32:14 +00:00
Dennis Tsiang
c859eef158 Fix bug in frame boundary feature
In submit_wait_request we were passing the memory location of the
pointer to submission_pnext instead of the actual pointer. This commit
fixes it to pass the actual pointer. Additionally when creating the
frame boundary, set the pNext explicitly to nullptr.

Change-Id: I61ab9c898c3af4b3f401a3de6fdf7201fd2553ac
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2024-10-10 10:26:52 +01:00
Iason Paraskevopoulos
e6fa021f8d Merge 'Add support for wp_presentation in the WSI layer' into 'main'
See merge request mesa/vulkan-wsi-layer!113
2024-10-03 16:12:53 +00:00
Iason Paraskevopoulos
67575b895f Merge 'Implement support for marking frame boundaries' into 'main'
See merge request mesa/vulkan-wsi-layer!112
2024-10-01 15:18:22 +00:00
Normunds Rieksts
94dd9840c9 Implement support for marking frame boundaries 2024-10-01 15:18:22 +00:00
ginujacob
7f63c67cf2 Add support for wp_presentation in the WSI layer
Enabling the support for wp_presentation in
Wayland surface. A handle to the interface is
stored in the Wayland surface. The handle is
initialized for each VKSurface.

Signed-off-by: ginujacob <ginu.jacob@arm.com>
Change-Id: I9a2239b3047720fdeb857e23bb529c0f0fce9575
2024-10-01 13:37:29 +01:00
Iason Paraskevopoulos
41d0942b12 Merge 'Extend README with implemented extensions by the layer' into 'main'
See merge request mesa/vulkan-wsi-layer!111
2024-09-30 14:44:33 +00:00
Iason Paraskevopoulos
61dbbef491 Extend README with implemented extensions by the layer
Change-Id: Ifb80ad8a28e1d529cc527bab0d3888916a15b4a2
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2024-09-26 14:11:12 +01:00
Iason Paraskevopoulos
2449525741 Merge 'Advertise VK_EXT_present_timing features.' into 'main'
See merge request mesa/vulkan-wsi-layer!110
2024-09-19 10:06:16 +00:00
ginujacob
0cee10aa6f Advertise VK_EXT_present_timing features.
Enabling the VK_EXT_present_timing features
VkPhysicalDevicePresentTimingFeaturesEXT and
VkPresentTimingSurfaceCapabilitiesEXT.

The feature values are updated based on the backend.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: Ie322f58118108c656530128b18ec905bd6815c63
2024-09-17 11:31:46 +01:00
Rosen Zhelev
04fe972216 Merge 'Fix wsign-compare warning' into 'main'
See merge request mesa/vulkan-wsi-layer!109
2024-09-16 16:43:42 +00:00
Rosen Zhelev
e7c95099b6 Merge 'Guard swapchain maintenance features with experimental flag' into 'main'
See merge request mesa/vulkan-wsi-layer!108
2024-09-16 13:23:03 +00:00
Rosen Zhelev
7d3f40f2ec Merge 'Destroy attached objects before destroying the queue' into 'main'
See merge request mesa/vulkan-wsi-layer!106
2024-09-13 15:21:24 +00:00
Dennis Tsiang
7e27d1d762 Guard swapchain maintenance features with experimental flag
The feature is still experimental so we should guard it with the flag
until it's ready to be used.

Change-Id: I3f10f730ca916374241fdcdceaf332672788040d
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2024-09-05 16:52:48 +01:00
Dennis Tsiang
b565608724 Fix wsign-compare warning
Compiler warning was being flagged between the integer comparisons as
we were comparing a int with a size_t. This commit resolves the
warning by updating the int to a size_t.

Change-Id: Ibcb72ac9abb6c8e18bc8aa1e33efadc9ef79a564
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
2024-09-05 10:30:05 +01:00
Normunds Rieksts
af44f50be3 Add support for VkPresentIdKHR structure
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>
2024-08-29 14:22:30 +01:00
Iason Paraskevopoulos
d487eede9e Destroy attached objects before destroying the queue
Reorganizes the wayland::surface's member variables in a way that
the objects attached to the queue are destroyed before the queue.

Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: Ifbc3f285005ae01b0cc75d2827e424db58c392e1
2024-08-21 17:28:48 +01:00
Dennis Tsiang
b1f9e5811a Add initial support for VK_KHR_present_id
Layer updated to advertise support for the VK_KHR_present_id
extension. vkGetPhysicalDeviceFeatures2KHR and vkCreateDevice updated
to handle the new struct.

Also add the extensions enabled by the layer to the
instance_data and device_data objects so that the layer can correctly
check which extensions have been enabled.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I71ae2b28c94d3f16b485a06094712d6c3f6c7e77
2024-08-20 11:46:07 +00:00
Fufu Fang
743f00f9bb Merge branch 'main' into 'swapchain_maintenance_new' 2024-08-19 12:20:16 +00:00
ginujacob
0a293fcfa9 VK_EXT_present_timing changes for the layer's json file.
Adding the entry-points and definitions required for the
VK_EXT_present_timing feature.

Signed-off-by: Ginu Jacob <ginu.jacob@arm.com>
Change-Id: I5f388b50d12fe32556676c4de0d37c95e1ff611b
2024-08-15 12:01:36 +01:00
Angeliki Agathi Tsintzira
1fa0ac21f3 Fix the number of planes calculation
Previously, the number of planes was incorrectly calculated.
The number of planes for non-linear images was the format
planes from wsialloc instead of the memory planes expected
by the implementation.

Additionally, the VK_IMAGE_CREATE_DISJOINT_BIT was based on
the format planes during image creation, instead of using the
allocation planes from wsialloc.

This commit corrects these issues by ensuring the plane count
and disjoint bit is set based on the appropriate memory planes.

Signed-off-by: Angeliki Agathi Tsintzira <angelikiagathi.tsintzira@arm.com>
Change-Id: I47ca4a0c710cdf21d94705c57f08de4f04b3a761
2024-08-13 19:27:55 +01:00
Dennis Tsiang
7f428885e1 Refactor compatible present mode functionality
Refactor the compatible present mode functionality into a new class
compatible_present_modes.

Change-Id: I801f41ba16d9c5693f1aaa1e95e9eb2c9c4f5b59
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:55 +01:00
Dennis Tsiang
05e98f4d17 Support switching presentation modes
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>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
cbf6c9765c Separate image creation from create_and_bind_swapchain
Change-Id: Ifbc6a5fb57c962006550838667944b03654ce0e4
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:27:55 +01:00
Dennis Tsiang
bb31e7fba0 Add support for scaling capabilities
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>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
9edb068a38 Support deferred allocation
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>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
4adaa0b5eb Add support for VkSwapchainPresentFenceInfoEXT
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>
2024-08-13 19:27:55 +01:00
Iason Paraskevopoulos
01b4e9aeff Add a function for empty queue submit operations
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>
2024-08-13 19:27:55 +01:00
Normunds Rieksts
d2b8eb3135 Add vkReleaseSwapchainImagesEXT entrypoint
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>
2024-08-13 19:27:53 +01:00
Dennis Tsiang
8e02a7ffe3 Add support for present mode compatibility
This commit adds support for querying a surface's compatible
presentation modes via VkSurfacePresentModeEXT and
VkSurfacePresentModeCompatibilityEXT, as part of the
VK_EXT_surface_maintenance1 extension.

A new struct present_mode_compatibility has been created to capture
this new functionality.

Our headless implementation supports compability between FIFO and
FIFO_RELAXED. On Wayland, we do not allow compatibility between FIFO
and MAILBOX presentation.

Change-Id: I53659cb2f2aa0ac41e37975cc34aee3ce8317a73
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:26:54 +01:00
Dennis Tsiang
8f2722de92 Add support for VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT
Check for VkPhyscialDeviceSwapchainMaintenance1FeaturesEXT struct in
the pNext chains of VkCreateDeviceInfo and VkPhysicalDeviceFeatures2

Change-Id: I540b800d882855c6782043ca6c88bafc850c4bcd
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-13 19:26:53 +01:00
Dennis Wildmark
c48d7382ef Refactor framebuffer format support
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>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-12 11:44:22 +00:00
Dennis Wildmark
e62cc2d42f VK_KHR_display swapchain implementation
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>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-12 11:44:22 +00:00
Dennis Wildmark
09a341b88b Make drm_display singleton
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>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-12 11:44:22 +00:00
Dennis Wildmark
8da77f2b8b VK_KHR_display surface_properties implementation
Implementation of the surface_properties interface for VK_KHR_display.

Change-Id: Idd3b53bec0d0a829478d51b4263db767c872d0e5
Signed-off-by: Dennis Wildmark <dennis.wildmark@arm.com>
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-12 11:44:22 +00:00
Fufu Fang
bdf564b077 Update pre-commit hook to run clang-format only on C/C++ files
Change-Id: I6e17429272ddaf4c375f3e89d7db5043b5c29d6c
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
2024-08-07 20:39:42 +01:00
Dennis Tsiang
4423a52816 Update clang-format rules
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: I76f87648a8ddaeddb6774123d263957b845d10a1
2024-07-04 10:30:42 +01:00
Iason Paraskevopoulos
b02486ff87 Extend wsialloc_alloc with disjoint information
Extends wsialloc_alloc to return whether or not the allocation will be
disjoint.

Groups wsialloc_alloc's return values to a struct.

Change-Id: I7542e37d8af16ce7989ab235c02305d562f3c667
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
2024-06-10 10:00:49 +01:00
Dennis Wildmark
8a74233de2 Add support for VK_KHR_shared_presentable_image for headless backend
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
2024-04-30 08:28:21 +00:00
Normunds Rieksts
fecfd94079 Fix issue with OOM CTS test
Fixes issues reported by the
create_instance_device_intentional_alloc_fail.basic CTS test. One of the
issues can happen if allocation fails at the time when dispatch table is
allocated at device/instance creation time which can result in dispatch
table being a null pointer which later is used to resolve Vulkan entrypoints.

This patch also makes sure that dispatch table is passed around the
{instance/device}_private_data::associate functions as a value-type
rather than a pointer which forces the user of the table to use the move
operator as otherwise the ownership transfer from the user to
the{instance/device}_private_data classes was not obvious and the user
could continue to invoke dispatch table functions erroneously.

Fixes the issue of the layer making use of the dispatch table when its
initialization has failed in the cases when calls to
dispatch_table::populate returned an error.

Any calls to vkDestroyInstance within vkCreateInstance
have been removed as the Vulkan loader handles the unloading of the
instance which would otherwise result in a double-free exception being
thrown.

Change-Id: I36bb7219db9d852bc31f09c8154b2f93776c162f
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
2024-04-29 16:07:49 +00:00
Iason Paraskevopoulos
3ed23f713c Add a note for tracing in the README
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Change-Id: Ie11e983a2893e5b1b7305e38aba574064013ef40
2024-03-26 17:04:48 +00:00
Embla Flatlandsmo
3fdda15be4 Add result store in VkBindImageMemory2KHR for maintenance6
For maintenance6, VkBindImageMemory2KHR should not return on
the first failure, but rather store the result and return it
after everything is bound.

Signed-off-by: Embla Flatlandsmo <embla.flatlandsmo@arm.com>
Change-Id: I2578d0ad0e6330ed9c091794e05cf5f24c876fb1
2024-03-01 07:27:36 +01:00
Dennis Wildmark
2837bab5c4 Refactor dispatch table to fix extension entry point visibility
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
2024-02-14 14:33:40 +00:00
Normunds Rieksts
bf7d090fdc Fix validation issues with fence import
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
2024-02-08 14:03:41 +00:00
Dennis Tsiang
7fda25462e Fix issues flagged by static analysis
Add error handling to snprintf.

Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Change-Id: Id0c0478254c57cb62af6f9cadde16f73b071f466
2024-01-05 12:41:47 +00:00
Dennis Tsiang
760d2f220d Fix validation error when importing sync fds
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-11-01 14:44:13 +00:00
Jiyu Yang
619f5f0e1e add missing <system_error> include
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-31 08:54:05 +00:00
Jiyu Yang
5f1733d88b fix Use after free
Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com>
2023-10-31 08:54:05 +00:00
Daniel Levin
b1621015c7 Use wayland-scanner public-code 2023-10-31 08:52:32 +00:00