CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::VKCommandBuffer Class Referencefinal

The GPUCommandBuffer implementation for the Vulkan RenderAPI. More...

#include <CeresEngine/RenderAPI/Vulkan/VKCommandBuffer.hpp>

Inheritance diagram for CeresEngine::VKCommandBuffer:
CeresEngine::GPUCommandBuffer CeresEngine::VKDeviceObject< VKCommandBuffer, GPUCommandBuffer > CeresEngine::TDeviceObject< GPUCommandBufferDescriptor > CeresEngine::VKObject< ChildTypeName, ParentType > CeresEngine::VKDeviceObjectBase CeresEngine::GPUDeviceObject CeresEngine::VKObjectBase CeresEngine::GPUObject

Public Types

using Allocator = VKObjectAllocator
 An allocator type used to allocate new VKCommandBuffer instances from a memory pool.
 
- Public Types inherited from CeresEngine::TDeviceObject< GPUCommandBufferDescriptor >
using Descriptor = GPUCommandBufferDescriptor
 An type-alias to the descriptor struct type.
 

Public Member Functions

 VKCommandBuffer (VKDevice &device, VKCommandQueue &commandQueue, const GPUCommandBufferDescriptor &descriptor)
 
 ~VKCommandBuffer () final
 
 operator VkCommandBuffer () const noexcept
 Generates a hash for the provided type.
 
void bindResourceSet (GPUResourceSet &resourceSet, UInt32 firstSet=0, Int32 offset=-1) final
 
void bindVertexBuffer (GPUBuffer &vertexBuffer, UInt32 offset=0, UInt32 slot=0) final
 
void bindIndexBuffer (GPUBuffer &indexBuffer, UInt32 offset=0, IndexType indexType=IndexType::UInt32) final
 
void draw (UInt32 vertexCount, UInt32 instanceCount=1, UInt32 firstVertex=0, UInt32 firstInstance=0) final
 
void draw (GPUBuffer &buffer, UInt32 drawCount, UInt32 bufferOffset=0, UInt32 stride=sizeof(GPUDrawIndirectCommand)) final
 
void drawIndexed (UInt32 indexCount, UInt32 instanceCount=1, UInt32 firstVertex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) final
 
void drawIndexed (GPUBuffer &buffer, UInt32 drawCount, UInt32 bufferOffset=0, UInt32 stride=sizeof(GPUDrawIndexedIndirectCommand)) final
 
void dispatch (UInt32 groupCountX, UInt32 groupCountY, UInt32 groupCountZ) final
 
void setViewport (const Viewport &viewport) final
 
void setViewports (const SmallVector< Viewport, 16 > &viewports) final
 
void setScissor (const Scissor &scissor) final
 
void setScissors (const SmallVector< Scissor, 16 > &scissors) final
 
void drawMeshTasks (UInt32 groupCountX, UInt32 groupCountY, UInt32 groupCountZ) final
 Draw mesh task work items.
 
void drawMeshTasksIndirect (GPUBuffer &buffer, UInt64 offset, UInt32 drawCount, UInt32 stride) final
 Issue an indirect mesh tasks draw into a command buffer.
 
void drawMeshTasksIndirect (GPUBuffer &buffer, UInt64 offset, GPUBuffer &countBuffer, UInt64 countBufferOffset, uint32_t maxDrawCount, uint32_t stride) final
 Issue an indirect mesh tasks draw into a command buffer.
 
void updateBuffer (GPUBuffer &dstBuffer, std::uint64_t dstOffset, const void *data, std::uint16_t dataSize) final
 
void copyBuffer (GPUBuffer &dstBuffer, std::uint64_t dstOffset, GPUBuffer &srcBuffer, std::uint64_t srcOffset, std::uint64_t size) final
 
void fillBuffer (GPUBuffer &dstBuffer, std::uint64_t dstOffset, std::uint32_t value, std::uint64_t fillSize=~0u) final
 
void copyBufferFromImage (GPUBuffer &dstBuffer, std::uint64_t dstOffset, GPUImage &srcImage, const GPUImageRegion &srcImageRegion, std::uint32_t rowStride=0, std::uint32_t layerStride=0) final
 
