Destroying a descriptor pool
When we don't need a descriptor pool any more, we can destroy it (with all descriptor sets allocated from the pool).
How to do it...
- Take the handle of a created logical device and store it in a variable of type
VkDevice
namedlogical_device
. - Provide the handle of the descriptor pool through a variable of type
VkDescriptorPool
nameddescriptor_pool
. - Call
vkDestroyDescriptorPool( logical_device, descriptor_pool, nullptr )
and provide thelogical_device
anddescriptor_pool
variables and anullptr
value. - For safety, assign the
VK_NULL_HANDLE
value to thedescriptor_pool
variable.
How it works...
Destroying a descriptor pool implicitly frees all descriptor sets allocated from it. We don't need to free individual descriptor sets first. But because of this, we need to make sure that none of the descriptor sets allocated from the pool are referenced by the commands that are currently processed by the hardware.
When we are ready, we can destroy a descriptor pool like this:
if...