Destroying an image
Images that won't be used any more should be destroyed to release their resources.
How to do it...
- Take a logical device and store its handle in a variable of type
VkDevice
namedlogical_device
. - Use the image's handle to initialize a variable of type
VkImage
namedimage
. - Call
vkDestroyImage( logical_device, image, nullptr )
. Provide the handle of the logical device, the handle of the image, and anullptr
value. - For safety reasons, assign a
VK_NULL_HANDLE
value to theimage
variable.
How it works...
Images are destroyed through a single call of the vkDestroyImage()
function. For it, we provide the handle of the logical device, the handle of the image, and a nullptr
value, like this:
if( VK_NULL_HANDLE != image ) { vkDestroyImage( logical_device, image, nullptr ); image = VK_NULL_HANDLE; }
We also try to avoid unnecessary function calls by checking whether the image's handle is not empty.
See also
- Creating an image recipe in this chapter