LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline > Class Template Referenceabstract

Represents a command buffer, that buffers commands that should be submitted to a CommandQueue. More...

#include <rendering.hpp>

Inherits LiteFX::Rendering::ICommandBuffer.

Public Types

using buffer_type = TBuffer
 
using vertex_buffer_type = TVertexBuffer
 
using index_buffer_type = TIndexBuffer
 
using image_type = TImage
 
using barrier_type = TBarrier
 
using pipeline_type = TPipeline
 
using pipeline_layout_type = pipeline_type::pipeline_layout_type
 
using descriptor_set_layout_type = pipeline_layout_type::descriptor_set_layout_type
 
using push_constants_layout_type = pipeline_layout_type::push_constants_layout_type
 
using descriptor_set_type = descriptor_set_layout_type::descriptor_set_type
 

Public Member Functions

virtual ~CommandBuffer () noexcept=default
 
virtual void barrier (const barrier_type &barrier, const bool &invert=false) const noexcept=0
 
virtual void generateMipMaps (image_type &image) noexcept=0
 
virtual void transfer (const buffer_type &source, const buffer_type &target, const UInt32 &sourceElement=0, const UInt32 &targetElement=0, const UInt32 &elements=1) const =0
 
virtual void transfer (const buffer_type &source, const image_type &target, const UInt32 &sourceElement=0, const UInt32 &firstSubresource=0, const UInt32 &elements=1) const =0
 
virtual void transfer (const image_type &source, const image_type &target, const UInt32 &sourceSubresource=0, const UInt32 &targetSubresource=0, const UInt32 &subresources=1) const =0
 
virtual void transfer (const image_type &source, const buffer_type &target, const UInt32 &firstSubresource=0, const UInt32 &targetElement=0, const UInt32 &subresources=1) const =0
 
virtual void use (const pipeline_type &pipeline) const noexcept=0
 
virtual void bind (const descriptor_set_type &descriptorSet, const pipeline_type &pipeline) const noexcept=0
 
virtual void bind (const vertex_buffer_type &buffer) const noexcept=0
 
virtual void bind (const index_buffer_type &buffer) const noexcept=0
 
virtual void pushConstants (const push_constants_layout_type &layout, const void *const memory) const noexcept=0
 
virtual void draw (const vertex_buffer_type &vertexBuffer, const UInt32 &instances=1, const UInt32 &firstVertex=0, const UInt32 &firstInstance=0) const
 
