SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::vk::VulkanQueue Class Referencefinal

Vulkan implementation of ICommandQueue. More...

#include <VulkanQueue.h>

Inheritance diagram for spark::render::vk::VulkanQueue:
spark::render::CommandQueue< VulkanCommandBuffer > spark::render::Resource< VkQueue > spark::render::ICommandQueue spark::render::IResource< VkQueue >

Classes

struct  Impl
 

Public Member Functions

 VulkanQueue (const VulkanDevice &device, QueueType type, QueuePriority priority, unsigned family_id, unsigned queue_id)
 
 VulkanQueue (const VulkanQueue &other)=delete
 
 VulkanQueue (VulkanQueue &&other) noexcept=delete
 
VulkanQueueoperator= (const VulkanQueue &other)=delete
 
VulkanQueueoperator= (VulkanQueue &&other) noexcept=delete
 
const VulkanDevicedevice () const noexcept
 Gets the parent VulkanDevice that provides the queue.
 
const VkCommandPool & commandPool () const noexcept
 Gets a reference to the command pool used to allocate command buffers.
 
unsigned familyId () const noexcept
 Gets the family ID of the queue.
 
unsigned queueId () const noexcept
 Gets the queue ID of the queue.
 
const VkSemaphore & timelineSemaphore () const noexcept
 Gets the internal semaphore used to synchronize the queue.
 
bool isBound () const noexcept override
 Checks whether the queue is currently bound to the parent device.
 
QueuePriority priority () const noexcept override
 Gets the priority of the queue.
 
QueueType type () const noexcept override
 Gets the type of the queue.
 
void bind () const noexcept override
 Binds the queue to the parent device.
 
void release () const noexcept override
 Releases the queue from the parent device.
 
void waitFor (std::size_t fence) const noexcept override
 Waits for fence value fence to complete on the command queue.
 
std::size_t currentFence () const noexcept override
 Gets the latest fence inserted into the queue.
 
std::shared_ptr< VulkanCommandBuffercreateCommandBuffer (bool begin_recording, bool secondary) const noexcept override
 Creates a command buffer that can be used to allocate commands on the queue.
 
std::size_t submit (std::shared_ptr< const VulkanCommandBuffer > command_buffer, std::span< VkSemaphore > wait_for_semaphores, std::span< VkPipelineStageFlags > wait_for_stages, std::span< VkSemaphore > signal_semaphores={}) const
 Submits a single command buffer and inserts a fence to wait for it.
 
std::size_t submit (const std::vector< std::shared_ptr< const VulkanCommandBuffer > > &command_buffers, std::span< VkSemaphore > wait_for_semaphores, std::span< VkPipelineStageFlags > wait_for_stages, std::span< VkSemaphore > signal_semaphores={}) const
 Submits a set of command buffers and inserts a fence to wait for them.
 
std::size_t submit (std::shared_ptr< VulkanCommandBuffer > command_buffer) const noexcept override
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
std::size_t submit (std::shared_ptr< const VulkanCommandBuffer > command_buffer) const noexcept override
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
std::size_t submit (const std::vector< std::shared_ptr< const VulkanCommandBuffer > > &command_buffers) const noexcept override
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
std::size_t submit (const std::vector< std::shared_ptr< VulkanCommandBuffer > > &command_buffers) const noexcept override
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
- Public Member Functions inherited from spark::render::CommandQueue< VulkanCommandBuffer >
virtual std::size_t submit (std::shared_ptr< command_buffer_type > command_buffer) const noexcept=0
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
virtual std::size_t submit (std::shared_ptr< const command_buffer_type > command_buffer) const noexcept=0
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
virtual std::size_t submit (const std::vector< std::shared_ptr< const command_buffer_type > > &command_buffers) const noexcept=0
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
virtual std::size_t submit (const std::vector< std::shared_ptr< command_buffer_type > > &command_buffers) const noexcept=0
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
- Public Member Functions inherited from spark::render::ICommandQueue
std::shared_ptr< ICommandBuffercreateCommandBuffer (bool begin_recording=false, bool secondary=false) const noexcept
 Creates a command buffer that can be used to allocate commands on the queue.
 
std::size_t submit (std::shared_ptr< ICommandBuffer > command_buffer) const noexcept
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
std::size_t submit (std::shared_ptr< const ICommandBuffer > command_buffer) const noexcept
 Submits a single command buffer to the queue and inserts a fence to wait for it.
 
std::size_t submit (const std::vector< std::shared_ptr< const ICommandBuffer > > &command_buffers) const noexcept
 Submits multiple command buffers to the queue and inserts a fence to wait for them.
 
