Magnum::Vk::CommandPool class new in Git master

Command pool.

Wraps a VkCommandPool and handles allocation of CommandBuffers.

Command pool creation

A CommandPoolCreateInfo doesn't need many inputs — the only required is queue family index coming from DeviceProperties of the device it's created on:

#include <Magnum/Vk/CommandPoolCreateInfo.h>



Vk::Device device{};

Vk::CommandPool commandPool{device, Vk::CommandPoolCreateInfo{
    device.properties().pickQueueFamily(Vk::QueueFlag::Graphics)
}};

After that, you can allocate command buffers and use them. See CommandBuffer class docs for details.

Public static functions

static auto wrap(Device& device, VkCommandPool handle, HandleFlags flags = {}) -> CommandPool
Wrap existing Vulkan handle.

Constructors, destructors, conversion operators

CommandPool(Device& device, const CommandPoolCreateInfo& info) explicit
Constructor.
CommandPool(NoCreateT) explicit noexcept
Construct without creating the instance.
CommandPool(const CommandPool&) deleted
Copying is not allowed.
CommandPool(CommandPool&& other) noexcept
Move constructor.
~CommandPool()
Destructor.
operator VkCommandPool()

Public functions

auto operator=(const CommandPool&) -> CommandPool& deleted
Copying is not allowed.
auto operator=(CommandPool&& other) -> CommandPool& noexcept
Move assignment.
auto handle() -> VkCommandPool
Underlying VkCommandPool handle.
auto handleFlags() const -> HandleFlags
Handle flags.
auto allocate(CommandBufferLevel level = CommandBufferLevel::Primary) -> CommandBuffer
Allocate a single command buffer.
void reset(CommandPoolResetFlags flags = {})
Reset the command pool.
auto release() -> VkCommandPool
Release the underlying Vulkan command pool.

Function documentation

static CommandPool Magnum::Vk::CommandPool::wrap(Device& device, VkCommandPool handle, HandleFlags flags = {})

Wrap existing Vulkan handle.

Parameters
device Vulkan device the command pool is created on
handle The VkCommandPool handle
flags Handle flags

The handle is expected to be of an existing Vulkan command pool. Unlike a command pool created using a constructor, the Vulkan command pool is by default not deleted on destruction, use flags for different behavior.

Magnum::Vk::CommandPool::CommandPool(Device& device, const CommandPoolCreateInfo& info) explicit

Constructor.

Parameters
device Vulkan device to create the command pool on
info Command pool creation info

Magnum::Vk::CommandPool::CommandPool(NoCreateT) explicit noexcept

Construct without creating the instance.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

Magnum::Vk::CommandPool::~CommandPool()

Destructor.

Destroys associated VkCommandPool handle, unless the instance was created using wrap() without HandleFlag::DestroyOnDestruction specified.

Magnum::Vk::CommandPool::operator VkCommandPool()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

CommandBuffer Magnum::Vk::CommandPool::allocate(CommandBufferLevel level = CommandBufferLevel::Primary)

Allocate a single command buffer.

void Magnum::Vk::CommandPool::reset(CommandPoolResetFlags flags = {})

Reset the command pool.

All command buffers allocated from this command pool are reset as well. See CommandBuffer::reset() for a way to reset a single command buffer.

VkCommandPool Magnum::Vk::CommandPool::release()

Release the underlying Vulkan command pool.

Releases ownership of the Vulkan command pool and returns its handle so vkDestroyCommandPool() is not called on destruction. The internal state is then equivalent to moved-from state.