virtual void drawIndexed (const index_buffer_type &indexBuffer, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const
 
virtual void drawIndexed (const vertex_buffer_type &vertexBuffer, const index_buffer_type &indexBuffer, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const
 
- Public Member Functions inherited from LiteFX::Rendering::ICommandBuffer
virtual ~ICommandBuffer () noexcept=default
 
virtual void begin () const =0
 Sets the command buffer into recording state, so that it can receive command that should be submitted to the parent CommandQueue. More...
 
virtual void end () const =0
 Ends recording commands on the command buffer. More...
 
void barrier (const IBarrier &barrier, const bool &invert=false) const noexcept
 Executes the transitions that have been added to barrier . More...
 
void generateMipMaps (IImage &image) noexcept
 Uses the image at level 0 to generate mip-maps for the remaining levels. More...
 
void transfer (const IBuffer &source, const IBuffer &target, const UInt32 &sourceElement=0, const UInt32 &targetElement=0, const UInt32 &elements=1) const
 Performs a buffer-to-buffer transfer from source to target . More...
 
void transfer (const IBuffer &source, const IImage &target, const UInt32 &sourceElement=0, const UInt32 &firstSubresource=0, const UInt32 &elements=1) const
 Performs a buffer-to-image transfer from source to target . More...
 
void transfer (const IImage &source, const IImage &target, const UInt32 &sourceSubresource=0, const UInt32 &targetSubresource=0, const UInt32 &subresources=1) const
 Performs an image-to-image transfer from source to target . More...
 
void transfer (const IImage &source, const IBuffer &target, const UInt32 &firstSubresource=0, const UInt32 &targetElement=0, const UInt32 &subresources=1) const
 Performs an image-to-buffer transfer from source to target . More...
 
void use (const IPipeline &pipeline) const noexcept
 Sets the active pipeline state. More...
 
void bind (const IDescriptorSet &descriptorSet, const IPipeline &pipeline) const noexcept
 Binds the provided descriptor set to the provided pipeline. More...
 
void bind (const IVertexBuffer &buffer) const noexcept
 Binds a vertex buffer to the pipeline. More...
 
void bind (const IIndexBuffer &buffer) const noexcept
 Binds a index buffer to the pipeline. More...
 
virtual void dispatch (const Vector3u &threadCount) const noexcept=0
 Executes a compute shader. More...
 
virtual void draw (const UInt32 &vertices, const UInt32 &instances=1, const UInt32 &firstVertex=0, const UInt32 &firstInstance=0) const noexcept=0
 Draws a number of vertices from the currently bound vertex buffer. More...
 
virtual void drawIndexed (const UInt32 &indices, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const noexcept=0
 Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer. More...
 
void pushConstants (const IPushConstantsLayout &layout, const void *const memory) const noexcept
 Pushes a block of memory into the push constants backing memory. More...
 
void draw (const IVertexBuffer &vertexBuffer, const UInt32 &instances=1, const UInt32 &firstVertex=0, const UInt32 &firstInstance=0) const
 Draws all vertices from the vertex buffer provided in vertexBuffer . More...
 
void drawIndexed (const IIndexBuffer &indexBuffer, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const
 Draws the currently bound vertex buffer using the index buffer provided in indexBuffer . More...
 
void drawIndexed (const IVertexBuffer &vertexBuffer, const IIndexBuffer &indexBuffer, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const
 Draws the vertex buffer provided by vertexBuffer using the index buffer, provided by indexBuffer . More...
 

Detailed Description

template<typename TBuffer, typename TVertexBuffer, typename TIndexBuffer, typename TImage, typename TBarrier, typename TPipeline>
requires rtti::implements<TBarrier, Barrier<TBuffer, TImage>> && std::derived_from<TPipeline, Pipeline<typename TPipeline::pipeline_layout_type, typename TPipeline::shader_program_type>>
class LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >

Represents a command buffer, that buffers commands that should be submitted to a CommandQueue.

Template Parameters
TBufferThe generic buffer type. Must implement IBuffer.
TVertexBufferThe vertex buffer type. Must implement VertexBuffer.
TIndexBufferThe index buffer type. Must implement IndexBuffer.
TImageThe generic image type. Must implement IImage.
TBarrierThe barrier type. Must implement Barrier.
TPipelineThe common pipeline interface type. Must be derived from Pipeline.

Member Typedef Documentation

◆ barrier_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::barrier_type = TBarrier

◆ buffer_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::buffer_type = TBuffer

◆ descriptor_set_layout_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::descriptor_set_layout_type = pipeline_layout_type::descriptor_set_layout_type

◆ descriptor_set_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::descriptor_set_type = descriptor_set_layout_type::descriptor_set_type

◆ image_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::image_type = TImage

◆ index_buffer_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::index_buffer_type = TIndexBuffer

◆ pipeline_layout_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::pipeline_layout_type = pipeline_type::pipeline_layout_type

◆ pipeline_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::pipeline_type = TPipeline

◆ push_constants_layout_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::push_constants_layout_type = pipeline_layout_type::push_constants_layout_type

◆ vertex_buffer_type

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
using LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::vertex_buffer_type = TVertexBuffer

Constructor & Destructor Documentation

◆ ~CommandBuffer()

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::~CommandBuffer ( )
virtualdefaultnoexcept

Member Function Documentation

◆ barrier()

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::barrier ( const barrier_type barrier,
const bool &  invert = false 
) const
pure virtualnoexcept

◆ bind() [1/3]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::bind ( const descriptor_set_type descriptorSet,
const pipeline_type pipeline 
) const
pure virtualnoexcept

◆ bind() [2/3]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::bind ( const index_buffer_type buffer) const
pure virtualnoexcept

◆ bind() [3/3]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::bind ( const vertex_buffer_type buffer) const
pure virtualnoexcept

◆ draw()

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::draw ( const vertex_buffer_type vertexBuffer,
const UInt32 instances = 1,
const UInt32 firstVertex = 0,
const UInt32 firstInstance = 0 
) const
inlinevirtual

◆ drawIndexed() [1/2]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::drawIndexed ( const index_buffer_type indexBuffer,
const UInt32 instances = 1,
const UInt32 firstIndex = 0,
const Int32 vertexOffset = 0,
const UInt32 firstInstance = 0 
) const
inlinevirtual

◆ drawIndexed() [2/2]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::drawIndexed ( const vertex_buffer_type vertexBuffer,
const index_buffer_type indexBuffer,
const UInt32 instances = 1,
const UInt32 firstIndex = 0,
const Int32 vertexOffset = 0,
const UInt32 firstInstance = 0 
) const
inlinevirtual

◆ generateMipMaps()

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::generateMipMaps ( image_type image)
pure virtualnoexcept

◆ pushConstants()

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::pushConstants ( const push_constants_layout_type layout,
const void *const  memory 
) const
pure virtualnoexcept

◆ transfer() [1/4]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::transfer ( const buffer_type source,
const buffer_type target,
const UInt32 sourceElement = 0,
const UInt32 targetElement = 0,
const UInt32 elements = 1 
) const
pure virtual

◆ transfer() [2/4]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::transfer ( const buffer_type source,
const image_type target,
const UInt32 sourceElement = 0,
const UInt32 firstSubresource = 0,
const UInt32 elements = 1 
) const
pure virtual

◆ transfer() [3/4]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::transfer ( const image_type source,
const buffer_type target,
const UInt32 firstSubresource = 0,
const UInt32 targetElement = 0,
const UInt32 subresources = 1 
) const
pure virtual

◆ transfer() [4/4]

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::transfer ( const image_type source,
const image_type target,
const UInt32 sourceSubresource = 0,
const UInt32 targetSubresource = 0,
const UInt32 subresources = 1 
) const
pure virtual

◆ use()

template<typename TBuffer , typename TVertexBuffer , typename TIndexBuffer , typename TImage , typename TBarrier , typename TPipeline >
virtual void LiteFX::Rendering::CommandBuffer< TBuffer, TVertexBuffer, TIndexBuffer, TImage, TBarrier, TPipeline >::use ( const pipeline_type pipeline) const
pure virtualnoexcept