| Flutter Impeller |

Public Member Functions | List of all members
impeller::DescriptorPoolVK Class Reference

A short-lived fixed-sized 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 (const std::weak_ptr< const ContextVK > &context)
| ~DescriptorPoolVK ()
fml::StatusOr< std::vector< vk::DescriptorSet > > | AllocateDescriptorSets (uint32_t buffer_count, uint32_t sampler_count, uint32_t subpass_count, const std::vector< vk::DescriptorSetLayout > &layouts)

## Detailed Description

A short-lived fixed-sized 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 | ( | const std::weak_ptr< const ContextVK > & | context | ) |
| explicit

Definition at line 55 of file descriptor_pool_vk.cc.

57 : context_(context) {
58 FML_DCHECK(context.lock());
59 }

## ◆ ~DescriptorPoolVK()

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

Definition at line 61 of file descriptor_pool_vk.cc.

61 {
62 if (!pool_) {
63 return;
64 }
65
66 auto const context = context_.lock();
67 if (!context) {
68 return;
69 }
70 auto const recycler = context->GetDescriptorPoolRecycler();
71 if (!recycler) {
72 return;
73 }
74
75 auto reset_pool_when_dropped = BackgroundDescriptorPoolVK(
76 std::move(pool_), allocated_capacity_, recycler);
77
78 UniqueResourceVKT<BackgroundDescriptorPoolVK> pool(
79 context->GetResourceManager(), std::move(reset_pool_when_dropped));
80 }

## Member Function Documentation

## ◆ AllocateDescriptorSets()

fml::StatusOr< std::vector< vk::DescriptorSet > > impeller::DescriptorPoolVK::AllocateDescriptorSets | ( | uint32_t | buffer_count,
|  | uint32_t | sampler_count,
|  | uint32_t | subpass_count,
|  | const std::vector< vk::DescriptorSetLayout > & | layouts
| ) |  |

Definition at line 83 of file descriptor_pool_vk.cc.

87 {
88 std::shared_ptr<const ContextVK> strong_context = context_.lock();
89 if (!strong_context) {
90 return fml::Status(fml::StatusCode::kUnknown, "No device");
91 }
92 auto minimum_capacity =
93 std::max(std::max(sampler_count, buffer_count), subpass_count);
94 auto [new_pool, capacity] =
95 strong_context->GetDescriptorPoolRecycler()->Get(minimum_capacity);
96 if (!new_pool) {
97 return fml::Status(fml::StatusCode::kUnknown,
98 "Failed to create descriptor pool");
99 }
100 pool_ = std::move(new_pool);
101 allocated_capacity_ = capacity;
102
103 vk::DescriptorSetAllocateInfo set_info;
104 set_info.setDescriptorPool(pool_.get());
105 set_info.setSetLayouts(layouts);
106
107 auto [result, sets] =
108 strong_context->GetDevice().allocateDescriptorSets(set_info);
109 if (result != vk::Result::eSuccess) {
110 VALIDATION_LOG << "Could not allocate descriptor sets: "
111 << vk::to_string(result);
112 return fml::Status(fml::StatusCode::kUnknown, "");
113 }
114 return sets;
115 }

References 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

VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67