Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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|.
 
vk::UniqueDescriptorPool Get ()
 Gets a descriptor pool.
 
std::shared_ptr< DescriptorPoolVKGetDescriptorPool ()
 
void Reclaim (DescriptorCacheMap descriptor_sets, std::vector< vk::UniqueDescriptorPool > pools)
 

Static Public Attributes

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

Detailed Description

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

Definition at line 70 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 81 of file descriptor_pool_vk.h.

82 : context_(std::move(context)) {}
std::shared_ptr< ContextGLES > 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 140 of file descriptor_pool_vk.cc.

140 {
141 // Recycle a pool with a matching minumum capcity if it is available.
142 return Create();
143}

◆ GetDescriptorPool()

std::shared_ptr< DescriptorPoolVK > impeller::DescriptorPoolRecyclerVK::GetDescriptorPool ( )

Definition at line 176 of file descriptor_pool_vk.cc.

176 {
177 {
178 Lock recycled_lock(recycled_mutex_);
179 if (!recycled_.empty()) {
180 auto result = recycled_.back();
181 recycled_.pop_back();
182 return result;
183 }
184 }
185 return std::make_shared<DescriptorPoolVK>(context_);
186}

◆ Reclaim()

void impeller::DescriptorPoolRecyclerVK::Reclaim ( DescriptorCacheMap  descriptor_sets,
std::vector< vk::UniqueDescriptorPool >  pools 
)

Definition at line 113 of file descriptor_pool_vk.cc.

115 {
116 // Reset the pool on a background thread.
117 auto strong_context = context_.lock();
118 if (!strong_context) {
119 return;
120 }
121
122 for (auto& [_, cache] : descriptor_sets) {
123 cache.unused.insert(cache.unused.end(), cache.used.begin(),
124 cache.used.end());
125 cache.used.clear();
126 }
127
128 // Move the pool to the recycled list. If more than 32 pool are
129 // cached then delete the newest entry.
130 Lock recycled_lock(recycled_mutex_);
131 while (recycled_.size() >= kMaxRecycledPools) {
132 auto& back_entry = recycled_.back();
133 back_entry->Destroy();
134 recycled_.pop_back();
135 }
136 recycled_.push_back(std::make_shared<DescriptorPoolVK>(
137 context_, std::move(descriptor_sets), std::move(pools)));
138}
static constexpr size_t kMaxRecycledPools
The maximum number of descriptor pools this recycler will hold onto.

References kMaxRecycledPools.

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 76 of file descriptor_pool_vk.h.

Referenced by Reclaim().


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