Hymn to Beauty
C++ 3D Engine
Video::CommandBuffer Class Referenceabstract

A buffer into which rendering commands are recorded. More...

#include <CommandBuffer.hpp>

Inheritance diagram for Video::CommandBuffer:
Video::OpenGLCommandBuffer Video::VulkanCommandBuffer Video::WebGPUCommandBuffer

Public Member Functions

 CommandBuffer ()
 Create a new command buffer. More...
 
virtual ~CommandBuffer ()
 Destructor. More...
 
virtual void BeginRenderPass (RenderPass *renderPass, const std::string &name="Untitled render pass")=0
 Begin render pass. More...
 
virtual void BeginRenderPass (Texture *colorAttachment, RenderPass::LoadOperation colorLoadOperation=RenderPass::LoadOperation::CLEAR, Texture *depthAttachment=nullptr, RenderPass::LoadOperation depthLoadOperation=RenderPass::LoadOperation::CLEAR, const std::string &name="Untitled render pass")=0
 Begin render pass. More...
 
virtual void BeginAttachmentlessRenderPass (const glm::uvec2 &size, uint32_t msaaSamples=1, const std::string &name="Untitled render pass")=0
 Begin attachmentless render pass. More...
 
virtual void EndRenderPass ()=0
 End render pass. More...
 
virtual void BindGraphicsPipeline (GraphicsPipeline *graphicsPipeline)=0
 Bind graphics pipeline. More...
 
virtual void SetViewport (const glm::uvec2 &origin, const glm::uvec2 &size)=0
 Set the viewport to render to. More...
 
virtual void SetScissor (const glm::uvec2 &origin, const glm::uvec2 &size)=0
 Set the scissor box. More...
 
void SetViewportAndScissor (const glm::uvec2 &origin, const glm::uvec2 &size)
 Set both viewport and scissor. More...
 
virtual void SetLineWidth (float width)=0
 Set width of lines. More...
 
virtual void BindGeometry (GeometryBinding *geometryBinding)=0
 Bind geometry to be used in upcoming draw calls. More...
 
virtual void BindUniformBuffer (ShaderProgram::BindingType bindingType, Buffer *uniformBuffer)=0
 Bind uniform buffer for use in a shader. More...
 
virtual void BindStorageBuffers (std::initializer_list< Buffer * > buffers)=0
 Bind storage buffers. More...
 
virtual void BindMaterial (std::initializer_list< std::pair< Texture *, const Sampler * > > textures)=0
 Bind a material. More...
 
virtual void PushConstants (const void *data)=0
 Update push constants. More...
 
virtual void Draw (unsigned int vertexCount, unsigned int firstVertex=0)=0
 Draw geometry. More...
 
virtual void DrawIndexed (unsigned int indexCount, unsigned int firstIndex=0, unsigned int baseVertex=0)=0
 Draw indexed geometry. More...
 
virtual void DrawIndexedInstanced (unsigned int indexCount, unsigned int instanceCount=1, unsigned int firstIndex=0, unsigned int baseVertex=0)=0
 Draw indexed instanced geometry. More...
 
virtual void BlitToSwapChain (Texture *texture)=0
 Blit a texture to the current swap chain image. More...
 
virtual void BindComputePipeline (ComputePipeline *computePipeline)=0
 Bind compute pipeline. More...
 
virtual void Dispatch (const glm::uvec3 &numGroups, const std::string &name="Untitled dispatch")=0
 Dispatch compute shader. More...
 
virtual void ClearBuffer (Buffer *buffer)=0
 Clear a buffer (fill with 0). More...
 

Detailed Description

A buffer into which rendering commands are recorded.

Command buffers have to be recorded in the same order as they are submitted.

Constructor & Destructor Documentation

◆ CommandBuffer()

Video::CommandBuffer::CommandBuffer ( )
inline

Create a new command buffer.

◆ ~CommandBuffer()

virtual Video::CommandBuffer::~CommandBuffer ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ BeginAttachmentlessRenderPass()

virtual void Video::CommandBuffer::BeginAttachmentlessRenderPass ( const glm::uvec2 &  size,
uint32_t  msaaSamples = 1,
const std::string &  name = "Untitled render pass" 
)
pure virtual

Begin attachmentless render pass.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BeginRenderPass() [1/2]

virtual void Video::CommandBuffer::BeginRenderPass ( RenderPass renderPass,
const std::string &  name = "Untitled render pass" 
)
pure virtual

