Fix FD ownership issue in Wayland Vulkan import
authorDennis Tsiang <dennis.tsiang@arm.com>
Mon, 24 Jan 2022 15:02:03 +0000 (15:02 +0000)
committerDennis Tsiang <dennis.tsiang@arm.com>
Mon, 24 Jan 2022 17:23:03 +0000 (17:23 +0000)
commite78252429a0a1e5a44b1c98b85fb948c28eecba9
tree38eef07f4343a2c39e19beebc00516654fea898c
parent79b5d296c2e4d28db34e08aa59d5de8143a47bec
Fix FD ownership issue in Wayland Vulkan import

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>
wsi/wayland/swapchain.cpp