Destroying a sampler
When we no longer need a sampler and we are sure it is not used anymore by the pending commands, we can destroy it.
How to do it...
- Take the handle of a logical device on which the sampler was created and store it in a variable of type
VkDevice
namedlogical_device
. - Take the handle of the sampler that should be destroyed. Provide it through a variable of type
VkSampler
namedsampler
. - Call
vkDestroySampler( logical_device, sampler, nullptr )
and provide thelogical_device
andsampler
variables, and anullptr
value. - For safety, assign the
VK_NULL_HANDLE
value to thesampler
variable.
How it works...
Samplers are destroyed like this:
if( VK_NULL_HANDLE != sampler ) { vkDestroySampler( logical_device, sampler, nullptr ); sampler = VK_NULL_HANDLE; }
We don't have to check whether the sampler's handle is not empty, because a deletion of a VK_NULL_HANDLE
is ignored. We do this just to avoid an unnecessary function call. But when we delete a sampler, we must be sure that the handle...