Resetting fences
Semaphores are automatically reset. But when a fence becomes signaled, it is the application's responsibility to reset the fence back to the un-signaled state.
How to do it...
- Store the handle of a created logical device in a variable of type
VkDevice
namedlogical_device
.
- Create a vector variable named
fences
. It should contain elements of typeVkFence
. In the variable, store the handles of all fences that should be reset. - Call
vkResetFences( logical_device, static_cast<uint32_t>(fences.size()), &fences[0] )
and provide thelogical_device
variable, the number of elements in thefences
vector and a pointer to the first element of thefences
vector. - Make sure the function succeeded by checking if the value returned by the call was equal to
VK_SUCCESS
.
How it works...
When we want to know when submitted commands are finished, we use a fence. But we can't provide a fence that was already signaled. We must first reset it, which means that we change its state from signaled...