Begin render pass.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BeginRenderPass() [2/2]

virtual void Video::CommandBuffer::BeginRenderPass ( Texture colorAttachment,
RenderPass::LoadOperation  colorLoadOperation = RenderPass::LoadOperation::CLEAR,
Texture depthAttachment = nullptr,
RenderPass::LoadOperation  depthLoadOperation = RenderPass::LoadOperation::CLEAR,
const std::string &  name = "Untitled render pass" 
)
pure virtual

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).

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BindComputePipeline()

virtual void Video::CommandBuffer::BindComputePipeline ( ComputePipeline computePipeline)
pure virtual

Bind compute pipeline.

Parameters
computePipelineThe compute pipeline to bind.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BindGeometry()

virtual void Video::CommandBuffer::BindGeometry ( GeometryBinding geometryBinding)
pure virtual

Bind geometry to be used in upcoming draw calls.

Parameters
geometryBindingThe geometry to bind.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BindGraphicsPipeline()

virtual void Video::CommandBuffer::BindGraphicsPipeline ( GraphicsPipeline graphicsPipeline)
pure virtual

Bind graphics pipeline.

Parameters
graphicsPipelineThe graphics pipeline to bind.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BindMaterial()

virtual void Video::CommandBuffer::BindMaterial ( std::initializer_list< std::pair< Texture *, const Sampler * > >  textures)
pure virtual

Bind a material.

Parameters
texturesThe textures to bind to the graphics pipeline.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BindStorageBuffers()

virtual void Video::CommandBuffer::BindStorageBuffers ( std::initializer_list< Buffer * >  buffers)
pure virtual

Bind storage buffers.

Parameters
buffersThe buffers to bind.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BindUniformBuffer()

virtual void Video::CommandBuffer::BindUniformBuffer ( ShaderProgram::BindingType  bindingType,
Buffer uniformBuffer 
)
pure virtual

Bind uniform buffer for use in a shader.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ BlitToSwapChain()

virtual void Video::CommandBuffer::BlitToSwapChain ( Texture texture)
pure virtual

Blit a texture to the current swap chain image.

Parameters
textureThe texture to copy to the swap chain.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ ClearBuffer()

virtual void Video::CommandBuffer::ClearBuffer ( Buffer buffer)
pure virtual

Clear a buffer (fill with 0).

Parameters
bufferThe buffer to clear.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ Dispatch()

virtual void Video::CommandBuffer::Dispatch ( const glm::uvec3 &  numGroups,
const std::string &  name = "Untitled dispatch" 
)
pure virtual

Dispatch compute shader.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ Draw()

virtual void Video::CommandBuffer::Draw ( unsigned int  vertexCount,
unsigned int  firstVertex = 0 
)
pure virtual

Draw geometry.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ DrawIndexed()

virtual void Video::CommandBuffer::DrawIndexed ( unsigned int  indexCount,
unsigned int  firstIndex = 0,
unsigned int  baseVertex = 0 
)
pure virtual

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.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ DrawIndexedInstanced()

virtual void Video::CommandBuffer::DrawIndexedInstanced ( unsigned int  indexCount,
unsigned int  instanceCount = 1,
unsigned int  firstIndex = 0,
unsigned int  baseVertex = 0 
)
pure virtual

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.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ EndRenderPass()

virtual void Video::CommandBuffer::EndRenderPass ( )
pure virtual

◆ PushConstants()

virtual void Video::CommandBuffer::PushConstants ( const void *  data)
pure virtual

Update push constants.

Parameters
dataThe data to push to the shader.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ SetLineWidth()

virtual void Video::CommandBuffer::SetLineWidth ( float  width)
pure virtual

Set width of lines.

Parameters
widthThe line width.

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ SetScissor()

virtual void Video::CommandBuffer::SetScissor ( const glm::uvec2 &  origin,
const glm::uvec2 &  size 
)
pure virtual

Set the scissor box.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ SetViewport()

virtual void Video::CommandBuffer::SetViewport ( const glm::uvec2 &  origin,
const glm::uvec2 &  size 
)
pure virtual

Set the viewport to render to.

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

Implemented in Video::OpenGLCommandBuffer, Video::VulkanCommandBuffer, and Video::WebGPUCommandBuffer.

◆ SetViewportAndScissor()

void Video::CommandBuffer::SetViewportAndScissor ( const glm::uvec2 &  origin,
const glm::uvec2 &  size 
)
inline

Set both viewport and scissor.

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

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