Creating a semaphore
Before we can submit commands and utilize the device's processing power, we need to know how to synchronize operations. Semaphores are one of the primitives used for synchronization. They allow us to coordinate operations submitted to queues, not only within one queue, but also between different queues in one logical device.
Semaphores are used when we submit commands to queues. So before we can use them during the submission of command buffers, we need to create them.
How to do it...
- Take the handle of a created logical device. Store the handle in a variable of type
VkDevice
namedlogical_device
. - Create a variable of type
VkSemaphoreCreateInfo
namedsemaphore_create_info
. Use the following values to initialize its members:VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
value forsType
nullptr
value forpNext
0
value forflags
- Create a variable of type
VkSemaphore
namedsemaphore
. In this variable, a handle of a created semaphore will be stored. - Make the following function call:
vkCreateSemaphore...