Flutter Impeller
external_fence_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_FENCE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_EXTERNAL_FENCE_VK_H_
7 
8 #include "flutter/fml/unique_fd.h"
12 
13 namespace impeller {
14 
15 //------------------------------------------------------------------------------
16 /// @brief A Vulkan fence that can be exported as a platform specific file
17 /// descriptor.
18 ///
19 /// The fences are exported as sync file descriptors.
20 ///
21 /// @warning Only fences that have been signaled or have a single operation
22 /// pending can be exported. Make sure to submit a fence signalling
23 /// operation to a queue before attempted to obtain a file
24 /// descriptor for the fence. See
25 /// VUID-VkFenceGetFdInfoKHR-handleType-01454 for additional details
26 /// on the implementation.
27 ///
29  public:
30  //----------------------------------------------------------------------------
31  /// @brief Create a new un-signaled fence that can be exported as a sync
32  /// file descriptor.
33  ///
34  /// @param[in] context The device context.
35  ///
36  explicit ExternalFenceVK(const std::shared_ptr<Context>& context);
37 
39 
40  ExternalFenceVK(const ExternalFenceVK&) = delete;
41 
42  ExternalFenceVK& operator=(const ExternalFenceVK&) = delete;
43 
44  //----------------------------------------------------------------------------
45  /// @brief If a valid fence could be created.
46  ///
47  /// @return True if valid, False otherwise.
48  ///
49  bool IsValid() const;
50 
51  //----------------------------------------------------------------------------
52  /// @brief Create a new sync file descriptor for the underlying fence.
53  /// The fence must already be signaled or have a signal operation
54  /// pending in a queue. There are no checks for this in the
55  /// implementation and only Vulkan validation will catch such a
56  /// misuse and undefined behavior.
57  ///
58  /// @warning Implementations are also allowed to return invalid file
59  /// descriptors in case a fence has already been signaled. So it
60  /// is not necessary an error to obtain an invalid descriptor from
61  /// this call. For APIs that are meant to consume such
62  /// descriptors, pass -1 as the file handle.
63  ///
64  /// Since this call can return an invalid FD even in case of
65  /// success, make sure to make the `IsValid` check before
66  /// attempting to export a FD.
67  ///
68  /// @return A (potentially invalid even in case of success) file
69  /// descriptor.
70  ///
71  fml::UniqueFD CreateFD() const;
72 
73  const vk::Fence& GetHandle() const;
74 
76 
77  private:
79 };
80 
81 } // namespace impeller
82 
83 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_EXTERNAL_FENCE_VK_H_
impeller::ExternalFenceVK::operator=
ExternalFenceVK & operator=(const ExternalFenceVK &)=delete
impeller::ExternalFenceVK
A Vulkan fence that can be exported as a platform specific file descriptor.
Definition: external_fence_vk.h:28
shared_object_vk.h
impeller::ExternalFenceVK::CreateFD
fml::UniqueFD CreateFD() const
Create a new sync file descriptor for the underlying fence. The fence must already be signaled or hav...
Definition: external_fence_vk.cc:40
vk.h
impeller::ExternalFenceVK::IsValid
bool IsValid() const
If a valid fence could be created.
Definition: external_fence_vk.cc:36
impeller::ExternalFenceVK::GetHandle
const vk::Fence & GetHandle() const
Definition: external_fence_vk.cc:56
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:53
context.h
impeller::ExternalFenceVK::ExternalFenceVK
ExternalFenceVK(const std::shared_ptr< Context > &context)
Create a new un-signaled fence that can be exported as a sync file descriptor.
Definition: external_fence_vk.cc:12
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ExternalFenceVK::~ExternalFenceVK
~ExternalFenceVK()
impeller::ExternalFenceVK::GetSharedHandle
const SharedHandleVK< vk::Fence > & GetSharedHandle() const
Definition: external_fence_vk.cc:60