Flutter Impeller
impeller::FrameSynchronizer Struct Reference

Public Member Functions

 FrameSynchronizer (const vk::Device &device)
 
 ~FrameSynchronizer ()=default
 
bool WaitForFence (const vk::Device &device)
 

Public Attributes

vk::UniqueFence acquire
 
vk::UniqueSemaphore render_ready
 
vk::UniqueSemaphore present_ready
 
std::shared_ptr< CommandBufferfinal_cmd_buffer
 
std::shared_ptr< fml::CountDownLatch > present_latch
 A latch that is signaled after a given swapchain image is presented. More...
 
bool is_valid = false
 

Detailed Description

Definition at line 28 of file swapchain_impl_vk.cc.

Constructor & Destructor Documentation

◆ FrameSynchronizer()

impeller::FrameSynchronizer::FrameSynchronizer ( const vk::Device &  device)
inlineexplicit

Definition at line 38 of file swapchain_impl_vk.cc.

38  {
39  auto acquire_res = device.createFenceUnique(
40  vk::FenceCreateInfo{vk::FenceCreateFlagBits::eSignaled});
41  auto render_res = device.createSemaphoreUnique({});
42  auto present_res = device.createSemaphoreUnique({});
43  if (acquire_res.result != vk::Result::eSuccess ||
44  render_res.result != vk::Result::eSuccess ||
45  present_res.result != vk::Result::eSuccess) {
46  VALIDATION_LOG << "Could not create synchronizer.";
47  return;
48  }
49  acquire = std::move(acquire_res.value);
50  render_ready = std::move(render_res.value);
51  present_ready = std::move(present_res.value);
52  present_latch = std::make_shared<fml::CountDownLatch>(0u);
53  is_valid = true;
54  }

References acquire, is_valid, present_latch, present_ready, render_ready, and VALIDATION_LOG.

◆ ~FrameSynchronizer()

impeller::FrameSynchronizer::~FrameSynchronizer ( )
default

Member Function Documentation

◆ WaitForFence()

bool impeller::FrameSynchronizer::WaitForFence ( const vk::Device &  device)
inline

Definition at line 58 of file swapchain_impl_vk.cc.

58  {
59  present_latch->Wait();
60  if (auto result = device.waitForFences(
61  *acquire, // fence
62  true, // wait all
63  std::numeric_limits<uint64_t>::max() // timeout (ns)
64  );
65  result != vk::Result::eSuccess) {
66  VALIDATION_LOG << "Fence wait failed: " << vk::to_string(result);
67  return false;
68  }
69  if (auto result = device.resetFences(*acquire);
70  result != vk::Result::eSuccess) {
71  VALIDATION_LOG << "Could not reset fence: " << vk::to_string(result);
72  return false;
73  }
74  present_latch = std::make_shared<fml::CountDownLatch>(1u);
75  return true;
76  }

References acquire, present_latch, and VALIDATION_LOG.

Member Data Documentation

◆ acquire

vk::UniqueFence impeller::FrameSynchronizer::acquire

Definition at line 29 of file swapchain_impl_vk.cc.

Referenced by FrameSynchronizer(), and WaitForFence().

◆ final_cmd_buffer

std::shared_ptr<CommandBuffer> impeller::FrameSynchronizer::final_cmd_buffer

Definition at line 32 of file swapchain_impl_vk.cc.

◆ is_valid

bool impeller::FrameSynchronizer::is_valid = false

Definition at line 36 of file swapchain_impl_vk.cc.

Referenced by FrameSynchronizer().

◆ present_latch

std::shared_ptr<fml::CountDownLatch> impeller::FrameSynchronizer::present_latch

A latch that is signaled after a given swapchain image is presented.

Definition at line 35 of file swapchain_impl_vk.cc.

Referenced by FrameSynchronizer(), and WaitForFence().

◆ present_ready

vk::UniqueSemaphore impeller::FrameSynchronizer::present_ready

Definition at line 31 of file swapchain_impl_vk.cc.

Referenced by FrameSynchronizer().

◆ render_ready

vk::UniqueSemaphore impeller::FrameSynchronizer::render_ready

Definition at line 30 of file swapchain_impl_vk.cc.

Referenced by FrameSynchronizer().


The documentation for this struct was generated from the following file:
impeller::FrameSynchronizer::acquire
vk::UniqueFence acquire
Definition: swapchain_impl_vk.cc:29
impeller::FrameSynchronizer::is_valid
bool is_valid
Definition: swapchain_impl_vk.cc:36
impeller::FrameSynchronizer::present_latch
std::shared_ptr< fml::CountDownLatch > present_latch
A latch that is signaled after a given swapchain image is presented.
Definition: swapchain_impl_vk.cc:35
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::FrameSynchronizer::present_ready
vk::UniqueSemaphore present_ready
Definition: swapchain_impl_vk.cc:31
impeller::FrameSynchronizer::render_ready
vk::UniqueSemaphore render_ready
Definition: swapchain_impl_vk.cc:30