Program Listing for File command_pool.hpp

Return to documentation for file (inexor/vulkan-renderer/wrapper/command_pool.hpp)

#pragma once

#include <spdlog/spdlog.h>
#include <volk.h>

#include "inexor/vulkan-renderer/wrapper/command_buffer.hpp"

#include <cassert>

namespace inexor::vulkan_renderer::wrapper {

// Forward declaration
class Device;

class CommandPool {
    std::string m_name;
    const Device &m_device;
    VkCommandPool m_cmd_pool{VK_NULL_HANDLE};

    std::vector<std::unique_ptr<CommandBuffer>> m_cmd_bufs;

public:
    CommandPool(const Device &device, std::string name);

    CommandPool(const CommandPool &) = delete;
    CommandPool(CommandPool &&) noexcept;

    ~CommandPool();

    CommandPool &operator=(const CommandPool &) = delete;
    CommandPool &operator=(CommandPool &&) = delete;

    [[nodiscard]] VkCommandPool get() const {
        return m_cmd_pool;
    }

    [[nodiscard]] const VkCommandPool *ptr() const {
        return &m_cmd_pool;
    }

    [[nodiscard]] const CommandBuffer &request_command_buffer(const std::string &name);
};

} // namespace inexor::vulkan_renderer::wrapper