LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::ICommandQueue Class Referenceabstract

The interface for a command queue. More...

#include <rendering_api.hpp>

Inherited by LiteFX::Rendering::CommandQueue< DirectX12CommandBuffer >, LiteFX::Rendering::CommandQueue< VulkanCommandBuffer >, and LiteFX::Rendering::CommandQueue< TCommandBuffer >.

Public Member Functions

virtual ~ICommandQueue () noexcept=default
 
virtual bool isBound () const noexcept=0
 Returns true, if the command queue is bound on the parent device. More...
 
virtual const QueuePriority & priority () const noexcept=0
 Returns the priority of the queue. More...
 
virtual const QueueType & type () const noexcept=0
 Returns the type of the queue. More...
 
virtual void bind ()=0
 Binds the queue on the parent device. More...
 
virtual void release ()=0
 Releases the queue from the parent device. More...
 
UniquePtr< ICommandBuffercreateCommandBuffer (const bool &beginRecording=false) const
 Creates a command buffer that can be used to allocate commands on the queue. More...
 
UInt64 submit (const ICommandBuffer &commandBuffer) const
 Submits a single command buffer and inserts a fence to wait for it. More...
 
UInt64 submit (const Array< const ICommandBuffer * > &commandBuffers) const
 Submits a set of command buffers and inserts a fence to wait for them. More...
 
virtual void waitFor (const UInt64 &fence) const noexcept=0
 Waits for a certain fence value to complete on the command queue. More...
 
virtual UInt64 currentFence () const noexcept=0
 Returns the value of the latest fence inserted into the queue. More...
 

Detailed Description

The interface for a command queue.

Constructor & Destructor Documentation

◆ ~ICommandQueue()

virtual LiteFX::Rendering::ICommandQueue::~ICommandQueue ( )
virtualdefaultnoexcept

Member Function Documentation

◆ bind()

virtual void LiteFX::Rendering::ICommandQueue::bind ( )
pure virtual

Binds the queue on the parent device.

See also
isBound

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.

◆ createCommandBuffer()

UniquePtr< ICommandBuffer > LiteFX::Rendering::ICommandQueue::createCommandBuffer ( const bool &  beginRecording = false) const
inline

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

Parameters
beginRecordingIf set to true, the command buffer will be initialized in recording state and can receive commands straight away.
Returns
The instance of the command buffer.

◆ currentFence()

virtual UInt64 LiteFX::Rendering::ICommandQueue::currentFence ( ) const
pure virtualnoexcept

Returns the value of the latest fence inserted into the queue.

Returns
The value of the latest fence inserted into the queue.
See also
waitFor

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.

◆ isBound()

virtual bool LiteFX::Rendering::ICommandQueue::isBound ( ) const
pure virtualnoexcept

Returns true, if the command queue is bound on the parent device.

Before a command queue can receive commands, it needs to be bound to a device. This ensures, that the queue is actually able to allocate commands. A command queue starts in unbound state until bind gets called. Destroying the queue also releases it by calling release.

See also
bind, release
Returns
true, if the command queue is bound on a device.

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.

◆ priority()

virtual const QueuePriority & LiteFX::Rendering::ICommandQueue::priority ( ) const
pure virtualnoexcept

Returns the priority of the queue.

Returns
The priority of the queue.

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.

◆ release()

virtual void LiteFX::Rendering::ICommandQueue::release ( )
pure virtual

Releases the queue from the parent device.

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.

◆ submit() [1/2]

UInt64 LiteFX::Rendering::ICommandQueue::submit ( const Array< const ICommandBuffer * > &  commandBuffers) const
inline

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

Note that submitting a command buffer that is currently recording will implicitly close the command buffer.

Parameters
commandBuffersThe command buffers to submit to the command queue.
Returns
The value of the fence, inserted after the command buffers.
See also
waitFor

◆ submit() [2/2]

UInt64 LiteFX::Rendering::ICommandQueue::submit ( const ICommandBuffer commandBuffer) const
inline

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

Note that submitting a command buffer that is currently recording will implicitly close the command buffer.

Parameters
commandBufferThe command buffer to submit to the command queue.
Returns
The value of the fence, inserted after the command buffer.
See also
waitFor

◆ type()

virtual const QueueType & LiteFX::Rendering::ICommandQueue::type ( ) const
pure virtualnoexcept

Returns the type of the queue.

Returns
The type of the queue.

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.

◆ waitFor()

virtual void LiteFX::Rendering::ICommandQueue::waitFor ( const UInt64 fence) const
pure virtualnoexcept

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

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 .

Note that this behavior can cause overflows when performing excessive fencing! Take for example a scenario, where each frame requires 80 fences to be signaled and an application that runs at 60 frames per second in average. In this case, each second 4.800 fences are inserted into the queue. Given the limit of an 64 bit unsigned integer fence value, the application can run ~2.9 billion years before overflowing. Drop me an e-mail or open an issue, if you ever happen to run into such a situation.

Parameters
fenceThe value of the fence to wait for.
See also
submit

Implemented in LiteFX::Rendering::Backends::DirectX12Queue, and LiteFX::Rendering::Backends::VulkanQueue.