void copyImage (GPUImage &dstImage, const GPUImageLocation &dstLocation, GPUImage &srcImage, const GPUImageLocation &srcLocation, const TExtent3< UInt32 > &extent) final
 
void copyImageFromBuffer (GPUImage &dstImage, const GPUImageRegion &dstRegion, GPUBuffer &srcBuffer, std::uint64_t srcOffset, std::uint32_t rowStride=0, std::uint32_t layerStride=0) final
 
void resolveImage (GPUImage &dstImage, const GPUImageLocation &dstLocation, GPUImage &srcImage, const GPUImageLocation &srcLocation, const TExtent3< UInt32 > &extent) final
 
void clear (GPUImage &image) final
 
void generateMips (GPUImage &image) final
 
void generateMips (GPUImage &image, const GPUImageSubresource &subresource) final
 
void barrier (GPUImage &image, GPUImageLayout layout) final
 
void begin () final
 
void end () final
 
void wait () final
 
bool isReady () const
 
void reset ()
 Resets the active command buffer.
 
bool tryFinish ()
 A method called internally on every frame to check if the buffer has finished execution on the GPU.
 
- Public Member Functions inherited from CeresEngine::GPUCommandBuffer
 GPUCommandBuffer (const GPUCommandBuffer &)=delete
 Deleted copy constructor.
 
GPUCommandBufferoperator= (const GPUCommandBuffer &)=delete
 
 GPUCommandBuffer (GPUCommandBuffer &&)=delete
 Deleted move constructor.
 
GPUCommandBufferoperator= (GPUCommandBuffer &&)=delete
 
void bindResourceSet (const GPUResourceSetPtr &resourceSet, const UInt32 firstSet=0, const Int32 offset=-1)
 
void bindVertexBuffer (const GPUBufferPtr &vertexBuffer, const UInt32 offset=0, const UInt32 slot=0)
 
virtual void bindVertexBuffer (const GPUVertexBuffer &vertexBuffer)
 Binds a vertex buffer for drawing.
 
void bindIndexBuffer (const GPUBufferPtr &indexBuffer, const UInt32 offset=0, const IndexType indexType=IndexType::UInt32)
 
virtual void bindIndexBuffer (const GPUIndexBuffer &indexBuffer)
 Binds a index buffer for drawing.
 
void draw (const GPUIndirectBuffer &buffer, UInt32 drawCount, UInt32 stride=sizeof(GPUDrawIndirectCommand))
 
void drawIndexed (const GPUIndirectBuffer &buffer, UInt32 drawCount, UInt32 stride=sizeof(GPUDrawIndexedIndirectCommand))
 
void buildAccelerationStructures ()
 
void buildAccelerationStructuresIndirect ()
 
void copyAccelerationStructure ()
 
void copyAccelerationStructureToMemory ()
 
void copyMemoryToAccelerationStructure ()
 
void writeAccelerationStructuresProperties ()
 
void setRayTracingPipelineStackSize ()
 
void traceRays ()
 
void traceRaysIndirect ()
 
