| Flutter Impeller |

Public Member Functions | List of all members
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 ()
fml::StatusOr< vk::DescriptorSet > | AllocateDescriptorSets (const vk::DescriptorSetLayout &layout, const ContextVK &context_vk)

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

## Constructor & Destructor Documentation

## ◆ DescriptorPoolVK()

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

Definition at line 67 of file descriptor_pool_vk.cc.

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

## ◆ ~DescriptorPoolVK()

impeller::DescriptorPoolVK::~DescriptorPoolVK | ( |  | ) |

Definition at line 70 of file descriptor_pool_vk.cc.

70 {
71 if (pools_.empty()) {
72 return;
73 }
74
75 auto const context = context_.lock();
76 if (!context) {
77 return;
78 }
79 auto const recycler = context->GetDescriptorPoolRecycler();
80 if (!recycler) {
81 return;
82 }
83
84 for (auto i = 0u; i < pools_.size(); i++) {
85 auto reset_pool_when_dropped =
86 BackgroundDescriptorPoolVK(std::move(pools_[i]), recycler);
87
88 UniqueResourceVKT<BackgroundDescriptorPoolVK> pool(
89 context->GetResourceManager(), std::move(reset_pool_when_dropped));
90 }
91 pools_.clear();
92 }

## Member Function Documentation

## ◆ AllocateDescriptorSets()

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

Definition at line 94 of file descriptor_pool_vk.cc.

96 {
97 if (pools_.empty()) {
98 CreateNewPool(context_vk);
99 }
100
101 vk::DescriptorSetAllocateInfo set_info;
102 set_info.setDescriptorPool(pools_.back().get());
103 set_info.setPSetLayouts(&layout);
104 set_info.setDescriptorSetCount(1);
105
106 vk::DescriptorSet set;
107 auto result = context_vk.GetDevice().allocateDescriptorSets(&set_info, &set);
108 if (result == vk::Result::eErrorOutOfPoolMemory) {
109 // If the pool ran out of memory, we need to create a new pool.
110 CreateNewPool(context_vk);
111 set_info.setDescriptorPool(pools_.back().get());
112 result = context_vk.GetDevice().allocateDescriptorSets(&set_info, &set);
113 }
114
115 if (result != vk::Result::eSuccess) {
116 VALIDATION_LOG << "Could not allocate descriptor sets: "
117 << vk::to_string(result);
118 return fml::Status(fml::StatusCode::kUnknown, "");
119 }
120 return set;
121 }
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

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

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

- impeller/renderer/backend/vulkan/descriptor_pool_vk.h
- impeller/renderer/backend/vulkan/descriptor_pool_vk.cc