Destroying a semaphore
Semaphores can be reused multiple times, so usually we don't need to delete them when the application is executing. But when we don't need a semaphore any more, and if we are sure it is not being used by the device (there are both no pending waits, and no pending signal operations), we can destroy it.
How to do it...
- Take the handle of a logical device. Store this handle in a variable of type
VkDevicenamedlogical_device. - Initialize a variable of type
VkSemaphorenamedsemaphorewith a handle of the semaphore that should be destroyed. Make sure it is not referenced by any submissions. - Make the following call:
vkDestroySemaphore( logical_device, semaphore, nullptr ), for which provide the logical device's handle, the handle of the semaphore and anullptrvalue. - For safety reasons, assign a
VK_NULL_HANDLEvalue to thesemaphorevariable.
How it works...
Deleting a semaphore is quite easy:
if( VK_NULL_HANDLE != semaphore ) {
vkDestroySemaphore( logical_device, semaphore,...