Class CommandBuffer#
Defined in File CommandBuffer.h
Inheritance Relationships#
Derived Type#
public TRAP::Graphics::API::VulkanCommandBuffer
(Class VulkanCommandBuffer)
Class Documentation#
-
class CommandBuffer#
Subclassed by TRAP::Graphics::API::VulkanCommandBuffer
Public Functions
-
virtual ~CommandBuffer()#
Destructor.
-
consteval CommandBuffer(const CommandBuffer&) noexcept = delete#
Copy constructor.
-
consteval CommandBuffer &operator=(const CommandBuffer&) noexcept = delete#
Copy assignment operator.
-
CommandBuffer(CommandBuffer&&) noexcept = default#
Move constructor.
-
CommandBuffer &operator=(CommandBuffer&&) noexcept = default#
Move assignment operator.
-
TRAP::Ref<Queue> GetQueue() const noexcept#
Retrieve the queue used by the command buffer.
- Returns:
Queue used by the command buffer.
-
virtual void BindPushConstants(const RootSignature &rootSignature, std::string_view name, std::span<const u8> constants) const = 0#
Bind push constant buffer data to the command buffer.
Note
There is an optimized function which uses the index into the RootSignature instead of the name of the push constant block.
- Parameters:
rootSignature – Root signature containing the push constant block.
name – Name of the push constant block.
constants – Constant buffer data.
-
virtual void BindPushConstantsByIndex(const RootSignature &rootSignature, u32 paramIndex, std::span<const u8> constants) const = 0#
Bind push constant buffer data to the command buffer.
- Parameters:
rootSignature – Root signature containing the push constant block.
paramIndex – Index of the push constant block in the RootSignatures descriptors array.
constants – Constant buffer data.
-
virtual void BindDescriptorSet(u32 index, DescriptorSet &descriptorSet) = 0#
Bind a descriptor set to the command buffer.
- Parameters:
index – Index for which descriptor set to bind.
descriptorSet – Descriptor set to bind.
-
virtual void BindIndexBuffer(const Buffer &buffer, RendererAPI::IndexType indexType, u64 offset) const = 0#
Bind an index buffer to the command buffer.
- Parameters:
buffer – Index buffer to bind.
indexType – Data type used by the index buffer.
offset – Starting offset in bytes to use for index buffer.
-
virtual void BindVertexBuffer(const std::vector<std::reference_wrapper<const Buffer>> &buffers, const std::vector<u32> &strides, const std::vector<u64> &offsets) const = 0#
Bind vertex buffer(s) to the command buffer.
- Parameters:
buffers – Vertex buffer(s) to bind.
strides – Stride in bytes of each vertex buffer.
offsets – Starting offsets in bytes to use for each vertex buffer.
-
virtual void BindPipeline(const Pipeline &pipeline) const = 0#
Bind a pipeline to the command buffer.
- Parameters:
pipeline – Pipeline to bind.
-
virtual void BindRenderTargets(const std::vector<std::reference_wrapper<const RenderTarget>> &renderTargets, const RenderTarget *depthStencil, RendererAPI::LoadActionsDesc *loadActions, const std::vector<u32> *colorArraySlices, const std::vector<u32> *colorMipSlices, u32 depthArraySlice, u32 depthMipSlice, const RenderTarget *shadingRate = nullptr) = 0#
Bind render target(s) to the command buffer.
Note
This functions ends the currently running render pass and starts a new one.
- Parameters:
renderTargets – Render target(s) to bind.
depthStencil – Optional depth stencil target to bind.
loadActions – Optional load actions for each render target.
colorArraySlices – Optional color array slices for each render target.
colorMipSlices – Optional color mip slices for each render target.
depthArraySlice – Optional depth array slice for the depth stencil target.
depthMipSlice – Optional depth mip slice for the depth stencil target.
shadingRate – Optional shading rate texture to use.
-
virtual void AddDebugMarker(const TRAP::Math::Vec3 &color, std::string_view name) const = 0#
Add a debug marker to the command buffer.
- Parameters:
color – Color for the debug marker.
name – Name of the marker.
-
virtual void BeginDebugMarker(const TRAP::Math::Vec3 &color, std::string_view name) const = 0#
Start a debug marker region.
- Parameters:
color – Color for the debug marker.
name – Name of the marker.
-
virtual void EndDebugMarker() const = 0#
End the currently running debug marker region.
-
virtual void Begin(bool oneTimeSubmit = false) = 0#
Begin command buffer recording.
- Parameters:
oneTimeSubmit – Whether each recording should only be submitted once. If true then the command buffer will be reset after submission to initial state.
-
virtual void End() = 0#
End command buffer recording.
Note
This function also ends the currently running render pass.
-
virtual void SetViewport(f32 x, f32 y, f32 width, f32 height, f32 minDepth, f32 maxDepth) const = 0#
Set a new viewport region.
- Parameters:
x – X position for the upper left corner of the viewport.
y – Y position for the upper left corner of the viewport.
width – New viewport width.
height – New viewport height.
minDepth – Min depth value.
maxDepth – Max depth value.
-
virtual void SetScissor(u32 x, u32 y, u32 width, u32 height) const = 0#
Set a new scissor region.
- Parameters:
x – X offset for the scissor region.
y – Y offset for the scissor region.
width – Width for the scissor region.
height – Height for the scissor region.
-
virtual void Draw(u32 vertexCount, u32 firstVertex) const = 0#
Draw a number of primitives.
- Parameters:
vertexCount – How many vertices to draw.
firstVertex – Offset to the first vertex to draw.
-
virtual void DrawInstanced(u32 vertexCount, u32 firstVertex, u32 instanceCount, u32 firstInstance) const = 0#
Draw multiple instances of primitives.
- Parameters:
vertexCount – How many vertices to draw.
firstVertex – Offset to the first vertex to draw.
instanceCount – How many instances to draw.
firstInstance – Offset to the first instance to draw.
-
virtual void DrawIndexed(u32 indexCount, u32 firstIndex, i32 firstVertex) const = 0#
Draw indexed primitives.
- Parameters:
indexCount – How many indices to draw.
firstIndex – Offset to the first index to draw.
firstVertex – Offset to the first vertex to draw.
-
virtual void DrawIndexedInstanced(u32 indexCount, u32 firstIndex, u32 instanceCount, u32 firstInstance, i32 firstVertex) const = 0#
Draw multiple instances of indexed primitives.
- Parameters:
indexCount – How many indices to draw.
firstIndex – Offset to the first index to draw.
instanceCount – How many instances to draw.
firstInstance – Offset to the first instance to draw.
firstVertex – Offset to the first vertex to draw.
-
virtual void ExecuteIndirect(const CommandSignature &cmdSignature, u32 maxCommandCount, const Buffer &indirectBuffer, u64 bufferOffset, const Buffer *counterBuffer, u64 counterBufferOffset) const = 0#
Draw primitives. Draw data is provided by the indirect buffer. Command signature provides information about which type of drawing to perform (Non-instanced & non-indexed, indexed, instances, indexed & instanced or dispatch).
- Parameters:
cmdSignature – Command signature containing extra data.
maxCommandCount – Max number of draws to execute.
indirectBuffer – Buffer containing draw parameters.
bufferOffset – Byte offset into indirect buffer to start reading from.
counterBuffer – Buffer containing the draw count.
counterBufferOffset – Byte offset into counter buffer to start reading from.
-
virtual void Dispatch(u32 groupCountX, u32 groupCountY, u32 groupCountZ) const = 0#
Dispatch compute work.
- Parameters:
groupCountX – Number of local work groups to dispatch in the X dimension.
groupCountY – Number of local work groups to dispatch in the Y dimension.
groupCountZ – Number of local work groups to dispatch in the Z dimension.
-
virtual void UpdateBuffer(const Buffer &buffer, u64 dstOffset, const Buffer &srcBuffer, u64 srcOffset, u64 size) const = 0#
Update a buffer with new data.
- Parameters:
buffer – Buffer to update.
dstOffset – Offset in the buffer to start writing to.
srcBuffer – Source buffer to read data from.
srcOffset – Offset in the source buffer to start reading from.
size – Size of the data to copy.
-
virtual void UpdateSubresource(const Texture &texture, const Buffer &srcBuffer, const RendererAPI::SubresourceDataDesc &subresourceDesc) const = 0#
Update a texture partially with new data.
- Parameters:
texture – Texture to update.
srcBuffer – Source buffer to read data from.
subresourceDesc – Subresource description.
-
virtual void CopySubresource(const Buffer &dstBuffer, const Texture &texture, const RendererAPI::SubresourceDataDesc &subresourceDesc) const = 0#
Copy a texture partially into a buffer.
- Parameters:
dstBuffer – Destination to copy data into.
texture – Source texture to copy from.
subresourceDesc – Subresource description.
-
virtual void ResetQueryPool(const QueryPool &queryPool, u32 startQuery, u32 queryCount) const = 0#
Reset a query pool.
- Parameters:
queryPool – Query pool to reset.
startQuery – Initial query index to reset.
queryCount – Number of queries to reset.
-
virtual void BeginQuery(const QueryPool &queryPool, const RendererAPI::QueryDesc &desc) const = 0#
Begin a new query.
- Parameters:
queryPool – Query pool to begin a new query in.
desc – Query desc.
-
virtual void EndQuery(const QueryPool &queryPool, const RendererAPI::QueryDesc &desc) const = 0#
End a query.
- Parameters:
queryPool – Query pool to begin a new query in.
desc – Query desc.
-
virtual void ResolveQuery(const QueryPool &queryPool, const Buffer &readBackBuffer, u32 startQuery, u32 queryCount) const = 0#
Retrieve the results of a query.
- Parameters:
queryPool – Query pool containing the query results.
readBackBuffer – Buffer to write results to.
startQuery – Initial query index.
queryCount – Number of queries to read.
-
virtual void ResourceBarrier(const std::vector<RendererAPI::BufferBarrier> *bufferBarriers, const std::vector<RendererAPI::TextureBarrier> *textureBarriers, const std::vector<RendererAPI::RenderTargetBarrier> *renderTargetBarriers) const = 0#
Add resource barriers (memory dependency) to the command buffer.
-
virtual void ResourceBarrier(const RendererAPI::BufferBarrier *bufferBarrier, const RendererAPI::TextureBarrier *textureBarrier, const RendererAPI::RenderTargetBarrier *renderTargetBarrier) const = 0#
Add a resource barrier (memory dependency) to the command buffer.
-
virtual void SetStencilReferenceValue(u32 val) const = 0#
Set the stencil reference value for the command buffer.
- Parameters:
val – New value to use as stencil reference.
-
virtual void SetShadingRate(RendererAPI::ShadingRate shadingRate, RendererAPI::ShadingRateCombiner postRasterizerRate, RendererAPI::ShadingRateCombiner finalRate) const = 0#
Set the pipeline fragment shading rate and combiner operation for the command buffer.
- Parameters:
shadingRate – Shading rate to use.
postRasterizerRate – Shading rate combiner to use.
finalRate – Shading rate combiner to use.
-
virtual void Clear(const RendererAPI::Color &color, u32 width, u32 height, u32 colorAttachment = 0) const = 0#
Clear the currently used color attachment.
- Parameters:
color – Color to clear the color attachment with.
width – Width of the area to clear.
height – Height of the area to clear.
colorAttachment – Index a bound color attachment which should be cleared by the given color.
-
virtual void Clear(f32 depth, u32 stencil, u32 width, u32 height) const = 0#
Clear the currently used depth and stencil attachment.
- Parameters:
depth – Depth value to clear the depth attachment with.
stencil – Stencil value to clear the stencil attachment with.
width – Width of the area to clear.
height – Height of the area to clear.
-
virtual ~CommandBuffer()#