Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
impeller::DescriptorPoolRecyclerVK Class Referencefinal

Creates and manages the lifecycle of |vk::DescriptorPoolVK| objects. More...

#include <descriptor_pool_vk.h>

Inheritance diagram for impeller::DescriptorPoolRecyclerVK:

Public Member Functions

 ~DescriptorPoolRecyclerVK ()=default
 
 DescriptorPoolRecyclerVK (std::weak_ptr< ContextVK > context)
 Creates a recycler for the given |ContextVK|. More...
 
vk::UniqueDescriptorPool Get ()
 Gets a descriptor pool. More...
 
void Reclaim (vk::UniqueDescriptorPool &&pool)
 Returns the descriptor pool to be reset on a background thread. More...
 

Static Public Attributes

static constexpr size_t kMaxRecycledPools = 32u
 The maximum number of descriptor pools this recycler will hold onto. More...
 

Detailed Description

Creates and manages the lifecycle of |vk::DescriptorPoolVK| objects.

Definition at line 51 of file descriptor_pool_vk.h.

Constructor & Destructor Documentation

◆ ~DescriptorPoolRecyclerVK()

impeller::DescriptorPoolRecyclerVK::~DescriptorPoolRecyclerVK ( )
default

◆ DescriptorPoolRecyclerVK()

impeller::DescriptorPoolRecyclerVK::DescriptorPoolRecyclerVK ( std::weak_ptr< ContextVK context)
inlineexplicit

Creates a recycler for the given |ContextVK|.

Parameters
[in]contextThe context to create the recycler for.

Definition at line 62 of file descriptor_pool_vk.h.

63 : context_(std::move(context)) {}

Member Function Documentation

◆ Get()

vk::UniqueDescriptorPool impeller::DescriptorPoolRecyclerVK::Get ( )

Gets a descriptor pool.

        This may create a new descriptor pool if no existing pools had
        the necessary capacity. 

Definition at line 151 of file descriptor_pool_vk.cc.

151 {
152 // Recycle a pool with a matching minumum capcity if it is available.
153 auto recycled_pool = Reuse();
154 if (recycled_pool.has_value()) {
155 return std::move(recycled_pool.value());
156 }
157 return Create();
158}

◆ Reclaim()

void impeller::DescriptorPoolRecyclerVK::Reclaim ( vk::UniqueDescriptorPool &&  pool)

Returns the descriptor pool to be reset on a background thread.

Parameters
[in]poolThe pool to recycler.

Definition at line 133 of file descriptor_pool_vk.cc.

133 {
134 // Reset the pool on a background thread.
135 auto strong_context = context_.lock();
136 if (!strong_context) {
137 return;
138 }
139 auto device = strong_context->GetDevice();
140 device.resetDescriptorPool(pool.get());
141
142 // Move the pool to the recycled list.
143 Lock recycled_lock(recycled_mutex_);
144
145 if (recycled_.size() < kMaxRecycledPools) {
146 recycled_.push_back(std::move(pool));
147 return;
148 }
149}
AutoreleasePool pool
static constexpr size_t kMaxRecycledPools
The maximum number of descriptor pools this recycler will hold onto.
VkDevice device
Definition: main.cc:53

Member Data Documentation

◆ kMaxRecycledPools

constexpr size_t impeller::DescriptorPoolRecyclerVK::kMaxRecycledPools = 32u
staticconstexpr

The maximum number of descriptor pools this recycler will hold onto.

Definition at line 57 of file descriptor_pool_vk.h.


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