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

WebGPU implementation of CommandBuffer. More...

#include <WebGPUCommandBuffer.hpp>

Inheritance diagram for Video::WebGPUCommandBuffer:
Video::CommandBuffer

Public Member Functions

 WebGPUCommandBuffer (WebGPURenderer *renderer)
 Create new WebGPU command buffer. More...
 
 ~WebGPUCommandBuffer () 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...
 
WGPUCommandEncoder GetCommandEncoder ()
 Get command encoder. More...
 
WGPUCommandBuffer End ()
 Finish recording the command buffer. More...
 
void NextFrame ()
 Cycle the command buffer for the next frame. More...
 
WGPURenderPassEncoder GetRenderPassEncoder ()
 Get the current render pass encoder. 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

WebGPU implementation of CommandBuffer.

Constructor & Destructor Documentation

◆ WebGPUCommandBuffer()

Video::WebGPUCommandBuffer::WebGPUCommandBuffer ( WebGPURenderer renderer)
explicit

Create new WebGPU command buffer.

Parameters
rendererThe WebGPU renderer.

◆ ~WebGPUCommandBuffer()

Video::WebGPUCommandBuffer::~WebGPUCommandBuffer ( )
final

Destructor.

Member Function Documentation

◆ BeginAttachmentlessRenderPass()

void Video::WebGPUCommandBuffer::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::WebGPUCommandBuffer::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::WebGPUCommandBuffer::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::WebGPUCommandBuffer::BindComputePipeline ( ComputePipeline computePipeline)
finalvirtual

Bind compute pipeline.

Parameters
computePipelineThe compute pipeline to bind.

Implements Video::CommandBuffer.

◆ BindGeometry()

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

Bind geometry to be used in upcoming draw calls.

Parameters
geometryBindingThe geometry to bind.

Implements Video::CommandBuffer.

◆ BindGraphicsPipeline()

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

Bind graphics pipeline.

Parameters
graphicsPipelineThe graphics pipeline to bind.

Implements Video::CommandBuffer.

◆ BindMaterial()

void Video::WebGPUCommandBuffer::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::WebGPUCommandBuffer::BindStorageBuffers ( std::initializer_list< Buffer * >  buffers)
finalvirtual

Bind storage buffers.

Parameters
buffersThe buffers to bind.

Implements Video::CommandBuffer.

◆ BindUniformBuffer()

void Video::WebGPUCommandBuffer::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::WebGPUCommandBuffer::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::WebGPUCommandBuffer::ClearBuffer ( Buffer buffer)
finalvirtual

Clear a buffer (fill with 0).

Parameters
bufferThe buffer to clear.

Implements Video::CommandBuffer.

◆ Dispatch()

void Video::WebGPUCommandBuffer::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::WebGPUCommandBuffer::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::WebGPUCommandBuffer::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::WebGPUCommandBuffer::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()

WGPUCommandBuffer Video::WebGPUCommandBuffer::End ( )

Finish recording the command buffer.

Returns
The resuing WGPUCommandBuffer that can be submitted to a queue.

◆ EndRenderPass()

void Video::WebGPUCommandBuffer::EndRenderPass ( )
finalvirtual

End render pass.

Implements Video::CommandBuffer.

◆ GetCommandEncoder()

WGPUCommandEncoder Video::WebGPUCommandBuffer::GetCommandEncoder ( )

Get command encoder.

Returns
The internal WebGPU command encoder.

◆ GetRenderPassEncoder()

WGPURenderPassEncoder Video::WebGPUCommandBuffer::GetRenderPassEncoder ( )

Get the current render pass encoder.

Returns
The current render pass encoder.

◆ NextFrame()

void Video::WebGPUCommandBuffer::NextFrame ( )

Cycle the command buffer for the next frame.

◆ PushConstants()

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

Update push constants.

Parameters
dataThe data to push to the shader.

Implements Video::CommandBuffer.

◆ SetLineWidth()

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

Set width of lines.

Parameters
widthThe line width.

Implements Video::CommandBuffer.

◆ SetScissor()

void Video::WebGPUCommandBuffer::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.
Todo:
Remove once wgpu has added support for zero-area scissors. https://github.com/gfx-rs/wgpu/issues/1750

Implements Video::CommandBuffer.

◆ SetViewport()

void Video::WebGPUCommandBuffer::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: