Freeing descriptor sets
If we want to return memory allocated by a descriptor set and give it back to the pool, we can free a given descriptor set.
How to do it...
- Use the handle of a logical device to initialize a variable of type
VkDevice
namedlogical_device
. - Take the descriptor pool that was created with a
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT
flag. Store its handle in a variable of typeVkDescriptorPool
nameddescriptor_pool
. - Create a vector of type
std::vector<VkDescriptorSet>
nameddescriptor_sets
. Add all the descriptor sets that should be freed to the vector. - Call
vkFreeDescriptorSets( logical_device, descriptor_pool, static_cast<uint32_t>(descriptor_sets.size()), descriptor_sets.data() )
. For the call provide thelogical_device
anddescriptor_pool
variables, the number of elements in thedescriptor_sets
vector, and a pointer to the first element of thedescriptor_sets
vector. - Make sure the call was successful by checking whether it returns a
VK_SUCCESS
value. - Clear...