LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::Backends::DirectX12CommandBuffer Class Reference

Records commands for a DirectX12CommandQueue More...

#include <dx12.hpp>

Inherits LiteFX::Rendering::CommandBuffer< IDirectX12Buffer, IDirectX12VertexBuffer, IDirectX12IndexBuffer, IDirectX12Image, DirectX12Barrier, DirectX12PipelineState >, and LiteFX::Resource< THandle >.

Classes

class  DirectX12CommandBufferImpl
 

Public Member Functions

 DirectX12CommandBuffer (const DirectX12Queue &queue, const bool &begin=false)
 Initializes the command buffer from a command queue. More...
 
 DirectX12CommandBuffer (const DirectX12CommandBuffer &)=delete
 
 DirectX12CommandBuffer (DirectX12CommandBuffer &&)=delete
 
virtual ~DirectX12CommandBuffer () noexcept
 
virtual void begin () const override
 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 override
 Ends recording commands on the command buffer. More...
 
virtual void generateMipMaps (IDirectX12Image &image) noexcept override
 
virtual void barrier (const DirectX12Barrier &barrier, const bool &invert=false) const noexcept override
 
virtual void transfer (const IDirectX12Buffer &source, const IDirectX12Buffer &target, const UInt32 &sourceElement=0, const UInt32 &targetElement=0, const UInt32 &elements=1) const override
 
virtual void transfer (const IDirectX12Buffer &source, const IDirectX12Image &target, const UInt32 &sourceElement=0, const UInt32 &firstSubresource=0, const UInt32 &elements=1) const override
 
virtual void transfer (const IDirectX12Image &source, const IDirectX12Image &target, const UInt32 &sourceSubresource=0, const UInt32 &targetSubresource=0, const UInt32 &subresources=1) const override
 
virtual void transfer (const IDirectX12Image &source, const IDirectX12Buffer &target, const UInt32 &firstSubresource=0, const UInt32 &targetElement=0, const UInt32 &subresources=1) const override
 
virtual void use (const DirectX12PipelineState &pipeline) const noexcept override
 
virtual void bind (const DirectX12DescriptorSet &descriptorSet, const DirectX12PipelineState &pipeline) const noexcept override
 
virtual void bind (const IDirectX12VertexBuffer &buffer) const noexcept override
 
virtual void bind (const IDirectX12IndexBuffer &buffer) const noexcept override
 
virtual void dispatch (const Vector3u &threadCount) const noexcept override
 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 override
 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 override
 Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer. More...
 
virtual void pushConstants (const DirectX12PushConstantsLayout &layout, const void *const memory) const noexcept override
 
- Public Member Functions inherited from LiteFX::Rendering::CommandBuffer< IDirectX12Buffer, IDirectX12VertexBuffer, IDirectX12IndexBuffer, IDirectX12Image, DirectX12Barrier, DirectX12PipelineState >
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...
 
- Public Member Functions inherited from LiteFX::Resource< THandle >
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
virtual ~Resource () noexcept=default
 
const THandle & handle () const noexcept override
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::IResource< THandle >
virtual ~IResource () noexcept=default
 
virtual const THandle & handle () const noexcept=0
 Returns the resource managed by the class. More...
 

Additional Inherited Members

- Public Types inherited from LiteFX::Rendering::CommandBuffer< IDirectX12Buffer, IDirectX12VertexBuffer, IDirectX12IndexBuffer, IDirectX12Image, DirectX12Barrier, DirectX12PipelineState >
using buffer_type = IDirectX12Buffer
 
using vertex_buffer_type = IDirectX12VertexBuffer
 
using index_buffer_type = IDirectX12IndexBuffer
 
using image_type = IDirectX12Image
 
using barrier_type = DirectX12Barrier
 
using pipeline_type = DirectX12PipelineState
 
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
 
- Protected Member Functions inherited from LiteFX::Resource< THandle >
 Resource (const THandle handle) noexcept
 Initializes the managed resource. More...
 
THandle & handle () noexcept override
 Returns the resource managed by the class. More...
 
virtual THandle & handle () noexcept=0
 Returns the resource managed by the class. More...
 

Detailed Description

Records commands for a DirectX12CommandQueue

See also
DirectX12CommandQueue

Constructor & Destructor Documentation

◆ DirectX12CommandBuffer() [1/3]

DirectX12CommandBuffer::DirectX12CommandBuffer ( const DirectX12Queue queue,
const bool &  begin = false 
)
explicit

