Allocate command buffers from pools

This commit is contained in:
Jérôme Leclercq
2020-08-27 18:31:26 +02:00
parent cbdac32f5f
commit 7c9dcdfbe4
18 changed files with 333 additions and 23 deletions

View File

@@ -9,19 +9,36 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <memory>
namespace Nz
{
class CommandBuffer;
class CommandBufferDeleter;
using CommandBufferPtr = std::unique_ptr<CommandBuffer, CommandBufferDeleter>;
class NAZARA_RENDERER_API CommandBuffer
{
friend CommandBufferDeleter;
public:
CommandBuffer() = default;
CommandBuffer(const CommandBuffer&) = delete;
CommandBuffer(CommandBuffer&&) = default;
CommandBuffer(CommandBuffer&&) = delete;
virtual ~CommandBuffer();
CommandBuffer& operator=(const CommandBuffer&) = delete;
CommandBuffer& operator=(CommandBuffer&&) = default;
CommandBuffer& operator=(CommandBuffer&&) = delete;
protected:
virtual void Release() = 0;
};
class CommandBufferDeleter
{
public:
inline void operator()(CommandBuffer* commandBuffer);
};
}

View File

@@ -7,6 +7,10 @@
namespace Nz
{
inline void CommandBufferDeleter::operator()(CommandBuffer* commandBuffer)
{
commandBuffer->Release();
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -9,12 +9,11 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/CommandBuffer.hpp>
#include <functional>
#include <memory> //< temporary
namespace Nz
{
class CommandBuffer;
class CommandBufferBuilder;
class NAZARA_RENDERER_API CommandPool
@@ -25,7 +24,7 @@ namespace Nz
CommandPool(CommandPool&&) = default;
virtual ~CommandPool();
virtual std::unique_ptr<CommandBuffer> BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) = 0;
virtual CommandBufferPtr BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) = 0;
CommandPool& operator=(const CommandPool&) = delete;
CommandPool& operator=(CommandPool&&) = default;

View File

@@ -30,10 +30,15 @@ namespace Nz
struct Binding;
ShaderBinding() = default;
ShaderBinding(const ShaderBinding&) = delete;
ShaderBinding(ShaderBinding&&) = delete;
virtual ~ShaderBinding();
virtual void Update(std::initializer_list<Binding> bindings) = 0;
ShaderBinding& operator=(const ShaderBinding&) = delete;
ShaderBinding& operator=(ShaderBinding&&) = delete;
struct TextureBinding
{
Texture* texture;
@@ -55,9 +60,6 @@ namespace Nz
protected:
virtual void Release() = 0;
ShaderBinding(const ShaderBinding&) = delete;
ShaderBinding(ShaderBinding&&) = default;
};
class ShaderBindingDeleter