VPP  0.7
A high-level modern C++ API for Vulkan
Public Member Functions | List of all members
vpp::Queue Class Reference

Command queue for execution of commands. More...

#include <vppQueue.hpp>

Public Member Functions

 Queue ()
 Constructs null reference.
 
 Queue (const Device &hDevice, unsigned int iQueue=0, EQueueType eQueue=Q_GRAPHICS)
 Constructs a queue reference to specified queue. More...
 
 Queue (unsigned int iFamily, const Device &hDevice, unsigned int iQueue)
 Constructs a queue reference to specified queue. More...
 
VkQueue handle () const
 Retrieves Vulkan handle to the queue object.
 
const Devicedevice () const
 Retrieves the parent device for the queue.
 
EQueueType type () const
 Retrieves the type of the queue.
 
 operator bool () const
 Checks if the queue object is valid (not a null reference).
 
void submit (const CommandBuffer &singleBuffer, const Semaphore &waitOnBegin=Semaphore(), const Semaphore &signalOnEnd=Semaphore(), const Fence &signalFenceOnEnd=Fence())
 Submits a command buffer (CommandBuffer object) for execution. More...
 
void submit (const std::vector< CommandBuffer > buffers, const Semaphore &waitOnBegin=Semaphore(), const Semaphore &signalOnEnd=Semaphore(), const Fence &signalFenceOnEnd=Fence())
 Submits a sequence of command buffers (CommandBuffer objects) for execution. More...
 
VkResult waitForIdle ()
 Waits until all operations on current queue are finished. More...
 

Detailed Description

Command queue for execution of commands.

This class represents a command queue. This is the means to execute commands recorded into command buffers.

Queues are contained within the rendering device (represented by a Device object). Each device contains at least one queue. Most real devices implement several queues.

Queues are categorized into families. This is because queues can have different capabilities, limiting selection of commands that may be performed by particular queue, but offering increased performance in return. There may be more than one queue within a family. Each family has an integer index.

VPP offers a simplified way to select a queue family, by using the EQueueType enumeration. There are currently two capability profiles:

In order to access a specific queue from desired family, use one of the constructors in Queue class to construct a Queue object. The object can be treated as a reference to the queue. Lifetime of the queue itself is not affected. You can quickly create Queue objects you need, submit commands to them and finally discard these objects.

Use the Queue::submit() methods to submit actual CommandBuffer objects to the queue. This is the topmost level operation in Vulkan to initiate rendering or any computation.

This object is reference-counted and may be passed by value.

Constructor & Destructor Documentation

◆ Queue() [1/2]

vpp::Queue::Queue ( const Device hDevice,
unsigned int  iQueue = 0,
EQueueType  eQueue = Q_GRAPHICS 
)
explicit

Constructs a queue reference to specified queue.

You must specify the device to access a queue belonging to.

Queue index is optional. Also optionally you can specify a queue family, using the EQueueType enumeration.

◆ Queue() [2/2]

vpp::Queue::Queue ( unsigned int  iFamily,
const Device hDevice,
unsigned int  iQueue 
)

Constructs a queue reference to specified queue.

You must specify the device to access a queue belonging to. Also in this constructor, you must explicitly provide queue family index and queue index within the family. This is the low-level constructor.

You can enumerate queue families and query their properties by using methods in PhysicalDevice class or Vulkan API directly. This is considered low-level usage and is rarely required.

Member Function Documentation

◆ submit() [1/2]

void vpp::Queue::submit ( const CommandBuffer singleBuffer,
const Semaphore waitOnBegin = Semaphore(),
const Semaphore signalOnEnd = Semaphore(),
const Fence signalFenceOnEnd = Fence() 
)

Submits a command buffer (CommandBuffer object) for execution.

This is the primary method of execution of all Vulkan commands by VPP.

Commands need to be recorded first into a CommandBuffer, forming a sequential program. Then the cxommand sequence is being sent for execution to the chosen queue.

This method does not wait for completion by default. The only required argument is the command buffer itself.

Optionally you can specify one or more synchronization primitives. None of them is mandatory, provide any set of them depending on your needs. These are the following primitives:

  • waitOnBegin: a Semaphore to wait on before the execution begins. You can ensure this way that some other rendering stage finishes before the execution of provided command buffer starts.
  • signalOnEnd: a Semaphore to be signaled when the execution ends. This allows to make other rendering phase dependent on this phase.
  • signalFenceOnEnd: a Fence to be signalled when the execution ends. Allows to wait for the finishing of execution on the CPU side. This is different from using the semaphores, as semaphores synchronize execution only on GPU side.

◆ submit() [2/2]

void vpp::Queue::submit ( const std::vector< CommandBuffer buffers,
const Semaphore waitOnBegin = Semaphore(),
const Semaphore signalOnEnd = Semaphore(),
const Fence signalFenceOnEnd = Fence() 
)

Submits a sequence of command buffers (CommandBuffer objects) for execution.

Alternative method allowing to set entire vector of command buffers at once.

◆ waitForIdle()

VkResult vpp::Queue::waitForIdle ( )

Waits until all operations on current queue are finished.

This is CPU side wait. It is very crude alternative to using fences, useful when we have no fence to wait on, but still want all jobs one the queue to be done before submitting more work.


The documentation for this class was generated from the following file: