Hymn to Beauty
C++ 3D Engine
Video::VulkanCommandBuffer Class Reference

Vulkan implementation of CommandBuffer. More...

#include <VulkanCommandBuffer.hpp>

Inheritance diagram for Video::VulkanCommandBuffer:
Video::CommandBuffer

Classes

struct  Timing
 Timing for a block of work. More...
 

Public Member Functions

 VulkanCommandBuffer (VulkanRenderer *vulkanRenderer, VkDevice device, VkCommandPool commandPool, VulkanRenderPassAllocator &renderPassAllocator)
 Create new Vulkan command buffer. More...
 
 ~VulkanCommandBuffer () final
 Destructor. More...
 
void BeginRenderPass (RenderPass *renderPass, const std::string &name) final
 Begin render pass. More...
 
void BeginRenderPass (Texture *colorAttachment, RenderPass::LoadOperation colorLoadOperation, Texture *depthAttachment, RenderPass::LoadOperation depthLoadOperation, const std::string &name) final
 Begin render pass. More...
 
void BeginAttachmentlessRenderPass (const glm::uvec2 &size, uint32_t msaaSamples, const std::string &name) final
 Begin attachmentless render pass. More...
 
void EndRenderPass () final
 End render pass. More...
 
void BindGraphicsPipeline (GraphicsPipeline *graphicsPipeline) final
 Bind graphics pipeline. More...
 
void SetViewport (const glm::uvec2 &origin, const glm::uvec2 &size) final
 Set the viewport to render to. More...
 
void SetScissor (const glm::uvec2 &origin, const glm::uvec2 &size) final
 Set the scissor box. More...
 
void SetLineWidth (float width) final
 Set width of lines. More...
 
void BindGeometry (GeometryBinding *geometryBinding) final
 Bind geometry to be used in upcoming draw calls. More...
 
void BindUniformBuffer (ShaderProgram::BindingType bindingType, Buffer *uniformBuffer) final
 Bind uniform buffer for use in a shader. More...
 
void BindStorageBuffers (std::initializer_list< Buffer * > buffers) final
 Bind storage buffers. More...
 
void BindMaterial (std::initializer_list< std::pair< Texture *, const Sampler * > > textures) final
 Bind a material. More...
 
void PushConstants (const void *data) final
 Update push constants. More...
 
void Draw (unsigned int vertexCount, unsigned int firstVertex) final
 Draw geometry. More...
 
void DrawIndexed (unsigned int indexCount, unsigned int firstIndex, unsigned int baseVertex) final
 Draw indexed geometry. More...
 
void DrawIndexedInstanced (unsigned int indexCount, unsigned int instanceCount, unsigned int firstIndex, unsigned int baseVertex) final
 Draw indexed instanced geometry. More...
 
void BlitToSwapChain (Texture *texture) final
 Blit a texture to the current swap chain image. More...
 
void BindComputePipeline (ComputePipeline *computePipeline) final
 Bind compute pipeline. More...
 
void Dispatch (const glm::uvec3 &numGroups, const std::string &name) final
 Dispatch compute shader. More...
 
void ClearBuffer (Buffer *buffer) final
 Clear a buffer (fill with 0). More...
 
VkCommandBuffer GetCommandBuffer () const
 Get command buffer. More...
 
void End ()
 Finish recording the command buffer. More...
 
void NextFrame ()
 Cycle the command buffer for the next frame. More...
 
bool ContainsBlitToSwapChain () const
 Get whether the command buffer contains a blit to the swap chain. More...
 
const std::vector< Timing > & GetTimings () const
 Get the all timings in the command buffer. More...
 
- Public Member Functions inherited from Video::CommandBuffer
 CommandBuffer ()
 Create a new command buffer. More...
 
virtual ~CommandBuffer ()
 Destructor. More...
 
void SetViewportAndScissor (const glm::uvec2 &origin, const glm::uvec2 &size)
 Set both viewport and scissor. More...
 

Detailed Description

Vulkan implementation of CommandBuffer.

Constructor & Destructor Documentation

◆ VulkanCommandBuffer()

Video::VulkanCommandBuffer::VulkanCommandBuffer ( VulkanRenderer vulkanRenderer,
VkDevice  device,
VkCommandPool  commandPool,
VulkanRenderPassAllocator renderPassAllocator 
)

Create new Vulkan command buffer.

Parameters
vulkanRendererThe Vulkan renderer.
deviceThe Vulkan device.
commandPoolThe command pool to allocate the command buffer from.
renderPassAllocatorThe render pass allocator.

◆ ~VulkanCommandBuffer()

Video::VulkanCommandBuffer::~VulkanCommandBuffer ( )
final

Destructor.

Member Function Documentation

◆ BeginAttachmentlessRenderPass()

void Video::VulkanCommandBuffer::BeginAttachmentlessRenderPass ( const glm::uvec2 &  size,
uint32_t  msaaSamples,
const std::string &  name 
)
finalvirtual

Begin attachmentless render pass.

Parameters
sizeThe framebuffer size.
msaaSamplesNumber of MSAA samples.
nameThe name of the render pass (displayed in profiling).

Implements Video::CommandBuffer.

◆ BeginRenderPass() [1/2]

void Video::VulkanCommandBuffer::BeginRenderPass ( RenderPass renderPass,
const std::string &  name 
)
finalvirtual

Begin render pass.

Parameters
renderPassThe render pass to begin.
nameThe name of the render pass (displayed in profiling).

Implements Video::CommandBuffer.

◆ BeginRenderPass() [2/2]

void Video::VulkanCommandBuffer::BeginRenderPass ( Texture colorAttachment,
RenderPass::LoadOperation  colorLoadOperation,
Texture depthAttachment,
RenderPass::LoadOperation  depthLoadOperation,
const std::string &  name 
)
finalvirtual

Begin render pass.

Parameters
colorAttachmentThe color attachment to draw to.
colorLoadOperationWhat to do with the previous contents of the color attachment.
depthAttachmentThe depth attachment to draw to.
depthLoadOperationWhat to do with the previous contents of the depth attachment.
nameThe name of the render pass (displayed in profiling).

Implements Video::CommandBuffer.

◆ BindComputePipeline()

void Video::VulkanCommandBuffer::BindComputePipeline ( ComputePipeline computePipeline)
finalvirtual

Bind compute pipeline.

Parameters
computePipelineThe compute pipeline to bind.

Implements Video::CommandBuffer.

◆ BindGeometry()

void Video::VulkanCommandBuffer::BindGeometry ( GeometryBinding geometryBinding)
finalvirtual

Bind geometry to be used in upcoming draw calls.

Parameters
geometryBindingThe geometry to bind.

Implements Video::CommandBuffer.

◆ BindGraphicsPipeline()

void Video::VulkanCommandBuffer::BindGraphicsPipeline ( GraphicsPipeline graphicsPipeline)
finalvirtual

Bind graphics pipeline.

Parameters
graphicsPipelineThe graphics pipeline to bind.

Implements Video::CommandBuffer.

◆ BindMaterial()

void Video::VulkanCommandBuffer::BindMaterial ( std::initializer_list< std::pair< Texture *, const Sampler * > >  textures)
finalvirtual

Bind a material.

Parameters
texturesThe textures to bind to the graphics pipeline.

Implements Video::CommandBuffer.

◆ BindStorageBuffers()

void Video::VulkanCommandBuffer::BindStorageBuffers ( std::initializer_list< Buffer * >  buffers)
finalvirtual

Bind storage buffers.

Parameters
buffersThe buffers to bind.

Implements Video::CommandBuffer.

◆ BindUniformBuffer()

void Video::VulkanCommandBuffer::BindUniformBuffer ( ShaderProgram::BindingType  bindingType,
Buffer uniformBuffer 
)
finalvirtual

Bind uniform buffer for use in a shader.

Parameters
bindingTypeWhere to bind the buffer.
uniformBufferThe buffer to bind.

Implements Video::CommandBuffer.

◆ BlitToSwapChain()

void Video::VulkanCommandBuffer::BlitToSwapChain ( Texture texture)
finalvirtual

Blit a texture to the current swap chain image.

Parameters
textureThe texture to copy to the swap chain.

