Destroying a fence
Fences can be reused multiple times. But when we don't need them anymore, typically just before we close our application, we should destroy them.
How to do it...
- Take the handle of a logical device and store it in a variable of type
VkDevice
namedlogical_device
. - Take the handle of a fence that should be destroyed. Use the handle to initialize a variable of type
VkFence
namedfence
. - Call
vkDestroyFence( logical_device, fence, nullptr )
and provide the logical device's handle, thefence
variable and anullptr
value. - For safety reasons, assign the
VK_NULL_HANDLE
value to thefence
variable.
How it works...
Fences are destroyed using the vkDestroyFence()
function, like this:
if( VK_NULL_HANDLE != fence ) { vkDestroyFence( logical_device, fence, nullptr ); fence = VK_NULL_HANDLE; }
We don't need to check if a value of the fence
variable is not equal to the VK_NULL_HANDLE
value because destruction of a null handle will be ignored by the driver. But, we do this to skip an unnecessary...