Initialising the Queues#

The queue serves as the link between GPU and software.

Queues are part of the GPU. The action of submitting a task to a queue via the command buffer is the action of beginning to execute the command. The application submits work using synchronisation objects to the queue using commands such as vkQueueSubmit(). This can be seen later on in this tutorial.

A number of graphics queues were already created alongside the logical device. The handle for these queues needs to be retrieved and stored so that command buffers can be submitted to them.

In this example, the application needs two queues: one for rendering and one for presenting to the surface. Some devices may support both operations on the same queue family. View in context.

void VulkanHelloAPI::initQueues()
{
    // Get the queue from the logical device created earlier and save it for later.
    vk::GetDeviceQueue(appManager.device, appManager.graphicsQueueFamilyIndex, 0, &appManager.graphicQueue);

    // If the queue family indices are the same, then the same queue is used to do both operations.
    // If not, another queue is retrieved for presenting.
    if (appManager.graphicsQueueFamilyIndex == appManager.presentQueueFamilyIndex) { appManager.presentQueue = appManager.graphicQueue; }
    else
    {
        vk::GetDeviceQueue(appManager.device, appManager.presentQueueFamilyIndex, 0, &appManager.presentQueue);
    }
}