#include <Vk/CommandPool/CommandPool.hpp>
#include <Utilities/Utilities.hpp>

Vk::CommandPool::CommandPool(
    std::shared_ptr<Vk::Device> device,
    VkCommandPoolCreateFlags flags,
    uint32_t queueFamilyIndex
) : m_device(device)
{
    VkCommandPoolCreateInfo poolInfo{};
    poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
    poolInfo.flags = flags;
    poolInfo.queueFamilyIndex = queueFamilyIndex;

    if (vkCreateCommandPool(device->inner(), &poolInfo, nullptr, &m_commandPool) != VK_SUCCESS)
    {
        crash("Failed to create command pool!");
    }
}

Vk::CommandPool::~CommandPool()
{
    vkDestroyCommandPool(m_device->inner(), m_commandPool, nullptr);
}

VkCommandPool Vk::CommandPool::inner()
{
    return m_commandPool;
}