Graphics: Add RenderTexture class

This commit is contained in:
SirLynix
2023-11-20 00:04:11 +01:00
committed by Jérôme Leclercq
parent 4f08d0b3c1
commit aaf3d97954
32 changed files with 354 additions and 76 deletions

View File

@@ -39,7 +39,7 @@ namespace Nz
const std::shared_ptr<Texture>& GetAttachmentTexture(std::size_t attachmentIndex) const;
const std::shared_ptr<RenderPass>& GetRenderPass(std::size_t passIndex) const;
bool Resize(RenderFrame& renderFrame);
bool Resize(RenderFrame& renderFrame, std::span<Vector2ui> viewerTargetSizes);
BakedFrameGraph& operator=(const BakedFrameGraph&) = delete;
BakedFrameGraph& operator=(BakedFrameGraph&&) noexcept = default;

View File

@@ -45,7 +45,7 @@ namespace Nz
inline float GetZFar() const;
inline float GetZNear() const;
std::size_t RegisterPasses(const std::vector<std::unique_ptr<FramePipelinePass>>& passes, FrameGraph& frameGraph, const FunctionRef<void(std::size_t passIndex, FramePass& framePass, FramePipelinePassFlags flags)>& passCallback = nullptr) const override;
std::size_t RegisterPasses(const std::vector<std::unique_ptr<FramePipelinePass>>& passes, FrameGraph& frameGraph, std::optional<unsigned int> viewerIndex, const FunctionRef<void(std::size_t passIndex, FramePass& framePass, FramePipelinePassFlags flags)>& passCallback = nullptr) const override;
inline void UpdateClearColor(Color color);
inline void UpdateFOV(DegreeAnglef fov);

View File

@@ -38,11 +38,12 @@ namespace Nz
inline std::size_t AddAttachmentCube(FramePassAttachment attachment);
inline std::size_t AddAttachmentCubeFace(std::size_t attachmentId, CubemapFace face);
inline std::size_t AddAttachmentProxy(std::string name, std::size_t attachmentId);
inline void AddBackbufferOutput(std::size_t backbufferOutput);
inline FramePass& AddPass(std::string name);
BakedFrameGraph Bake();
inline void MarkAsFinalOutput(std::size_t attachmentIndex);
FrameGraph& operator=(const FrameGraph&) = delete;
FrameGraph& operator=(FrameGraph&&) noexcept = default;
@@ -138,7 +139,7 @@ namespace Nz
using AttachmentType = std::variant<FramePassAttachment, AttachmentProxy, AttachmentArray, AttachmentCube, AttachmentLayer>;
std::vector<std::size_t> m_backbufferOutputs;
std::vector<std::size_t> m_finalOutputs;
std::vector<FramePass> m_framePasses;
std::vector<AttachmentType> m_attachments;
WorkData m_pending;

View File

@@ -78,16 +78,16 @@ namespace Nz
return id;
}
inline void FrameGraph::AddBackbufferOutput(std::size_t backbufferOutput)
{
m_backbufferOutputs.push_back(backbufferOutput);
}
inline FramePass& FrameGraph::AddPass(std::string name)
{
std::size_t id = m_framePasses.size();
return m_framePasses.emplace_back(*this, id, std::move(name));
}
inline void FrameGraph::MarkAsFinalOutput(std::size_t attachmentIndex)
{
m_finalOutputs.push_back(attachmentIndex);
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -30,9 +30,11 @@ namespace Nz
PixelFormat format;
FramePassAttachmentSize size;
TextureUsageFlags usage;
bool canReuse;
unsigned int width;
unsigned int height;
unsigned int layerCount;
unsigned int viewerIndex;
};
}

View File

@@ -90,8 +90,8 @@ namespace Nz
struct Input
{
std::size_t attachmentId;
std::optional<TextureLayout> assumedLayout;
std::size_t attachmentId;
bool doesRead = true;
};

View File

@@ -18,17 +18,19 @@ namespace Nz
enum class FramePassAttachmentSize
{
Fixed,
SwapchainFactor
SwapchainFactor,
ViewerTargetFactor,
};
struct FramePassAttachment
{
std::string name;
PixelFormat format;
TextureUsage additionalUsage = TextureUsage::TransferSource;
FramePassAttachmentSize size = FramePassAttachmentSize::SwapchainFactor;
TextureUsageFlags additionalUsages;
FramePassAttachmentSize size = FramePassAttachmentSize::ViewerTargetFactor;
unsigned int width = 100'000;
unsigned int height = 100'000;
unsigned int viewerIndex = 0;
};
}

View File

@@ -53,7 +53,7 @@ namespace Nz
inline void EnablePassFlags(std::size_t passIndex, FramePipelinePassFlags flags);
std::size_t RegisterPasses(const std::vector<std::unique_ptr<FramePipelinePass>>& passes, FrameGraph& frameGraph, const FunctionRef<void(std::size_t passIndex, FramePass& framePass, FramePipelinePassFlags flags)>& passCallback = nullptr) const;
std::size_t RegisterPasses(const std::vector<std::unique_ptr<FramePipelinePass>>& passes, FrameGraph& frameGraph, std::optional<unsigned int> viewerIndex, const FunctionRef<void(std::size_t passIndex, FramePass& framePass, FramePipelinePassFlags flags)>& passCallback = nullptr) const;
inline void SetFinalOutput(std::size_t attachmentIndex);

View File

@@ -28,7 +28,7 @@ namespace Nz
virtual std::vector<std::unique_ptr<FramePipelinePass>> BuildPasses(FramePipelinePass::PassData& passData) const = 0;
virtual std::size_t RegisterPasses(const std::vector<std::unique_ptr<FramePipelinePass>>& passes, FrameGraph& frameGraph, const FunctionRef<void(std::size_t passIndex, FramePass& framePass, FramePipelinePassFlags flags)>& passCallback = nullptr) const = 0;
virtual std::size_t RegisterPasses(const std::vector<std::unique_ptr<FramePipelinePass>>& passes, FrameGraph& frameGraph, std::optional<unsigned int> viewerIndex, const FunctionRef<void(std::size_t passIndex, FramePass& framePass, FramePipelinePassFlags flags)>& passCallback = nullptr) const = 0;
PipelineViewer& operator=(const PipelineViewer&) = delete;
PipelineViewer& operator=(PipelineViewer&&) = delete;