Initializes the command buffer from a command queue.

Parameters
queueThe parent command queue, the buffer gets submitted to.
beginIf set to true, the command buffer automatically starts recording by calling begin.

◆ DirectX12CommandBuffer() [2/3]

LiteFX::Rendering::Backends::DirectX12CommandBuffer::DirectX12CommandBuffer ( const DirectX12CommandBuffer )
delete

◆ DirectX12CommandBuffer() [3/3]

LiteFX::Rendering::Backends::DirectX12CommandBuffer::DirectX12CommandBuffer ( DirectX12CommandBuffer &&  )
delete

◆ ~DirectX12CommandBuffer()

DirectX12CommandBuffer::~DirectX12CommandBuffer ( )
virtualdefaultnoexcept

Member Function Documentation

◆ barrier()

void DirectX12CommandBuffer::barrier ( const DirectX12Barrier barrier,
const bool &  invert = false 
) const
overridevirtualnoexcept

◆ begin()

void DirectX12CommandBuffer::begin ( ) const
overridevirtual

Sets the command buffer into recording state, so that it can receive command that should be submitted to the parent CommandQueue.

Implements LiteFX::Rendering::ICommandBuffer.

◆ bind() [1/3]

void DirectX12CommandBuffer::bind ( const DirectX12DescriptorSet descriptorSet,
const DirectX12PipelineState pipeline 
) const
overridevirtualnoexcept

◆ bind() [2/3]

void DirectX12CommandBuffer::bind ( const IDirectX12IndexBuffer buffer) const
overridevirtualnoexcept

◆ bind() [3/3]

void DirectX12CommandBuffer::bind ( const IDirectX12VertexBuffer buffer) const
overridevirtualnoexcept

◆ dispatch()

void DirectX12CommandBuffer::dispatch ( const Vector3u threadCount) const
overridevirtualnoexcept

Executes a compute shader.

Implements LiteFX::Rendering::ICommandBuffer.

◆ draw()

void DirectX12CommandBuffer::draw ( const UInt32 vertices,
const UInt32 instances = 1,
const UInt32 firstVertex = 0,
const UInt32 firstInstance = 0 
) const
overridevirtualnoexcept

Draws a number of vertices from the currently bound vertex buffer.

Implements LiteFX::Rendering::ICommandBuffer.

◆ drawIndexed()

void DirectX12CommandBuffer::drawIndexed ( const UInt32 indices,
const UInt32 instances = 1,
const UInt32 firstIndex = 0,
const Int32 vertexOffset = 0,
const UInt32 firstInstance = 0 
) const
overridevirtualnoexcept

Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.

Implements LiteFX::Rendering::ICommandBuffer.

◆ end()

void DirectX12CommandBuffer::end ( ) const
overridevirtual

Ends recording commands on the command buffer.

Implements LiteFX::Rendering::ICommandBuffer.

◆ generateMipMaps()

void DirectX12CommandBuffer::generateMipMaps ( IDirectX12Image image)
overridevirtualnoexcept

◆ pushConstants()

void DirectX12CommandBuffer::pushConstants ( const DirectX12PushConstantsLayout layout,
const void *const  memory 
) const
overridevirtualnoexcept

◆ transfer() [1/4]

void DirectX12CommandBuffer::transfer ( const IDirectX12Buffer source,
const IDirectX12Buffer target,
const UInt32 sourceElement = 0,
const UInt32 targetElement = 0,
const UInt32 elements = 1 
) const
overridevirtual

◆ transfer() [2/4]

void DirectX12CommandBuffer::transfer ( const IDirectX12Buffer source,
const IDirectX12Image target,
const UInt32 sourceElement = 0,
const UInt32 firstSubresource = 0,
const UInt32 elements = 1 
) const
overridevirtual

◆ transfer() [3/4]

void DirectX12CommandBuffer::transfer ( const IDirectX12Image source,
const IDirectX12Buffer target,
const UInt32 firstSubresource = 0,
const UInt32 targetElement = 0,
const UInt32 subresources = 1 
) const
overridevirtual

◆ transfer() [4/4]

void DirectX12CommandBuffer::transfer ( const IDirectX12Image source,
const IDirectX12Image target,
const UInt32 sourceSubresource = 0,
const UInt32 targetSubresource = 0,
const UInt32 subresources = 1 
) const
overridevirtual

◆ use()

void DirectX12CommandBuffer::use ( const DirectX12PipelineState pipeline) const
overridevirtualnoexcept