VV::V3::CommandPool class

Command pools are opaque objects that command buffer memory is allocated from, and which allow the implementation to amortize the cost of resource creation across multiple command buffers.

Command pools are externally synchronized, meaning that a command pool must not be used concurrently in multiple threads. That includes use via recording commands on any command buffers allocated from the pool, as well as operations that allocate, free, and reset command buffers or the pool itself.

This object represents a device created object on the host. As such ownership is tied to this host object. Due to this design, the object has no copy-construction allowed. Instead, default move constructor and assignment has been defined.

Base classes

struct VV::V2::CommandPool
Command pools are opaque objects that command buffer memory is allocated from, and which allow the implementation to amortize the cost of resource creation across multiple command buffers.

Public types

using Parent = V2::CommandPool

Constructors, destructors, conversion operators

CommandPool()
Default constructor.
CommandPool(const LogicalDevice& _device)
Default constructor, logical device defined.
CommandPool(const LogicalDevice& _device, const Memory::AllocationCallbacks& _allocator)
Default constructor, logical device and allocator defined.
CommandPool(CommandPool&& _poolToMove) noexcept
Performs a move operation to transfer ownership of the device object to this host object.
~CommandPool()
Call the destroy for the device object if the host object's handle is not null.
operator Handle&()
Implicit conversion to give a reference to its handle.
operator const Handle&() const
Implicit conversion to give a readonly reference to its handle.
operator const Handle*() const
Implicit conversion to give a pointer to its handle.

Public functions

auto Allocate(CommandBuffer& _buffer) -> EResult
Allocate a command buffer.
auto Allocate(AllocateInfo& _info, CommandBuffer& _buffer) -> EResult
Allocate a command buffer with the specified allocation info.
auto Allocate(AllocateInfo& _info, CommandBuffer::Handle* _buffers) -> EResult
Allocate command buffers based on the allocate info.
auto Allocate(ECommandBufferLevel _level, ui32 _count, CommandBuffer::Handle* _buffers) -> EResult
Allocate command buffers with the specified count and level.
auto Allocate(ECommandBufferLevel _level, ui32 _count, DynamicArray<CommandBuffer>& _commandBuffers) -> EResult
Allocate command buffers and their handles into dynamic arrays. based on the count provided and the level desired.
auto Allocate(ECommandBufferLevel _level, ui32 _count, DynamicArray<CommandBuffer>& _commandBuffers, DynamicArray<CommandBuffer::Handle>& _handles) -> EResult
Allocate command buffers and their handles into dynamic arrays. based on the count provided and the level desired.
auto Create(const CreateInfo& _info) -> EResult
Create a command pool.
auto Create(const LogicalDevice& _device, const CreateInfo& _info) -> EResult
Create a command pool (device specified).
auto Create(const LogicalDevice& _device, CreateInfo& _info, const Memory::AllocationCallbacks& _allocator) -> EResult
Create a command pool (device and allocator specified).
void Destroy()
Destroy a command pool.
void Free(ui32 _bufferCount, const CommandBuffer::Handle* _commandBuffers)
Free the command buffers based on the count and handle container provided.
void Free(const AllocateInfo& _info, const CommandBuffer::Handle* _commandBuffers)
Free the command buffers based on the allocate info and handle container provided.
void Free(CommandBuffer& _commandBuffer)
Free a command buffer.
auto Reset(ResetFlags _flags) -> EResult
Resetting a command pool recycles all of the resources from all of the command buffers allocated from the command pool back to the command pool. All command buffers that have been allocated from the command pool are put in the initial state.
void Trim(TrimFlags _flags)
Trimming a command pool recycles unused memory from the command pool back to the system. Command buffers allocated from the pool are not affected by the command.
auto BeginSingleTimeCommands(EResult& _result) -> CommandBuffer
Will auto-allocate a command buffer on the specified pool and begin recording commands on the buffer.
auto EndSingleTimeCommands(CommandBuffer& _commandBuffer, const LogicalDevice::Queue& _queue) -> EResult
Will end the recording and submit the command buffer created with the BeginSingleTimeCommands function.
auto CopyBuffer(Buffer& _sourceBuffer, Buffer& _destinationBuffer, Buffer::CopyInfo& _regionInfo, const LogicalDevice::Queue& _queue) -> EResult
Uses a single time command buffer to copy a buffer with the provided queue and copy info.
auto operator==(const CommandPool& _other) const -> bool
Checks to see if its the same object by checking to see if its the same handle.
auto operator=(CommandPool&& _other) -> CommandPool& noexcept
Performs a move assignment operation to transfer ownership of the device object to this host object.

Protected variables

Handle handle
const Memory::AllocationCallbacks* allocator
const LogicalDevice* device

Function documentation

CommandBuffer VV::V3::CommandPool::BeginSingleTimeCommands(EResult& _result)

Will auto-allocate a command buffer on the specified pool and begin recording commands on the buffer.

The handle to the command buffer will be returned.

Expected to be used with the EndSingleTimeCommands function (defined below it).

EResult VV::V3::CommandPool::EndSingleTimeCommands(CommandBuffer& _commandBuffer, const LogicalDevice::Queue& _queue)

Will end the recording and submit the command buffer created with the BeginSingleTimeCommands function.

Will wait until the queue is idle that the commands were submitted to. Will also free the command buffer after completion.

Expected to be used with the BeginSingleTimeCommands function (defined above it).