Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::AHBSwapchainImplVK Class Referencefinal

The implementation of a swapchain at a specific size. Resizes to the surface will cause the instance of the swapchain impl at that size to be discarded along with all its caches and transients. More...

#include <ahb_swapchain_impl_vk.h>

Inheritance diagram for impeller::AHBSwapchainImplVK:

Public Member Functions

 ~AHBSwapchainImplVK ()
 
 AHBSwapchainImplVK (const AHBSwapchainImplVK &)=delete
 
AHBSwapchainImplVKoperator= (const AHBSwapchainImplVK &)=delete
 
const ISizeGetSize () const
 
bool IsValid () const
 
const android::HardwareBufferDescriptorGetDescriptor () const
 Get the descriptor used to create the hardware buffers that will be displayed on the surface control.
 
std::unique_ptr< SurfaceAcquireNextDrawable ()
 Acquire the next surface that can be used to present to the swapchain.
 
void AddFinalCommandBuffer (std::shared_ptr< CommandBuffer > cmd_buffer)
 

Static Public Member Functions

static std::shared_ptr< AHBSwapchainImplVKCreate (const std::weak_ptr< Context > &context, std::weak_ptr< android::SurfaceControl > surface_control, const CreateTransactionCB &cb, const ISize &size, bool enable_msaa)
 Create a swapchain of a specific size whose images will be presented to the provided surface control.
 

Detailed Description

The implementation of a swapchain at a specific size. Resizes to the surface will cause the instance of the swapchain impl at that size to be discarded along with all its caches and transients.

Definition at line 51 of file ahb_swapchain_impl_vk.h.

Constructor & Destructor Documentation

◆ ~AHBSwapchainImplVK()

impeller::AHBSwapchainImplVK::~AHBSwapchainImplVK ( )

Definition at line 108 of file ahb_swapchain_impl_vk.cc.

108 {
109 // Ensure that the Vulkan device is idle before destroying objects that the
110 // device may have been using.
111 WaitIdle();
112}

◆ AHBSwapchainImplVK()

impeller::AHBSwapchainImplVK::AHBSwapchainImplVK ( const AHBSwapchainImplVK )
delete

Member Function Documentation

◆ AcquireNextDrawable()

std::unique_ptr< Surface > impeller::AHBSwapchainImplVK::AcquireNextDrawable ( )

Acquire the next surface that can be used to present to the swapchain.

Returns
A surface if one can be created. If one cannot be created, it is likely due to resource exhaustion.

Definition at line 138 of file ahb_swapchain_impl_vk.cc.

138 {
139 auto context = transients_->GetContext().lock();
140 if (!context) {
141 return nullptr;
142 }
143
144 frame_index_ = (frame_index_ + 1) % kMaxPendingPresents;
145
146 if (!frame_data_[frame_index_]->WaitForFence(
147 ContextVK::Cast(*context).GetDevice())) {
148 return nullptr;
149 }
150
151 if (!is_valid_) {
152 return nullptr;
153 }
154
155 auto pool_entry = pool_->Pop();
156
157 if (!pool_entry.IsValid()) {
158 VALIDATION_LOG << "Could not create AHB texture source.";
159 return nullptr;
160 }
161
162 // Import the render ready semaphore that will block onscreen rendering until
163 // it is ready.
164 if (!ImportRenderReady(pool_entry.render_ready_fence, pool_entry.texture)) {
165 VALIDATION_LOG << "Could wait on render ready fence.";
166 return nullptr;
167 }
168
169#if IMPELLER_DEBUG
170 if (context) {
171 ContextVK::Cast(*context).GetGPUTracer()->MarkFrameStart();
172 }
173#endif // IMPELLER_DEBUG
174
176 transients_, pool_entry.texture,
177 [weak = weak_from_this(), texture = pool_entry.texture]() {
178 auto thiz = weak.lock();
179 if (!thiz) {
180 VALIDATION_LOG << "Swapchain died before image could be presented.";
181 return false;
182 }
183 return thiz->Present(texture);
184 });
185
186 if (!surface) {
187 return nullptr;
188 }
189
190 return surface;
191}
static ContextVK & Cast(Context &base)
const vk::Device & GetDevice() const
std::shared_ptr< GPUTracerVK > GetGPUTracer() const
static std::unique_ptr< SurfaceVK > WrapSwapchainImage(const std::shared_ptr< SwapchainTransientsVK > &transients, const std::shared_ptr< TextureSourceVK > &swapchain_image, SwapCallback swap_callback)
Wrap the swapchain image in a Surface, which provides the additional configuration required for usage...
Definition surface_vk.cc:13
VkSurfaceKHR surface
Definition main.cc:65
FlTexture * texture
static constexpr const size_t kMaxPendingPresents
std::shared_ptr< ContextGLES > context
#define VALIDATION_LOG
Definition validation.h:91

