Flutter Engine
 
Loading...
Searching...
No Matches
impeller::DescriptorPoolVK Class Reference

A per-frame descriptor pool. Descriptors from this pool don't need to be freed individually. Instead, the pool must be collected after all the descriptors allocated from it are done being used. More...

#include <descriptor_pool_vk.h>

Public Member Functions

 DescriptorPoolVK (std::weak_ptr< const ContextVK > context)
 
 DescriptorPoolVK (std::weak_ptr< const ContextVK > context, DescriptorCacheMap descriptor_sets, std::vector< vk::UniqueDescriptorPool > pools)
 
 ~DescriptorPoolVK ()
 
fml::StatusOr< vk::DescriptorSet > AllocateDescriptorSets (const vk::DescriptorSetLayout &layout, PipelineKey pipeline_key, const ContextVK &context_vk)
 

Friends

class DescriptorPoolRecyclerVK
 

Detailed Description

A per-frame descriptor pool. Descriptors from this pool don't need to be freed individually. Instead, the pool must be collected after all the descriptors allocated from it are done being used.

The pool or it's descriptors may not be accessed from multiple threads.

Encoders create pools as necessary as they have the same threading and lifecycle restrictions.

Definition at line 36 of file descriptor_pool_vk.h.

Constructor & Destructor Documentation

◆ DescriptorPoolVK() [1/2]

impeller::DescriptorPoolVK::DescriptorPoolVK ( std::weak_ptr< const ContextVK context)
explicit

Definition at line 29 of file descriptor_pool_vk.cc.

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

◆ DescriptorPoolVK() [2/2]

impeller::DescriptorPoolVK::DescriptorPoolVK ( std::weak_ptr< const ContextVK context,
DescriptorCacheMap  descriptor_sets,
std::vector< vk::UniqueDescriptorPool >  pools 
)

Definition at line 36 of file descriptor_pool_vk.cc.

39 : context_(std::move(context)),
40 descriptor_sets_(std::move(descriptor_sets)),
41 pools_(std::move(pools)) {}

◆ ~DescriptorPoolVK()

impeller::DescriptorPoolVK::~DescriptorPoolVK ( )

Definition at line 43 of file descriptor_pool_vk.cc.

43 {
44 if (pools_.empty()) {
45 return;
46 }
47
48 auto const context = context_.lock();
49 if (!context) {
50 return;
51 }
52 auto const recycler = context->GetDescriptorPoolRecycler();
53 if (!recycler) {
54 return;
55 }
56
57 recycler->Reclaim(std::move(descriptor_sets_), std::move(pools_));
58}

Member Function Documentation

◆ AllocateDescriptorSets()

fml::StatusOr< vk::DescriptorSet > impeller::DescriptorPoolVK::AllocateDescriptorSets ( const vk::DescriptorSetLayout &  layout,
PipelineKey  pipeline_key,
const ContextVK context_vk 
)

Definition at line 60 of file descriptor_pool_vk.cc.

63 {
64 DescriptorCacheMap::iterator existing = descriptor_sets_.find(pipeline_key);
65 if (existing != descriptor_sets_.end() && !existing->second.unused.empty()) {
66 auto descriptor_set = existing->second.unused.back();
67 existing->second.unused.pop_back();
68 existing->second.used.push_back(descriptor_set);
69 return descriptor_set;
70 }
71
72 if (pools_.empty()) {
73 CreateNewPool(context_vk);
74 }
75
76 vk::DescriptorSetAllocateInfo set_info;
77 set_info.setDescriptorPool(pools_.back().get());
78 set_info.setPSetLayouts(&layout);
79 set_info.setDescriptorSetCount(1);
80
81 vk::DescriptorSet set;
82 auto result = context_vk.GetDevice().allocateDescriptorSets(&set_info, &set);
83 if (result == vk::Result::eErrorOutOfPoolMemory) {
84 // If the pool ran out of memory, we need to create a new pool.
85 CreateNewPool(context_vk);
86 set_info.setDescriptorPool(pools_.back().get());
87 result = context_vk.GetDevice().allocateDescriptorSets(&set_info, &set);
88 }
89 auto lookup_result =
90 descriptor_sets_.try_emplace(pipeline_key, DescriptorCache{});
91 lookup_result.first->second.used.push_back(set);
92
93 if (result != vk::Result::eSuccess) {
94 VALIDATION_LOG << "Could not allocate descriptor sets: "
95 << vk::to_string(result);
97 }
98 return set;
99}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition switch_defs.h:71
#define VALIDATION_LOG
Definition validation.h:91

References impeller::ContextVK::GetDevice(), fml::kUnknown, and VALIDATION_LOG.

Referenced by impeller::testing::TEST(), and impeller::testing::TEST().

Friends And Related Symbol Documentation

◆ DescriptorPoolRecyclerVK

friend class DescriptorPoolRecyclerVK
friend

Definition at line 52 of file descriptor_pool_vk.h.


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