You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.2 KiB
67 lines
1.2 KiB
// Copyright 2022 Simon Boyé
|
|
|
|
#include <vk/CommandPool.h>
|
|
#include <vk/Context.h>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
namespace vk {
|
|
|
|
|
|
CommandPool::CommandPool() noexcept {
|
|
}
|
|
|
|
CommandPool::CommandPool(Context& context, uint32_t queue_family, VkCommandPoolCreateFlags flags)
|
|
: Wrapper(context)
|
|
{
|
|
assert(m_context);
|
|
|
|
VkCommandPoolCreateInfo create_info {
|
|
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
|
.flags = flags,
|
|
.queueFamilyIndex = queue_family,
|
|
};
|
|
if(vkCreateCommandPool(
|
|
context.device(),
|
|
&create_info,
|
|
nullptr,
|
|
&m_command_pool
|
|
) != VK_SUCCESS)
|
|
throw std::runtime_error("failed to create command pool");
|
|
}
|
|
|
|
CommandPool::CommandPool(CommandPool&& other) noexcept
|
|
{
|
|
swap(other);
|
|
}
|
|
|
|
CommandPool::~CommandPool() noexcept {
|
|
if(!is_null())
|
|
destroy();
|
|
}
|
|
|
|
|
|
CommandPool& CommandPool::operator=(CommandPool&& other) noexcept {
|
|
swap(other);
|
|
if(other)
|
|
other.destroy();
|
|
return *this;
|
|
}
|
|
|
|
|
|
void CommandPool::destroy() noexcept {
|
|
assert(!is_null());
|
|
assert(m_context);
|
|
|
|
vkDestroyCommandPool(
|
|
m_context->device(),
|
|
m_command_pool,
|
|
nullptr
|
|
);
|
|
|
|
m_command_pool = nullptr;
|
|
}
|
|
|
|
|
|
}
|
|
|