Creating a fence
Fences, opposite to semaphores, are used to synchronize an application with commands submitted to the graphics hardware. They inform the application when the processing of a submitted work has been finished. But before we can use fences, we need to create them.
How to do it...
- Take the created logical device and use its handle to initialize a variable of type
VkDevice
namedlogical_device
. - Create a variable of type
VkFenceCreateInfo
namedfence_create_info
. Use the following values to initialize its members:VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
value forsType
nullptr
value forpNext
- For
flags
use a0
value if a created fence should be un-signaled, or aVK_FENCE_CREATE_SIGNALED_BIT
value if a created fence should be signaled
- Create a variable of type
VkFence
namedfence
that will hold the handle of a created fence. - Call
vkCreateFence( logical_device, &fence_create_info, nullptr, &fence )
and provide thelogical_device
variable, a pointer to thefence_create_info
variable...