To allocate command buffers, call:
VkResult vkAllocateCommandBuffers( VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers);
device
is the logical device that owns the command pool.
pAllocateInfo
is a pointer to an instance of the
VkCommandBufferAllocateInfo
structure describing parameters of the
allocation.
pCommandBuffers
is a pointer to an array of VkCommandBuffer
handles in which the resulting command buffer objects are returned.
The array must be at least the length specified by the
commandBufferCount
member of pAllocateInfo
.
Each allocated command buffer begins in the initial state.
The VkCommandBufferAllocateInfo
structure is defined as:
typedef struct VkCommandBufferAllocateInfo { VkStructureType sType; const void* pNext; VkCommandPool commandPool; VkCommandBufferLevel level; uint32_t commandBufferCount; } VkCommandBufferAllocateInfo;
sType
is the type of this structure.
pNext
is NULL
or a pointer to an extension-specific structure.
commandPool
is the name of the command pool that the command
buffers allocate their memory from.
level
determines whether the command buffers are primary or
secondary command buffers.
Possible values include:
typedef enum VkCommandBufferLevel { VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0, VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1, } VkCommandBufferLevel;
commandBufferCount
is the number of command buffers to allocate
from the pool.
To reset command buffers, call:
VkResult vkResetCommandBuffer( VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags);
commandBuffer
is the command buffer to reset.
The command buffer can be in any state, and is put in the initial
state.
flags
is a bitmask controlling the reset operation.
Bits which can be set include:
typedef enum VkCommandBufferResetFlagBits { VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, } VkCommandBufferResetFlagBits;
If flags
includes VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT
,
then most or all memory resources currently owned by the command buffer
should be returned to the parent command pool.
If this flag is not set, then the command buffer may hold onto memory
resources and reuse them when recording commands.
To free command buffers, call:
void vkFreeCommandBuffers( VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers);
device
is the logical device that owns the command pool.
commandPool
is the handle of the command pool that the command
buffers were allocated from.
commandBufferCount
is the length of the pCommandBuffers
array.
pCommandBuffers
is an array of handles of command buffers to free.