// Copyright (C) 2021 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Vulkan renderer" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP #define NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP #include #include #include #include #include #include #include namespace Nz { class NAZARA_VULKANRENDERER_API VulkanCommandPool final : public CommandPool { friend VulkanCommandBuffer; public: inline VulkanCommandPool(Vk::Device& device, QueueType queueType); inline VulkanCommandPool(Vk::Device& device, UInt32 queueFamilyIndex); VulkanCommandPool(const VulkanCommandPool&) = delete; VulkanCommandPool(VulkanCommandPool&&) noexcept = default; ~VulkanCommandPool() = default; CommandBufferPtr BuildCommandBuffer(const std::function& callback) override; VulkanCommandPool& operator=(const VulkanCommandPool&) = delete; VulkanCommandPool& operator=(VulkanCommandPool&&) = delete; private: struct CommandPool; CommandPool& AllocatePool(); template CommandBufferPtr AllocateFromPool(std::size_t poolIndex, Args&&... args); void Release(CommandBuffer& commandBuffer); inline void TryToShrink(); struct CommandPool { using BindingStorage = std::aligned_storage_t; Bitset freeCommands; std::unique_ptr storage; }; MovablePtr m_device; std::vector m_commandPools; Vk::CommandPool m_commandPool; }; } #include #endif // NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP