Allocate command buffers from pools
This commit is contained in:
@@ -8,23 +8,45 @@
|
||||
#define NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Renderer/CommandPool.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLCommandBuffer.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;
|
||||
|
||||
std::unique_ptr<CommandBuffer> BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) override;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user