template<typename Func >
decltype(autorecord (Func &&recorder)
 Records a sequence of commands to be executed by the GPU.
 
 TDeviceObject (GPUDevice &device, const Descriptor &descriptor)
 Inherited constructors.
 
 TDeviceObject (const TDeviceObject &)=delete
 Inherited constructors.
 
 TDeviceObject (TDeviceObject &&)=delete
 Inherited constructors.
 
- Public Member Functions inherited from CeresEngine::TDeviceObject< GPUCommandBufferDescriptor >
 TDeviceObject (GPUDevice &device, const Descriptor &descriptor)
 Initializes a new RenderAPI device object instance.
 
 TDeviceObject (const TDeviceObject &)=delete
 
 TDeviceObject (TDeviceObject &&)=delete
 
 ~TDeviceObject () override=default
 
TDeviceObjectoperator= (const TDeviceObject &)=delete
 
TDeviceObjectoperator= (TDeviceObject &&)=delete
 
- Public Member Functions inherited from CeresEngine::GPUDeviceObject
 GPUDeviceObject (GPUDevice &device)
 
 ~GPUDeviceObject () override
 
- Public Member Functions inherited from CeresEngine::GPUObject
 GPUObject ()=default
 
virtual ~GPUObject ()=default
 
 GPUObject (const GPUObject &)=delete
 
GPUObjectoperator= (const GPUObject &)=delete
 
 GPUObject (GPUObject &&)=delete
 
GPUObjectoperator= (GPUObject &&)=delete
 
void retain () noexcept
 Retains the object by increment it's reference count by one.
 
bool release () noexcept
 Releases the object by decrementing it's reference count by one.
 
- Public Member Functions inherited from CeresEngine::VKDeviceObjectBase
 VKDeviceObjectBase (VKDevice &device) noexcept
 Creates a new VKDeviceObjectBase from the given device.
 
 ~VKDeviceObjectBase () noexcept
 Destroys the VKDeviceObjectBase.
 

Static Public Member Functions

static AllocatorgetAllocator () noexcept
 Returns the allocator for VKCommandBuffer.
 
static voidoperator new (size_t size) noexcept
 Allocates memory for a new instance of VKCommandBuffer.
 
static void operator delete (void *p, std::size_t size) noexcept
 Deletes memory for an instance of VKCommandBuffer.
 
- Static Public Member Functions inherited from CeresEngine::VKObject< ChildTypeName, ParentType >
static RC< ChildTypeNamecast (const RC< ParentType > &ptr)
 Casts a RC containing a ParentType pointer to a pointer to a pointer to a ChildTypeName.
 
static ChildTypeNamecast (ParentType &object)
 Casts a object of type ParentType to a object of type ChildTypeName.
 
static const ChildTypeNamecast (const ParentType &object)
 Casts a object of type ParentType to a object of type ChildTypeName.
 
static ChildTypeNamecast (ParentType *object)
 Casts a object of type ParentType to a object of type ChildTypeName.
 
static const ChildTypeNamecast (const ParentType *object)
 Casts a object of type ParentType to a object of type ChildTypeName.
 
- Static Public Member Functions inherited from CeresEngine::VKObjectBase
static voidoperator new (size_t size) noexcept
 
static void operator delete (void *p, std::size_t sz) noexcept
 

Private Attributes

const GPUCommandBufferDescriptor mDescriptorVK
 A structure that describes the command buffer and it's properties.
 
VKCommandQueuemCommandQueue
 The command queue that owns this command buffer.
 
VkCommandPool mCommandPool = VK_NULL_HANDLE
 The command pool used to allocate commands on the queue.
 
VkCommandBuffer mCommandBuffer
 The current active command buffer.
 
VkFence mCompletionFence
 A fence that must be signalled to indicate that the command buffer as finished execution.
 
VKCommandBufferTracker mTrackedState
 The tracked state for the submitted command buffer.
 
VkPipelineBindPoint mPipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS
 The current pipeline bind point.
 
Promise mCompletionPromise
 A promise to be fulfilled once the command buffer has completed execution.
 
SmallVector< VKImage *, 16, VKAllocatormImages {gVKAllocator()}
 The list of render targets used on the command buffer.
 
Vector< VKTimerQuery *, VKAllocatormTimerQueries {gVKAllocator()}
 The list of timer queries submitted on this command buffer.
 
VKRenderTargetmRenderTarget = nullptr
 
VKRenderPassmRenderPass = nullptr
 
VKGraphicsPipelinemGraphicsPipeline = nullptr
 
VKComputePipelinemComputePipeline = nullptr
 

Friends

class VKCommandQueue
 
class VKGraphicsPipeline
 
class VKComputePipeline
 
class VKRenderPass
 
class VKTimerQuery
 

Additional Inherited Members

- Public Attributes inherited from CeresEngine::GPUCommandBuffer
Event< void()> didFinish
 An event triggered whenever the command buffer has finished execution.
 
- Public Attributes inherited from CeresEngine::TDeviceObject< GPUCommandBufferDescriptor >
const Descriptordescriptor
 A structure that describes the object and it's properties.
 
- Public Attributes inherited from CeresEngine::GPUDeviceObject
GPUDevicedevice
 The owning device this object was created from.
 
- Public Attributes inherited from CeresEngine::VKDeviceObjectBase
VKDevicedeviceVK
 The owning VKDevice instance.
 
- Protected Member Functions inherited from CeresEngine::GPUObject
virtual void destroy () noexcept
 A internal method called by the system when the object reference count reaches zero.
 
- Protected Member Functions inherited from CeresEngine::VKDeviceObject< VKCommandBuffer, GPUCommandBuffer >
 VKDeviceObject (VKDevice &device) noexcept
 Creates a new VKDeviceObject from the given device.
 

Detailed Description

The GPUCommandBuffer implementation for the Vulkan RenderAPI.

Member Typedef Documentation

◆ Allocator

An allocator type used to allocate new VKCommandBuffer instances from a memory pool.

Constructor & Destructor Documentation

◆ VKCommandBuffer()

CeresEngine::VKCommandBuffer::VKCommandBuffer ( VKDevice device,
VKCommandQueue commandQueue,
const GPUCommandBufferDescriptor descriptor 
)

◆ ~VKCommandBuffer()

CeresEngine::VKCommandBuffer::~VKCommandBuffer ( )
final

Member Function Documentation

◆ barrier()

void CeresEngine::VKCommandBuffer::barrier ( GPUImage image,
GPUImageLayout  layout 
)
finalvirtual

◆ begin()

void CeresEngine::VKCommandBuffer::begin ( )
finalvirtual

◆ bindIndexBuffer()

void CeresEngine::VKCommandBuffer::bindIndexBuffer ( GPUBuffer indexBuffer,
UInt32  offset = 0,
IndexType  indexType = IndexType::UInt32 
)
finalvirtual

◆ bindResourceSet()

void CeresEngine::VKCommandBuffer::bindResourceSet ( GPUResourceSet resourceSet,
UInt32  firstSet = 0,
Int32  offset = -1 
)
finalvirtual

◆ bindVertexBuffer()

void CeresEngine::VKCommandBuffer::bindVertexBuffer ( GPUBuffer vertexBuffer,
UInt32  offset = 0,
UInt32  slot = 0 
)
finalvirtual

◆ clear()

void CeresEngine::VKCommandBuffer::clear ( GPUImage image)
finalvirtual

◆ copyBuffer()

void CeresEngine::VKCommandBuffer::copyBuffer ( GPUBuffer dstBuffer,
std::uint64_t  dstOffset,
GPUBuffer srcBuffer,
std::uint64_t  srcOffset,
std::uint64_t  size 
)
finalvirtual

◆ copyBufferFromImage()

void CeresEngine::VKCommandBuffer::copyBufferFromImage ( GPUBuffer dstBuffer,
std::uint64_t  dstOffset,
GPUImage srcImage,
const GPUImageRegion srcImageRegion,
std::uint32_t  rowStride = 0,
std::uint32_t  layerStride = 0 
)
finalvirtual

◆ copyImage()

void CeresEngine::VKCommandBuffer::copyImage ( GPUImage dstImage,
const GPUImageLocation dstLocation,
GPUImage srcImage,
const GPUImageLocation srcLocation,
const TExtent3< UInt32 > &  extent 
)
finalvirtual

◆ copyImageFromBuffer()

void CeresEngine::VKCommandBuffer::copyImageFromBuffer ( GPUImage dstImage,
const GPUImageRegion dstRegion,
GPUBuffer srcBuffer,
std::uint64_t  srcOffset,
std::uint32_t  rowStride = 0,
std::uint32_t  layerStride = 0 
)
finalvirtual

◆ dispatch()

void CeresEngine::VKCommandBuffer::dispatch ( UInt32  groupCountX,
UInt32  groupCountY,
UInt32  groupCountZ 
)
finalvirtual

◆ draw() [1/2]

void CeresEngine::VKCommandBuffer::draw ( GPUBuffer buffer,
UInt32  drawCount,
UInt32  bufferOffset = 0,
UInt32  stride = sizeof(GPUDrawIndirectCommand) 
)
finalvirtual

◆ draw() [2/2]

void CeresEngine::VKCommandBuffer::draw ( UInt32  vertexCount,
UInt32  instanceCount = 1,
UInt32  firstVertex = 0,
UInt32  firstInstance = 0 
)
finalvirtual

◆ drawIndexed() [1/2]

void CeresEngine::VKCommandBuffer::drawIndexed ( GPUBuffer buffer,
UInt32  drawCount,
UInt32  bufferOffset = 0,
UInt32  stride = sizeof(GPUDrawIndexedIndirectCommand) 
)
finalvirtual

◆ drawIndexed() [2/2]

void CeresEngine::VKCommandBuffer::drawIndexed ( UInt32  indexCount,
UInt32  instanceCount = 1,
UInt32  firstVertex = 0,
Int32  vertexOffset = 0,
UInt32  firstInstance = 0 
)
finalvirtual

◆ drawMeshTasks()

void CeresEngine::VKCommandBuffer::drawMeshTasks ( UInt32  groupCountX,
UInt32  groupCountY,
UInt32  groupCountZ 
)
finalvirtual

Draw mesh task work items.

Parameters
groupCountXThe number of local workgroups to dispatch in the X dimension.
groupCountYThe number of local workgroups to dispatch in the Y dimension.
groupCountZThe number of local workgroups to dispatch in the Z dimension.

Implements CeresEngine::GPUCommandBuffer.

◆ drawMeshTasksIndirect() [1/2]

void CeresEngine::VKCommandBuffer::drawMeshTasksIndirect ( GPUBuffer buffer,
UInt64  offset,
GPUBuffer countBuffer,
UInt64  countBufferOffset,
uint32_t  maxDrawCount,
uint32_t  stride 
)
finalvirtual

Issue an indirect mesh tasks draw into a command buffer.

Parameters
bufferThe buffer containing draw parameters.
offsetThe byte offset into buffer where parameters begin.
drawCountThe number of draws to execute, and can be zero.
strideThe byte stride between successive sets of draw parameters.

Implements CeresEngine::GPUCommandBuffer.

◆ drawMeshTasksIndirect() [2/2]

void CeresEngine::VKCommandBuffer::drawMeshTasksIndirect ( GPUBuffer buffer,
UInt64  offset,
UInt32  drawCount,
UInt32  stride 
)
finalvirtual

Issue an indirect mesh tasks draw into a command buffer.

Parameters
bufferThe buffer containing draw parameters.
offsetThe byte offset into buffer where parameters begin.
drawCountThe number of draws to execute, and can be zero.
strideThe byte stride between successive sets of draw parameters.

Implements CeresEngine::GPUCommandBuffer.

◆ end()

void CeresEngine::VKCommandBuffer::end ( )
finalvirtual

◆ fillBuffer()

void CeresEngine::VKCommandBuffer::fillBuffer ( GPUBuffer dstBuffer,
std::uint64_t  dstOffset,
std::uint32_t  value,
std::uint64_t  fillSize = ~0u 
)
finalvirtual

◆ generateMips() [1/2]

void CeresEngine::VKCommandBuffer::generateMips ( GPUImage image)
finalvirtual

◆ generateMips() [2/2]

void CeresEngine::VKCommandBuffer::generateMips ( GPUImage image,
const GPUImageSubresource subresource 
)
finalvirtual

◆ getAllocator()

static Allocator & CeresEngine::VKCommandBuffer::getAllocator ( )
staticnoexcept

Returns the allocator for VKCommandBuffer.

◆ isReady()

bool CeresEngine::VKCommandBuffer::isReady ( ) const

◆ operator delete()

static void CeresEngine::VKCommandBuffer::operator delete ( void p,
std::size_t  size 
)
staticnoexcept

Deletes memory for an instance of VKCommandBuffer.

◆ operator new()

static void * CeresEngine::VKCommandBuffer::operator new ( size_t  size)
staticnoexcept

Allocates memory for a new instance of VKCommandBuffer.

◆ operator VkCommandBuffer()

CeresEngine::VKCommandBuffer::operator VkCommandBuffer ( ) const
inlinenoexcept

Generates a hash for the provided type.

Type must have a std::hash specialization.

Template Parameters
Tthe type to be hashed
Parameters
vThe value to be hashed
Returns
The hashed value

◆ reset()

void CeresEngine::VKCommandBuffer::reset ( )

Resets the active command buffer.

◆ resolveImage()

void CeresEngine::VKCommandBuffer::resolveImage ( GPUImage dstImage,
const GPUImageLocation dstLocation,
GPUImage srcImage,
const GPUImageLocation srcLocation,
const TExtent3< UInt32 > &  extent 
)
finalvirtual

◆ setScissor()

void CeresEngine::VKCommandBuffer::setScissor ( const Scissor scissor)
finalvirtual

Reimplemented from CeresEngine::GPUCommandBuffer.

◆ setScissors()

void CeresEngine::VKCommandBuffer::setScissors ( const SmallVector< Scissor, 16 > &  scissors)
finalvirtual

◆ setViewport()

void CeresEngine::VKCommandBuffer::setViewport ( const Viewport viewport)
finalvirtual

Reimplemented from CeresEngine::GPUCommandBuffer.

◆ setViewports()

void CeresEngine::VKCommandBuffer::setViewports ( const SmallVector< Viewport, 16 > &  viewports)
finalvirtual

◆ tryFinish()

bool CeresEngine::VKCommandBuffer::tryFinish ( )

A method called internally on every frame to check if the buffer has finished execution on the GPU.

If the buffer has finished, true is returned and the onFinished event is triggered.

◆ updateBuffer()

void CeresEngine::VKCommandBuffer::updateBuffer ( GPUBuffer dstBuffer,
std::uint64_t  dstOffset,
const void data,
std::uint16_t  dataSize 
)
finalvirtual

◆ wait()

void CeresEngine::VKCommandBuffer::wait ( )
finalvirtual

Friends And Related Symbol Documentation

◆ VKCommandQueue

◆ VKComputePipeline

◆ VKGraphicsPipeline

◆ VKRenderPass

◆ VKTimerQuery

Member Data Documentation

◆ mCommandBuffer

VkCommandBuffer CeresEngine::VKCommandBuffer::mCommandBuffer
private

The current active command buffer.

◆ mCommandPool

VkCommandPool CeresEngine::VKCommandBuffer::mCommandPool = VK_NULL_HANDLE
private

The command pool used to allocate commands on the queue.

◆ mCommandQueue

VKCommandQueue& CeresEngine::VKCommandBuffer::mCommandQueue
private

The command queue that owns this command buffer.

◆ mCompletionFence

VkFence CeresEngine::VKCommandBuffer::mCompletionFence
private

A fence that must be signalled to indicate that the command buffer as finished execution.

◆ mCompletionPromise

Promise CeresEngine::VKCommandBuffer::mCompletionPromise
private

A promise to be fulfilled once the command buffer has completed execution.

Only set if the command buffer was submitted asynchronously.

◆ mComputePipeline

VKComputePipeline* CeresEngine::VKCommandBuffer::mComputePipeline = nullptr
private

◆ mDescriptorVK

const GPUCommandBufferDescriptor CeresEngine::VKCommandBuffer::mDescriptorVK
private

A structure that describes the command buffer and it's properties.

◆ mGraphicsPipeline

VKGraphicsPipeline* CeresEngine::VKCommandBuffer::mGraphicsPipeline = nullptr
private

◆ mImages

SmallVector<VKImage*, 16, VKAllocator> CeresEngine::VKCommandBuffer::mImages {gVKAllocator()}
private

The list of render targets used on the command buffer.

◆ mPipelineBindPoint

VkPipelineBindPoint CeresEngine::VKCommandBuffer::mPipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS
private

The current pipeline bind point.

◆ mRenderPass

VKRenderPass* CeresEngine::VKCommandBuffer::mRenderPass = nullptr
private

◆ mRenderTarget

VKRenderTarget* CeresEngine::VKCommandBuffer::mRenderTarget = nullptr
private

◆ mTimerQueries

Vector<VKTimerQuery*, VKAllocator> CeresEngine::VKCommandBuffer::mTimerQueries {gVKAllocator()}
private

The list of timer queries submitted on this command buffer.

◆ mTrackedState

VKCommandBufferTracker CeresEngine::VKCommandBuffer::mTrackedState
private

The tracked state for the submitted command buffer.


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