Renderer/RenderPass: Implement RenderPass correctly

This commit is contained in:
Jérôme Leclercq
2021-02-15 18:14:47 +01:00
parent 3d84479d0e
commit d058a127e1
11 changed files with 543 additions and 133 deletions

View File

@@ -11,6 +11,9 @@
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
#include <limits>
#include <optional>
#include <vector>
namespace Nz
{
@@ -18,20 +21,64 @@ namespace Nz
{
public:
struct Attachment;
struct SubpassDependency;
struct SubpassDescription;
RenderPass() = default;
inline RenderPass(std::vector<Attachment> attachments, std::vector<SubpassDescription> subpassDescriptions, std::vector<SubpassDependency> subpassDependencies);
RenderPass(const RenderPass&) = delete;
RenderPass(RenderPass&&) noexcept = default;
virtual ~RenderPass();
inline const Attachment& GetAttachment(std::size_t attachmentIndex) const;
inline std::size_t GetAttachmentCount() const;
inline const std::vector<Attachment>& GetAttachments() const;
inline const std::vector<SubpassDescription>& GetSubpassDescriptions() const;
inline const std::vector<SubpassDependency>& GetsubpassDependencies() const;
RenderPass& operator=(const RenderPass&) = delete;
RenderPass& operator=(RenderPass&&) noexcept = default;
struct Attachment
{
PixelFormat format;
// TODO
AttachmentLoadOp loadOp = AttachmentLoadOp::Load;
AttachmentLoadOp stencilLoadOp = AttachmentLoadOp::Load;
AttachmentStoreOp storeOp = AttachmentStoreOp::Store;
AttachmentStoreOp stencilStoreOp = AttachmentStoreOp::Store;
TextureLayout initialLayout = TextureLayout::Undefined;
TextureLayout finalLayout = TextureLayout::Present;
};
struct AttachmentReference
{
std::size_t attachmentIndex;
TextureLayout attachmentLayout = TextureLayout::ColorInput;
};
struct SubpassDependency
{
std::size_t fromSubpassIndex;
PipelineStageFlags fromStages;
MemoryAccessFlags fromAccessFlags;
std::size_t toSubpassIndex;
PipelineStageFlags toStages;
MemoryAccessFlags toAccessFlags;
bool tilable = false;
};
struct SubpassDescription
{
std::vector<AttachmentReference> colorAttachment;
std::vector<AttachmentReference> inputAttachments;
std::optional<AttachmentReference> depthStencilAttachment;
};
static constexpr std::size_t ExternalSubpassIndex = std::numeric_limits<std::size_t>::max();
protected:
std::vector<Attachment> m_attachments;
std::vector<SubpassDependency> m_subpassDependencies;
std::vector<SubpassDescription> m_subpassDescriptions;
};
}