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"
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 ///
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 
38 
40 
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 
77 
78  private:
80 };
81 
82 } // namespace impeller
83 
84 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_EXTERNAL_SEMAPHORE_VK_H_
A Vulkan semaphore that can be exported as a platform specific file descriptor.
const vk::Semaphore & GetHandle() const
ExternalSemaphoreVK(const ExternalSemaphoreVK &)=delete
const SharedHandleVK< vk::Semaphore > & GetSharedHandle() const
ExternalSemaphoreVK & operator=(const ExternalSemaphoreVK &)=delete
fml::UniqueFD CreateFD() const
Create a new sync file descriptor for the underlying semaphore.
bool IsValid() const
If a valid fence could be created.
ExternalSemaphoreVK(const std::shared_ptr< Context > &context)
Create a new un-signaled semaphore that can be exported as a sync file descriptor.
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK