// Copyright 2022 Simon Boyé #include #include #include 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; } }