| Flutter Impeller |

Public Member Functions | Friends | List of all members
impeller::KHRSwapchainVK Class Referencefinal

A swapchain implemented backed by VK_KHR_swapchain and VK_KHR_surface. More...

`#include <khr_swapchain_vk.h>`

Inheritance diagram for impeller::KHRSwapchainVK:

## Public Member Functions
| ~KHRSwapchainVK ()
bool | IsValid () const override
std::unique_ptr< Surface > | AcquireNextDrawable () override
vk::Format | GetSurfaceFormat () const override
void | UpdateSurfaceSize (const ISize &size) override
| Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame. More...
void | AddFinalCommandBuffer (std::shared_ptr< CommandBuffer > cmd_buffer) const override
Public Member Functions inherited from impeller::SwapchainVK
virtual | ~SwapchainVK ()
| SwapchainVK (const SwapchainVK &)=delete
SwapchainVK & | operator= (const SwapchainVK &)=delete

## Friends
class | SwapchainVK

## Additional Inherited Members
Static Public Member Functions inherited from impeller::SwapchainVK
static std::shared_ptr< SwapchainVK > | Create (const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
Protected Member Functions inherited from impeller::SwapchainVK
| SwapchainVK ()

## Detailed Description

A swapchain implemented backed by VK_KHR_swapchain and VK_KHR_surface.

Definition at line 24 of file khr_swapchain_vk.h.

## Constructor & Destructor Documentation

## ◆ ~KHRSwapchainVK()

impeller::KHRSwapchainVK::~KHRSwapchainVK | ( |  | ) |
| default

## Member Function Documentation

## ◆ AcquireNextDrawable()

std::unique_ptr< Surface > impeller::KHRSwapchainVK::AcquireNextDrawable | ( |  | ) |
| override virtual

We managed to recreate the swapchain in the new configuration. Try again.

Implements impeller::SwapchainVK.

Definition at line 47 of file khr_swapchain_vk.cc.

47 {
48 if (!IsValid()) {
49 return nullptr;
50 }
51
52 TRACE_EVENT0("impeller", __FUNCTION__);
53
54 auto result = impl_->AcquireNextDrawable();
55 if (!result.out_of_date && size_ == impl_->GetSize()) {
56 return std::move(result.surface);
57 }
58
59 TRACE_EVENT0("impeller", "RecreateSwapchain");
60
61 // This swapchain implementation indicates that it is out of date. Tear it
62 // down and make a new one.
63 auto context = impl_->GetContext();
64 auto [surface, old_swapchain] = impl_->DestroySwapchain();
65
66 auto new_impl = KHRSwapchainImplVK::Create(context, //
67 std::move(surface), //
68 size_, //
69 enable_msaa_, //
70 *old_swapchain //
71 );
72 if (!new_impl || !new_impl->IsValid()) {
73 VALIDATION_LOG << "Could not update swapchain.";
74 // The old swapchain is dead because we took its surface. This is
75 // unrecoverable.
76 impl_.reset();
77 return nullptr;
78 }
79 impl_ = std::move(new_impl);
80
81 //----------------------------------------------------------------------------
82 /// We managed to recreate the swapchain in the new configuration. Try again.
83 ///
84 return AcquireNextDrawable();
85 }

References impeller::KHRSwapchainImplVK::AcquireNextDrawable(), impeller::KHRSwapchainImplVK::Create(), impeller::KHRSwapchainImplVK::IsValid(), and VALIDATION_LOG.

## ◆ AddFinalCommandBuffer()

void impeller::KHRSwapchainVK::AddFinalCommandBuffer | ( | std::shared_ptr< CommandBuffer > | cmd_buffer | ) | const
| override virtual

Implements impeller::SwapchainVK.

Definition at line 42 of file khr_swapchain_vk.cc.

43 {
44 impl_->AddFinalCommandBuffer(std::move(cmd_buffer));
45 }

## ◆ GetSurfaceFormat()

vk::Format impeller::KHRSwapchainVK::GetSurfaceFormat | ( |  | ) | const
| override virtual

Implements impeller::SwapchainVK.

Definition at line 87 of file khr_swapchain_vk.cc.

87 {
88 return IsValid() ? impl_->GetSurfaceFormat() : vk::Format::eUndefined;
89 }

References impeller::KHRSwapchainImplVK::IsValid().

## ◆ IsValid()

bool impeller::KHRSwapchainVK::IsValid | ( |  | ) | const
| override virtual

Implements impeller::SwapchainVK.

Definition at line 32 of file khr_swapchain_vk.cc.

32 {
33 return impl_ ? impl_->IsValid() : false;
34 }

## ◆ UpdateSurfaceSize()

void impeller::KHRSwapchainVK::UpdateSurfaceSize | ( | const ISize & | size | ) |
| override virtual

Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.

Implements impeller::SwapchainVK.

Definition at line 36 of file khr_swapchain_vk.cc.

36 {
37 // Update the size of the swapchain. On the next acquired drawable,
38 // the sizes may no longer match, forcing the swapchain to be recreated.
39 size_ = size;
40 }

## Friends And Related Function Documentation

## ◆ SwapchainVK

friend class SwapchainVK
| friend

Definition at line 45 of file khr_swapchain_vk.h.

The documentation for this class was generated from the following files:

- impeller/renderer/backend/vulkan/swapchain/khr/khr_swapchain_vk.h
- impeller/renderer/backend/vulkan/swapchain/khr/khr_swapchain_vk.cc

impeller::KHRSwapchainVK::IsValid
bool IsValid() const override
Definition: khr_swapchain_vk.cc:32
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::KHRSwapchainImplVK::Create
static std::shared_ptr< KHRSwapchainImplVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true, vk::SwapchainKHR old_swapchain=VK_NULL_HANDLE)
Definition: khr_swapchain_impl_vk.cc:115
impeller::KHRSwapchainVK::AcquireNextDrawable
std::unique_ptr< Surface > AcquireNextDrawable() override
Definition: khr_swapchain_vk.cc:47