Implements Video::CommandBuffer.

◆ ClearBuffer()

void Video::VulkanCommandBuffer::ClearBuffer ( Buffer buffer)
finalvirtual

Clear a buffer (fill with 0).

Parameters
bufferThe buffer to clear.

Implements Video::CommandBuffer.

◆ ContainsBlitToSwapChain()

bool Video::VulkanCommandBuffer::ContainsBlitToSwapChain ( ) const

Get whether the command buffer contains a blit to the swap chain.

Returns
Whether the command buffer contains a blit to the swap chain.

◆ Dispatch()

void Video::VulkanCommandBuffer::Dispatch ( const glm::uvec3 &  numGroups,
const std::string &  name 
)
finalvirtual

Dispatch compute shader.

Parameters
numGroupsThe number of groups in each dimension.
nameThe name of the dispatch (displayed in profiling).

Implements Video::CommandBuffer.

◆ Draw()

void Video::VulkanCommandBuffer::Draw ( unsigned int  vertexCount,
unsigned int  firstVertex 
)
finalvirtual

Draw geometry.

Parameters
vertexCountThe number of vertices to render.
firstVertexThe vertex to start rendering at.

Implements Video::CommandBuffer.

◆ DrawIndexed()

void Video::VulkanCommandBuffer::DrawIndexed ( unsigned int  indexCount,
unsigned int  firstIndex,
unsigned int  baseVertex 
)
finalvirtual

Draw indexed geometry.

Parameters
indexCountThe number of indices to render.
firstIndexThe index to start rendering at.
baseVertexConstant that should be added to each value in the index buffer.

Implements Video::CommandBuffer.

◆ DrawIndexedInstanced()

void Video::VulkanCommandBuffer::DrawIndexedInstanced ( unsigned int  indexCount,
unsigned int  instanceCount,
unsigned int  firstIndex,
unsigned int  baseVertex 
)
finalvirtual

Draw indexed instanced geometry.

Parameters
indexCountThe number of indices to render.
instanceCountThe number of instances to render.
firstIndexThe index to start rendering at.
baseVertexConstant that should be added to each value in the index buffer.

Implements Video::CommandBuffer.

◆ End()

void Video::VulkanCommandBuffer::End ( )

Finish recording the command buffer.

◆ EndRenderPass()

void Video::VulkanCommandBuffer::EndRenderPass ( )
finalvirtual

End render pass.

Implements Video::CommandBuffer.

◆ GetCommandBuffer()

VkCommandBuffer Video::VulkanCommandBuffer::GetCommandBuffer ( ) const

Get command buffer.

Returns
The internal Vulkan command buffer.

◆ GetTimings()

const std::vector< VulkanCommandBuffer::Timing > & Video::VulkanCommandBuffer::GetTimings ( ) const

Get the all timings in the command buffer.

Returns
All recorded timings.

◆ NextFrame()

void Video::VulkanCommandBuffer::NextFrame ( )

Cycle the command buffer for the next frame.

◆ PushConstants()

void Video::VulkanCommandBuffer::PushConstants ( const void *  data)
finalvirtual

Update push constants.

Parameters
dataThe data to push to the shader.

Implements Video::CommandBuffer.

◆ SetLineWidth()

void Video::VulkanCommandBuffer::SetLineWidth ( float  width)
finalvirtual

Set width of lines.

Parameters
widthThe line width.
Todo:
Clamp line width to supported values.

Implements Video::CommandBuffer.

◆ SetScissor()

void Video::VulkanCommandBuffer::SetScissor ( const glm::uvec2 &  origin,
const glm::uvec2 &  size 
)
finalvirtual

Set the scissor box.

Parameters
originThe bottom-left corner of the scissor box.
sizeThe size of the scissor box.

Implements Video::CommandBuffer.

◆ SetViewport()

void Video::VulkanCommandBuffer::SetViewport ( const glm::uvec2 &  origin,
const glm::uvec2 &  size 
)
finalvirtual

Set the viewport to render to.

Parameters
originThe bottom-left corner of the viewport.
sizeThe size of the viewport.

Implements Video::CommandBuffer.


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