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
VkDevice
namedlogical_device
. - Initialize a variable of type
VkSemaphore
namedsemaphore
with 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 anullptr
value. - For safety reasons, assign a
VK_NULL_HANDLE
value to thesemaphore
variable.
How it works...
Deleting a semaphore is quite easy:
if( VK_NULL_HANDLE != semaphore ) { vkDestroySemaphore( logical_device, semaphore,...