std::size_t submit (const std::vector< std::shared_ptr< ICommandBuffer > > &command_buffers) const noexcept
 Submits multiple command buffers to the queue and inserts a fence to wait for them.
 
- Public Member Functions inherited from spark::render::Resource< VkQueue >
 Resource (VkQueue handle) noexcept
 Initializes the managed resource with the given handle.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other) noexcept=delete
 
Resourceoperator= (const Resource &other)=delete
 
Resourceoperator= (Resource &&other) noexcept=delete
 
const VkQueue & handle () const final
 Gets the managed resource handle.
 

Additional Inherited Members

- Public Types inherited from spark::render::CommandQueue< VulkanCommandBuffer >
using command_buffer_type
 
- Public Types inherited from spark::render::IResource< VkQueue >
using handle_type
 
- Protected Member Functions inherited from spark::render::Resource< VkQueue >
VkQueue & handle () final
 Gets the managed resource handle.
 

Detailed Description

Vulkan implementation of ICommandQueue.

Member Function Documentation

◆ bind()

void spark::render::vk::VulkanQueue::bind ( ) const
overridevirtualnoexcept

Binds the queue to the parent device.

Implements spark::render::ICommandQueue.

◆ commandPool()

const VkCommandPool & spark::render::vk::VulkanQueue::commandPool ( ) const
nodiscardnoexcept

Gets a reference to the command pool used to allocate command buffers.

Returns
A reference to the command pool used to allocate command buffers.
Note
The command pool exists only if the queue is bound to a device.

◆ createCommandBuffer()

std::shared_ptr< VulkanCommandBuffer > spark::render::vk::VulkanQueue::createCommandBuffer ( bool begin_recording,
bool secondary ) const
nodiscardoverridevirtualnoexcept

Creates a command buffer that can be used to allocate commands on the queue.

Parameters
begin_recordingtrue if the command buffer should be in recording state after creation, false otherwise.
secondarytrue if the command buffer should be a secondary command buffer, false otherwise.
Returns
A std::shared_ptr to the created ICommandBuffer.

Specifying secondary allows to create secondary command buffers (aka. bundles). Those are intended to be used as efficient pre-recorded command buffers that are re-used multiple times. Using such a command buffer allows drivers to pre-apply optimizations, which causes a one-time cost during setup, but reduces cost when re- applying the command buffer multiple times. Ideally they are used as small chunks of re-occurring workloads.

A secondary command buffer must not be submitted to a queue, but rather to a primary command buffer by calling ICommandBuffer::execute().

Implements spark::render::CommandQueue< VulkanCommandBuffer >.

◆ currentFence()

std::size_t spark::render::vk::VulkanQueue::currentFence ( ) const
nodiscardoverridevirtualnoexcept

Gets the latest fence inserted into the queue.

Returns
The latest fence value.

Implements spark::render::ICommandQueue.

◆ device()

const VulkanDevice & spark::render::vk::VulkanQueue::device ( ) const
nodiscardnoexcept

Gets the parent VulkanDevice that provides the queue.

Returns
The parent VulkanDevice that provides the queue.

◆ familyId()

unsigned spark::render::vk::VulkanQueue::familyId ( ) const
nodiscardnoexcept

Gets the family ID of the queue.

Returns
The family ID of the queue.

◆ isBound()

bool spark::render::vk::VulkanQueue::isBound ( ) const
nodiscardoverridevirtualnoexcept

Checks whether the queue is currently bound to the parent device.

Returns
true if the queue is bound, false otherwise.

Implements spark::render::ICommandQueue.

◆ priority()

QueuePriority spark::render::vk::VulkanQueue::priority ( ) const
nodiscardoverridevirtualnoexcept

Gets the priority of the queue.

Returns
A QueuePriority value.

Implements spark::render::ICommandQueue.

◆ queueId()

unsigned spark::render::vk::VulkanQueue::queueId ( ) const
nodiscardnoexcept

Gets the queue ID of the queue.

Returns
The queue ID.

◆ release()

void spark::render::vk::VulkanQueue::release ( ) const
overridevirtualnoexcept

Releases the queue from the parent device.

Implements spark::render::ICommandQueue.

◆ submit() [1/6]

std::size_t spark::render::vk::VulkanQueue::submit ( const std::vector< std::shared_ptr< const VulkanCommandBuffer > > & command_buffers) const
nodiscardoverridenoexcept

Submits a single command buffer to the queue and inserts a fence to wait for it.

Parameters
command_bufferThe command buffer to submit to the queue.
Returns
The fence that was inserted to wait for the command buffer.
Note
Submitting a recording command buffer will implicitly end the recording.

