diff options
author | Rosen Zhelev <rosen.zhelev@arm.com> | 2021-09-01 22:30:31 +0100 |
---|---|---|
committer | Rosen Zhelev <rosen.zhelev@arm.com> | 2021-09-14 10:52:28 +0100 |
commit | d7aabddf4007e725848a326e6e9e39b7ecce1e21 (patch) | |
tree | 9b9d2b7ff5bb3b90440e18b013ba035838b4c9da /util | |
parent | 1ae0397aaae089251e08b9a7e4a87be05133104f (diff) | |
download | vulkan-wsi-layer-d7aabddf4007e725848a326e6e9e39b7ecce1e21.tar.gz vulkan-wsi-layer-d7aabddf4007e725848a326e6e9e39b7ecce1e21.tar.bz2 vulkan-wsi-layer-d7aabddf4007e725848a326e6e9e39b7ecce1e21.zip |
Use explicit synchronization for Wayland surfaces
This change adds the use of zwp_linux_explicit_synchronization_v1 to
attach a Sync FD fence on presented image submitted to the compositor.
The change introduces the wsi/synchronization.hpp header and
implementation of the synchronization primitives used by WSI
implementations. Currently only Vulkan fences and fences exportable to
Sync FD are supported.
Change-Id: Ic7d6b712cc8ae8d171f799af51a70be62585b8a1
Signed-off-by: Rosen Zhelev <rosen.zhelev@arm.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/file_descriptor.hpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/util/file_descriptor.hpp b/util/file_descriptor.hpp new file mode 100644 index 0000000..870cfbb --- /dev/null +++ b/util/file_descriptor.hpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2021 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * @file + * + * @brief Contains the defintions of file descriptor utilities. + */ + +#pragma once + +#include <unistd.h> +#include <utility> + +namespace util +{ + +/** + * Manages a POSIX file descriptor. + */ +class fd_owner +{ +public: + + fd_owner() = default; + fd_owner(int fd) + : fd_handle{ fd } + { + } + + fd_owner(const fd_owner &) = delete; + fd_owner &operator=(const fd_owner &) = delete; + + fd_owner(fd_owner &&rhs) + { + *this = std::move(rhs); + } + + fd_owner &operator=(fd_owner &&rhs) + { + std::swap(fd_handle, rhs.fd_handle); + return *this; + } + + ~fd_owner() + { + if (is_valid()) + { + close(fd_handle); + } + } + + int get() + { + return fd_handle; + } + + bool is_valid() + { + return fd_handle >= 0; + } + +private: + int fd_handle{ -1 }; +}; + +} /* namespace util */
\ No newline at end of file |