References impeller::BackendCast< ContextVK, Context >::Cast(), context, impeller::ContextVK::GetDevice(), impeller::ContextVK::GetGPUTracer(), impeller::kMaxPendingPresents, surface, texture, VALIDATION_LOG, and impeller::SurfaceVK::WrapSwapchainImage().

◆ AddFinalCommandBuffer()

void impeller::AHBSwapchainImplVK::AddFinalCommandBuffer ( std::shared_ptr< CommandBuffer cmd_buffer)

Definition at line 240 of file ahb_swapchain_impl_vk.cc.

241 {
242 frame_data_[frame_index_]->final_cmd_buffer = std::move(cmd_buffer);
243}

◆ Create()

std::shared_ptr< AHBSwapchainImplVK > impeller::AHBSwapchainImplVK::Create ( const std::weak_ptr< Context > &  context,
std::weak_ptr< android::SurfaceControl surface_control,
const CreateTransactionCB cb,
const ISize size,
bool  enable_msaa 
)
static

Create a swapchain of a specific size whose images will be presented to the provided surface control.

Parameters
[in]contextThe context whose allocators will be used to create swapchain image resources.
[in]surface_controlThe surface control to which the swapchain images will be presented.
[in]sizeThe size of the swapchain images. This is constant for the lifecycle of the swapchain impl.
[in]enable_msaaIf the swapchain images will be presented using a render target that enables MSAA. This allows for additional caching of transients.
Returns
A valid swapchain impl if one can be created. nullptr otherwise.

Definition at line 69 of file ahb_swapchain_impl_vk.cc.

74 {
75 auto impl = std::shared_ptr<AHBSwapchainImplVK>(new AHBSwapchainImplVK(
76 context, std::move(surface_control), cb, size, enable_msaa));
77 return impl->IsValid() ? impl : nullptr;
78}
AHBSwapchainImplVK(const AHBSwapchainImplVK &)=delete

References context.

Referenced by impeller::AHBSwapchainVK::UpdateSurfaceSize().

◆ GetDescriptor()

const android::HardwareBufferDescriptor & impeller::AHBSwapchainImplVK::GetDescriptor ( ) const

Get the descriptor used to create the hardware buffers that will be displayed on the surface control.

Returns
The descriptor.

Definition at line 122 of file ahb_swapchain_impl_vk.cc.

123 {
124 return desc_;
125}

◆ GetSize()

const ISize & impeller::AHBSwapchainImplVK::GetSize ( ) const
Returns
The size of the swapchain images that will be displayed on the surface control.

Definition at line 114 of file ahb_swapchain_impl_vk.cc.

114 {
115 return desc_.size;
116}

References impeller::android::HardwareBufferDescriptor::size.

◆ IsValid()

bool impeller::AHBSwapchainImplVK::IsValid ( ) const
Returns
If the swapchain impl is valid. If it is not, the instance must be discarded. There is no error recovery.

Definition at line 118 of file ahb_swapchain_impl_vk.cc.

118 {
119 return is_valid_;
120}

◆ operator=()

AHBSwapchainImplVK & impeller::AHBSwapchainImplVK::operator= ( const AHBSwapchainImplVK )
delete

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