Files
NazaraEngine/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp
Jérôme Leclercq 03e2801dbe Split engine to packages NazaraUtils and NZSL (#375)
* Move code to NazaraUtils and NZSL packages

* Reorder includes

* Tests: Remove glslang and spirv-tools deps

* Tests: Remove glslang init

* Remove NazaraUtils tests and fix Vector4Test

* Fix Linux compilation

* Update msys2-build.yml

* Fix assimp package

* Update xmake.lua

* Update xmake.lua

* Fix shader compilation on MinGW

* Final fixes

* The final fix 2: the fix strikes back!

* Disable cache on CI

* The return of the fix™️
2022-05-25 19:36:10 +02:00

56 lines
1.7 KiB
C++

// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - OpenGL renderer"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP
#define NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/OpenGLRenderer/Config.hpp>
#include <Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp>
#include <Nazara/Renderer/CommandPool.hpp>
#include <Nazara/Utils/Bitset.hpp>
namespace Nz
{
class NAZARA_OPENGLRENDERER_API OpenGLCommandPool final : public CommandPool
{
friend OpenGLCommandBuffer;
public:
OpenGLCommandPool() = default;
OpenGLCommandPool(const OpenGLCommandPool&) = delete;
OpenGLCommandPool(OpenGLCommandPool&&) noexcept = default;
~OpenGLCommandPool() = default;
CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) override;
OpenGLCommandPool& operator=(const OpenGLCommandPool&) = delete;
OpenGLCommandPool& operator=(OpenGLCommandPool&&) = delete;
private:
struct CommandPool;
CommandPool& AllocatePool();
CommandBufferPtr AllocateFromPool(std::size_t poolIndex);
void Release(CommandBuffer& commandBuffer);
inline void TryToShrink();
struct CommandPool
{
using BindingStorage = std::aligned_storage_t<sizeof(OpenGLCommandBuffer), alignof(OpenGLCommandBuffer)>;
Bitset<UInt64> freeCommands;
std::unique_ptr<BindingStorage[]> storage;
};
std::vector<CommandPool> m_commandPools;
};
}
#include <Nazara/OpenGLRenderer/OpenGLCommandPool.inl>
#endif // NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP