Destroying a buffer view
When we don't need a buffer view any more, we should destroy it.
How to do it...
- Take a logical device and store its handle in a variable of type
VkDevice
namedlogical_device
. - Use the buffer's view handle and initialize a variable of type
VkBufferView
namedbuffer_view
with it. - Call
vkDestroyBufferView( logical_device, buffer_view, nullptr )
. Provide the handle of the logical device, the handle of the buffer view, and anullptr
value. - For safety reasons, assign the
VK_NULL_HANDLE
value to thebuffer_view
variable.
How it works...
Buffer views are destroyed using the vkDestroyBufferView()
function:
if( VK_NULL_HANDLE != buffer_view ) { vkDestroyBufferView( logical_device, buffer_view, nullptr ); buffer_view = VK_NULL_HANDLE; }
To avoid unnecessary function calls, we check whether the buffer view's handle is not empty before we call a buffer view destroying function.
See also
- Creating a buffer view recipe in this chapter