Class VulkanCommandBuffer#
Defined in File VulkanCommandBuffer.h
Inheritance Relationships#
Base Type#
public TRAP::Graphics::CommandBuffer
(Class CommandBuffer)
Class Documentation#
-
class VulkanCommandBuffer : public TRAP::Graphics::CommandBuffer#
Public Functions
-
VulkanCommandBuffer(TRAP::Ref<VulkanDevice> device, TRAP::Ref<Queue> queue, VkCommandPool commandPool, bool secondary, std::string_view name = "")#
Constructor.
-
~VulkanCommandBuffer() override#
Destructor.
-
consteval VulkanCommandBuffer(const VulkanCommandBuffer&) noexcept = delete#
Copy constructor.
-
consteval VulkanCommandBuffer &operator=(const VulkanCommandBuffer&) noexcept = delete#
Copy assignment operator.
-
VulkanCommandBuffer(VulkanCommandBuffer&&) noexcept = default#
Move constructor.
-
constexpr VulkanCommandBuffer &operator=(VulkanCommandBuffer&&) noexcept = delete#
Move assignment operator.
-
constexpr VkCommandBuffer GetVkCommandBuffer() const noexcept#
Retrieve the VkCommandBuffer handle.
- Returns:
VkCommandBuffer handle.
-
RendererAPI::QueueType GetQueueType() const#
Retrieve the queue type used for resource barriers.
- Returns:
Queue type used for resource barriers.
-
constexpr bool IsSecondary() const noexcept#
Retrieve whether this is a secondary command buffer.
- Returns:
True of this is a secondary command buffer, false otherwise.
-
virtual void BindPushConstants(const RootSignature &rootSignature, std::string_view name, std::span<const u8> constants) const override#
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 override#
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) override#
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 override#
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 override#
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 override#
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) override#
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.
-
virtual void AddDebugMarker(const TRAP::Math::Vec3 &color, std::string_view name) const override#
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 override#
Start a debug marker region.
- Parameters:
color – Color for the debug marker.
name – Name of the marker.
-
virtual void EndDebugMarker() const override#
End the currently running debug marker region.
-
virtual void Begin(bool oneTimeSubmit = false) override#
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() override#
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 override#
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 override#
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 override#
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 override#
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 vertexOffset) const override#
Draw indexed primitives.
- Parameters:
indexCount – How many indices to draw.
firstIndex – Offset to the first index to draw.
vertexOffset – Offset to the first vertex to draw.
-
virtual void DrawIndexedInstanced(u32 indexCount, u32 firstIndex, u32 instanceCount, u32 firstInstance, i32 vertexOffset) const override#
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.
vertexOffset – 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 override#
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 override#
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 override#
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 TRAP::Graphics::Texture &texture, const Buffer &srcBuffer, const RendererAPI::SubresourceDataDesc &subresourceDesc) const override#
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 override#
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 override#
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 override#
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 override#
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 override#
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 override#
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 override#
Add a resource barrier (memory dependency) to the command buffer.
-
virtual void SetStencilReferenceValue(u32 val) const override#
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 override#
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 override#
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 override#
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 void Clear(f32 depth, u32 width, u32 height) const override#
Clear the currently used depth attachment.
- Parameters:
depth – Depth value to clear the depth attachment with.
width – Width of the area to clear.
height – Height of the area to clear.
-
virtual void Clear(u32 stencil, u32 width, u32 height) const override#
Clear the currently used stencil attachment.
- Parameters:
stencil – Stencil value to clear the stencil attachment with.
width – Width of the area to clear.
height – Height of the area to clear.
-
void ResolveImage(const API::VulkanTexture &srcImage, RendererAPI::ResourceState srcState, const API::VulkanTexture &dstImage, RendererAPI::ResourceState dstState) const#
Resolve a multisample color texture to a non-multisample color texture.
- Parameters:
srcImage – Source multisample color texture to resolve.
srcState – Source texture state.
dstImage – Destination non-multisample color texture to resolve into.
dstState – Destination texture state.
-
void BlitImage(const VulkanTexture &source, const VulkanTexture &destination, const VkImageBlit ®ion, RendererAPI::FilterType filter) const#
Blit an image from source to destination using the specified region and filtering options.
- Parameters:
source – Source texture to blit from.
destination – Destination texture to blit to.
region – Region to blit.
filter – Filter mode to use for the blit operation.
-
constexpr VkRenderPass GetActiveVkRenderPass() const noexcept#
Retrieve the currently active VkRenderPass.
- Returns:
Currently active VkRenderPass.
-
VulkanCommandBuffer(TRAP::Ref<VulkanDevice> device, TRAP::Ref<Queue> queue, VkCommandPool commandPool, bool secondary, std::string_view name = "")#