Vulkan: Add renderpass and framebuffers

This commit is contained in:
Lynix
2020-04-10 17:36:05 +02:00
parent 9507c56fc9
commit d9a08640d6
41 changed files with 659 additions and 95 deletions

View File

@@ -17,20 +17,27 @@
namespace Nz
{
class Framebuffer;
class RenderPass;
class RenderPipeline;
class ShaderBinding;
class NAZARA_RENDERER_API CommandBufferBuilder
{
public:
struct ClearValues;
CommandBufferBuilder() = default;
CommandBufferBuilder(const CommandBufferBuilder&) = delete;
CommandBufferBuilder(CommandBufferBuilder&&) = default;
virtual ~CommandBufferBuilder();
virtual void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) = 0;
virtual void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list<ClearValues> clearValues) = 0;
virtual void BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset = 0) = 0;
virtual void BindShaderBinding(ShaderBinding& binding) = 0;
virtual void BindPipeline(const RenderPipeline& pipeline) = 0;
virtual void BindShaderBinding(const ShaderBinding& binding) = 0;
virtual void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) = 0;
inline void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target);
@@ -42,6 +49,7 @@ namespace Nz
virtual void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) = 0;
virtual void EndDebugRegion() = 0;
virtual void EndRenderPass() = 0;
virtual void PreTransferBarrier() = 0;
virtual void PostTransferBarrier() = 0;
@@ -51,6 +59,13 @@ namespace Nz
CommandBufferBuilder& operator=(const CommandBufferBuilder&) = delete;
CommandBufferBuilder& operator=(CommandBufferBuilder&&) = default;
struct ClearValues
{
Nz::Color color;
float depth;
UInt32 stencil;
};
};
}

View File

@@ -0,0 +1,30 @@
// 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_FRAMEBUFFER_HPP
#define NAZARA_FRAMEBUFFER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Config.hpp>
namespace Nz
{
class NAZARA_RENDERER_API Framebuffer
{
public:
Framebuffer() = default;
Framebuffer(const Framebuffer&) = delete;
Framebuffer(Framebuffer&&) noexcept = default;
virtual ~Framebuffer();
Framebuffer& operator=(const Framebuffer&) = delete;
Framebuffer& operator=(Framebuffer&&) noexcept = default;
};
}
#include <Nazara/Renderer/Framebuffer.inl>
#endif // NAZARA_FRAMEBUFFER_HPP

View 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/Framebuffer.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -0,0 +1,40 @@
// 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_RENDERPASS_HPP
#define NAZARA_RENDERPASS_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
namespace Nz
{
class NAZARA_RENDERER_API RenderPass
{
public:
struct Attachment;
RenderPass() = default;
RenderPass(const RenderPass&) = delete;
RenderPass(RenderPass&&) noexcept = default;
virtual ~RenderPass();
RenderPass& operator=(const RenderPass&) = delete;
RenderPass& operator=(RenderPass&&) noexcept = default;
struct Attachment
{
PixelFormat format;
// TODO
};
};
}
#include <Nazara/Renderer/RenderPass.inl>
#endif // NAZARA_RENDERPASS_HPP

View 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/RenderPass.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -17,8 +17,10 @@
namespace Nz
{
class CommandPool;
class Framebuffer;
class RendererImpl;
class RenderImage;
class RenderPass;
class RenderSurface;
class NAZARA_RENDERER_API RenderWindowImpl
@@ -32,7 +34,9 @@ namespace Nz
virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0;
virtual std::unique_ptr<CommandPool> CreateCommandPool(QueueType queueType) = 0;
virtual const Framebuffer& GetFramebuffer() const = 0;
virtual std::shared_ptr<RenderDevice> GetRenderDevice() = 0;
virtual const RenderPass& GetRenderPass() const = 0;
};
}