◆ submit() [2/6]

std::size_t spark::render::vk::VulkanQueue::submit ( const std::vector< std::shared_ptr< const VulkanCommandBuffer > > & command_buffers,
std::span< VkSemaphore > wait_for_semaphores,
std::span< VkPipelineStageFlags > wait_for_stages,
std::span< VkSemaphore > signal_semaphores = {} ) const
nodiscard

Submits a set of command buffers and inserts a fence to wait for them.

Parameters
command_buffersThe command buffers to submit to the command queue.
wait_for_semaphoresThe semaphores to wait for on each pipeline stage. There must be a semaphore for each entry in the waitForStages array.
wait_for_stagesThe pipeline stages of the current render pass to wait for before submitting the command buffer.
signal_semaphoresThe semaphores to signal, when the command buffer is executed.
Returns
The value of the fence, inserted after the command buffer.

By calling this method, the queue takes shared ownership over the command_buffers until the fence is passed. The reference will be released during a waitFor(), if the awaited fence is inserted after the associated one.

Note
If any of the command buffers is currently recording, it will implicitly end the recording.

◆ submit() [3/6]

std::size_t spark::render::vk::VulkanQueue::submit ( const std::vector< std::shared_ptr< VulkanCommandBuffer > > & command_buffers) const
nodiscardoverridenoexcept

Submits a single command buffer to the queue and inserts a fence to wait for it.

Parameters
command_bufferThe command buffer to submit to the queue.
Returns
The fence that was inserted to wait for the command buffer.
Note
Submitting a recording command buffer will implicitly end the recording.

◆ submit() [4/6]

std::size_t spark::render::vk::VulkanQueue::submit ( std::shared_ptr< const VulkanCommandBuffer > command_buffer) const
nodiscardoverridenoexcept

Submits a single command buffer to the queue and inserts a fence to wait for it.

Parameters
command_bufferThe command buffer to submit to the queue.
Returns
The fence that was inserted to wait for the command buffer.
Note
Submitting a recording command buffer will implicitly end the recording.

◆ submit() [5/6]

std::size_t spark::render::vk::VulkanQueue::submit ( std::shared_ptr< const VulkanCommandBuffer > command_buffer,
std::span< VkSemaphore > wait_for_semaphores,
std::span< VkPipelineStageFlags > wait_for_stages,
std::span< VkSemaphore > signal_semaphores = {} ) const
nodiscard

Submits a single command buffer and inserts a fence to wait for it.

Parameters
command_bufferThe command buffer to submit to the queue.
wait_for_semaphoresThe semaphores to wait for on each pipeline stage. There must be a semaphore for each entry in the wait_for_stages array.
wait_for_stagesThe pipeline stages of the current render pass to wait for before submitting the command buffer.
signal_semaphoresThe semaphores to signal, when the command buffer is executed.
Returns
The value of the fence, inserted after the command buffer.

By calling this method, the queue takes shared ownership over the command_buffer until the fence is passed. The reference will be released during a waitFor(), if the awaited fence is inserted after the associated one.

Note
If any of the command buffers is currently recording, it will implicitly end the recording.

◆ submit() [6/6]

std::size_t spark::render::vk::VulkanQueue::submit ( std::shared_ptr< VulkanCommandBuffer > command_buffer) const
nodiscardoverridenoexcept

Submits a single command buffer to the queue and inserts a fence to wait for it.

Parameters
command_bufferThe command buffer to submit to the queue.
Returns
The fence that was inserted to wait for the command buffer.
Note
Submitting a recording command buffer will implicitly end the recording.

◆ timelineSemaphore()

const VkSemaphore & spark::render::vk::VulkanQueue::timelineSemaphore ( ) const
nodiscardnoexcept

Gets the internal semaphore used to synchronize the queue.

Returns
The internal semaphore used to synchronize the queue.

◆ type()

QueueType spark::render::vk::VulkanQueue::type ( ) const
nodiscardoverridevirtualnoexcept

Gets the type of the queue.

Returns
A QueueType value.

Implements spark::render::ICommandQueue.

◆ waitFor()

void spark::render::vk::VulkanQueue::waitFor ( std::size_t fence) const
overridevirtualnoexcept

Waits for fence value fence to complete on the command queue.

Parameters
fenceThe fence value to wait for.

Each time one or more command buffers are submitted to the queue, a fence is inserted and its value will be returned. By calling this method, it is possible to wait for this fence. A fence value is guaranteed to be larger than earlier fences, so the method returns, if the latest signaled fence value is larger or equal to the value specified in fence.

Implements spark::render::ICommandQueue.