Flutter Engine
The Flutter Engine
external_fence_vk.cc
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
6
9
10namespace impeller {
11
12ExternalFenceVK::ExternalFenceVK(const std::shared_ptr<Context>& context) {
13 if (!context) {
14 return;
15 }
16 vk::StructureChain<vk::FenceCreateInfo, vk::ExportFenceCreateInfoKHR> info;
17
18 info.get<vk::ExportFenceCreateInfoKHR>().handleTypes =
19 vk::ExternalFenceHandleTypeFlagBits::eSyncFd;
20
21 const auto& context_vk = ContextVK::Cast(*context);
22 auto [result, fence] = context_vk.GetDevice().createFenceUnique(info.get());
23 if (result != vk::Result::eSuccess) {
24 VALIDATION_LOG << "Could not create external fence: "
26 return;
27 }
28
29 context_vk.SetDebugName(fence.get(), "ExternalFenceSyncFD");
30
31 fence_ = MakeSharedVK(std::move(fence));
32}
33
35
37 return !!fence_;
38}
39
41 if (!IsValid()) {
42 return {};
43 }
44 vk::FenceGetFdInfoKHR info;
45 info.fence = fence_->Get();
46 info.handleType = vk::ExternalFenceHandleTypeFlagBits::eSyncFd;
47 auto [result, fd] = fence_->GetUniqueWrapper().getOwner().getFenceFdKHR(info);
48 if (result != vk::Result::eSuccess) {
49 VALIDATION_LOG << "Could not export external fence FD: "
51 return {};
52 }
53 return fml::UniqueFD{fd};
54}
55
56const vk::Fence& ExternalFenceVK::GetHandle() const {
57 return fence_->Get();
58}
59
61 return fence_;
62}
63
64} // namespace impeller
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static ContextVK & Cast(Context &base)
Definition: backend_cast.h:13
fml::UniqueFD CreateFD() const
Create a new sync file descriptor for the underlying fence. The fence must already be signaled or hav...
ExternalFenceVK(const std::shared_ptr< Context > &context)
Create a new un-signaled fence that can be exported as a sync file descriptor.
const vk::Fence & GetHandle() const
const SharedHandleVK< vk::Fence > & GetSharedHandle() const
bool IsValid() const
If a valid fence could be created.
GAsyncResult * result
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
auto MakeSharedVK(vk::UniqueHandle< T, VULKAN_HPP_DEFAULT_DISPATCHER_TYPE > handle)
static SkString to_string(int n)
Definition: nanobench.cpp:119
#define VALIDATION_LOG
Definition: validation.h:73