Vulkan: Refactor command buffer and introduce command pool
This commit is contained in:
37
include/Nazara/Renderer/CommandPool.hpp
Normal file
37
include/Nazara/Renderer/CommandPool.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_COMMANDPOOL_HPP
|
||||
#define NAZARA_COMMANDPOOL_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <functional>
|
||||
#include <memory> //< temporary
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CommandBuffer;
|
||||
class CommandBufferBuilder;
|
||||
|
||||
class NAZARA_RENDERER_API CommandPool
|
||||
{
|
||||
public:
|
||||
CommandPool() = default;
|
||||
CommandPool(const CommandPool&) = delete;
|
||||
CommandPool(CommandPool&&) = default;
|
||||
virtual ~CommandPool();
|
||||
|
||||
virtual std::unique_ptr<CommandBuffer> BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) = 0;
|
||||
|
||||
CommandPool& operator=(const CommandPool&) = delete;
|
||||
CommandPool& operator=(CommandPool&&) = default;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/CommandPool.inl>
|
||||
|
||||
#endif // NAZARA_COMMANDPOOL_HPP
|
||||
12
include/Nazara/Renderer/CommandPool.inl
Normal file
12
include/Nazara/Renderer/CommandPool.inl
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/CommandPool.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -69,6 +69,23 @@ namespace Nz
|
||||
using ShaderStageTypeFlags = Flags<ShaderStageType>;
|
||||
|
||||
constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex;
|
||||
|
||||
enum class QueueType
|
||||
{
|
||||
Compute,
|
||||
Graphics,
|
||||
Transfer,
|
||||
|
||||
Max = Transfer
|
||||
};
|
||||
|
||||
template<>
|
||||
struct EnumAsFlags<QueueType>
|
||||
{
|
||||
static constexpr QueueType max = QueueType::Max;
|
||||
};
|
||||
|
||||
using QueueTypeFlags = Flags<QueueType>;
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_RENDERER_HPP
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CommandPool;
|
||||
class ShaderStageImpl;
|
||||
|
||||
class NAZARA_RENDERER_API RenderDevice
|
||||
@@ -29,6 +30,7 @@ namespace Nz
|
||||
virtual ~RenderDevice();
|
||||
|
||||
virtual std::unique_ptr<AbstractBuffer> InstantiateBuffer(BufferType type) = 0;
|
||||
virtual std::unique_ptr<CommandPool> InstantiateCommandPool(QueueType queueType) = 0;
|
||||
virtual std::unique_ptr<RenderPipeline> InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0;
|
||||
virtual std::shared_ptr<RenderPipelineLayout> InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) = 0;
|
||||
virtual std::shared_ptr<ShaderStageImpl> InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace Nz
|
||||
@@ -23,11 +24,11 @@ namespace Nz
|
||||
RenderImage() = default;
|
||||
virtual ~RenderImage();
|
||||
|
||||
virtual void Execute(const std::function<void(CommandBufferBuilder& builder)>& callback, bool isGraphical) = 0;
|
||||
virtual void Execute(const std::function<void(CommandBufferBuilder& builder)>& callback, QueueTypeFlags queueTypeFlags) = 0;
|
||||
|
||||
virtual UploadPool& GetUploadPool() = 0;
|
||||
|
||||
virtual void SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) = 0;
|
||||
virtual void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) = 0;
|
||||
|
||||
virtual void Present() = 0;
|
||||
|
||||
|
||||
@@ -13,12 +13,10 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderDevice.hpp>
|
||||
#include <Nazara/Renderer/RenderWindowParameters.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CommandBuffer;
|
||||
class CommandBufferBuilder;
|
||||
class CommandPool;
|
||||
class RendererImpl;
|
||||
class RenderImage;
|
||||
class RenderSurface;
|
||||
@@ -31,9 +29,8 @@ namespace Nz
|
||||
|
||||
virtual RenderImage& Acquire() = 0;
|
||||
|
||||
virtual std::unique_ptr<CommandBuffer> BuildCommandBuffer(const std::function<void(CommandBufferBuilder& builder)>& callback) = 0;
|
||||
|
||||
virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0;
|
||||
virtual std::unique_ptr<CommandPool> CreateCommandPool(QueueType queueType) = 0;
|
||||
|
||||
virtual std::shared_ptr<RenderDevice> GetRenderDevice() = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user