| Flutter Impeller |

external_semaphore_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_EXTERNAL_SEMAPHORE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_EXTERNAL_SEMAPHORE_VK_H_
7
8 #include "flutter/fml/unique_fd.h"
9 #include "impeller/renderer/backend/vulkan/shared_object_vk.h"
10 #include "impeller/renderer/backend/vulkan/vk.h"
11 #include "impeller/renderer/context.h"
12 #include "vulkan/vulkan_handles.hpp"
13
14 namespace impeller {
15
16 //------------------------------------------------------------------------------
17 /// @brief A Vulkan semaphore that can be exported as a platform specific
18 /// file descriptor.
19 ///
20 /// The semaphore are exported as sync file descriptors.
21 ///
22 /// @warning Only semaphore that have been signaled or have a single
23 /// operation pending can be exported. Make sure to submit a fence
24 /// signalling operation to a queue before attempted to obtain a
25 /// file descriptor for the fence.
26 ///
27 class ExternalSemaphoreVK {
28 public:
29 //----------------------------------------------------------------------------
30 /// @brief Create a new un-signaled semaphore that can be exported as a
31 /// sync file descriptor.
32 ///
33 /// @param[in] context The device context.
34 ///
35 explicit ExternalSemaphoreVK(const std::shared_ptr<Context>& context);
36
37 ~ExternalSemaphoreVK();
38
39 ExternalSemaphoreVK(const ExternalSemaphoreVK&) = delete;
40
41 ExternalSemaphoreVK& operator=(const ExternalSemaphoreVK&) = delete;
42
43 //----------------------------------------------------------------------------
44 /// @brief If a valid fence could be created.
45 ///
46 /// @return True if valid, False otherwise.
47 ///
48 bool IsValid() const;
49
50 //----------------------------------------------------------------------------
51 /// @brief Create a new sync file descriptor for the underlying
52 /// semaphore.
53 ///
54 /// The semaphore must already be signaled or have a signal
55 /// operation pending in a queue. There are no checks for this in
56 /// the implementation and only Vulkan validation will catch such
57 /// a misuse and undefined behavior.
58 ///
59 /// @warning Implementations are also allowed to return invalid file
60 /// descriptors in case a semaphore has already been signaled. So
61 /// it is not necessary an error to obtain an invalid descriptor
62 /// from this call. For APIs that are meant to consume such
63 /// descriptors, pass -1 as the file handle.
64 ///
65 /// Since this call can return an invalid FD even in case of
66 /// success, make sure to make the `IsValid` check before
67 /// attempting to export a FD.
68 ///
69 /// @return A (potentially invalid even in case of success) file
70 /// descriptor.
71 ///
72 fml::UniqueFD CreateFD() const;
73
74 const vk::Semaphore& GetHandle() const;
75
76 const SharedHandleVK<vk::Semaphore>& GetSharedHandle() const;
77
78 private:
79 SharedHandleVK<vk::Semaphore> semaphore_;
80 };
81
82 } // namespace impeller
83
84 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_EXTERNAL_SEMAPHORE_VK_H_
impeller::ExternalSemaphoreVK
A Vulkan semaphore that can be exported as a platform specific file descriptor.
Definition: external_semaphore_vk.h:27
impeller::ExternalSemaphoreVK::GetHandle
const vk::Semaphore & GetHandle() const
Definition: external_semaphore_vk.cc:61
impeller::ExternalSemaphoreVK::ExternalSemaphoreVK
ExternalSemaphoreVK(const ExternalSemaphoreVK &)=delete
impeller::ExternalSemaphoreVK::GetSharedHandle
const SharedHandleVK< vk::Semaphore > & GetSharedHandle() const
Definition: external_semaphore_vk.cc:65
impeller::ExternalSemaphoreVK::operator=
ExternalSemaphoreVK & operator=(const ExternalSemaphoreVK &)=delete
impeller::ExternalSemaphoreVK::CreateFD
fml::UniqueFD CreateFD() const
Create a new sync file descriptor for the underlying semaphore.
Definition: external_semaphore_vk.cc:44
impeller::ExternalSemaphoreVK::IsValid
bool IsValid() const
If a valid fence could be created.
Definition: external_semaphore_vk.cc:40
impeller::ExternalSemaphoreVK::~ExternalSemaphoreVK
~ExternalSemaphoreVK()
impeller::ExternalSemaphoreVK::ExternalSemaphoreVK
ExternalSemaphoreVK(const std::shared_ptr< Context > &context)
Create a new un-signaled semaphore that can be exported as a sync file descriptor.
Definition: external_semaphore_vk.cc:13
impeller
Definition: allocation.cc:12
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:53
context.h
shared_object_vk.h
vk.h