Destroying a command pool
When all command buffers allocated from a given pool are not used any more, and we also don't need the pool, we can safely destroy it.
How to do it...
- Take the handle of a logical device and store it in a variable of type
VkDevice
namedlogical_device
. - Use a handle of the pool that should be destroyed to initialize a variable of type
VkCommandPool
namedcommand_pool
. - Call
vkDestroyCommandPool( logical_device, command_pool, nullptr )
, for which provide the handles of the logical device and the command pool, and anullptr
value. - For safety reasons, assign the
VK_NULL_HANDLE
value to thecommand_pool
variable.
How it works...
The command pool is destroyed with the following code:
if( VK_NULL_HANDLE != command_pool ) { vkDestroyCommandPool( logical_device, command_pool, nullptr ); command_pool = VK_NULL_HANDLE; }
But, we can't destroy the pool until all command buffers allocated from it are not pending for execution on a device. To do that, we can wait on fences or use...