Graphics: Add RenderTexture class
This commit is contained in:
committed by
Jérôme Leclercq
parent
4f08d0b3c1
commit
aaf3d97954
@@ -69,6 +69,7 @@
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/OwnedMemoryStream.hpp>
|
||||
#include <Nazara/Core/ParameterFile.hpp>
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Core/Plugin.hpp>
|
||||
#include <Nazara/Core/PluginInterface.hpp>
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <Nazara/Graphics/DebugDrawPipelinePass.hpp>
|
||||
#include <Nazara/Graphics/DepthPipelinePass.hpp>
|
||||
#include <Nazara/Graphics/DirectionalLight.hpp>
|
||||
#include <Nazara/Graphics/DirectionalLightShadowData.hpp>
|
||||
#include <Nazara/Graphics/ElementRenderer.hpp>
|
||||
#include <Nazara/Graphics/ElementRendererRegistry.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
@@ -48,6 +49,7 @@
|
||||
#include <Nazara/Graphics/FramePassAttachment.hpp>
|
||||
#include <Nazara/Graphics/FramePipeline.hpp>
|
||||
#include <Nazara/Graphics/FramePipelinePass.hpp>
|
||||
#include <Nazara/Graphics/FramePipelinePassRegistry.hpp>
|
||||
#include <Nazara/Graphics/GraphicalMesh.hpp>
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
|
||||
@@ -62,9 +64,13 @@
|
||||
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||
#include <Nazara/Graphics/MaterialSettings.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Graphics/PipelinePassList.hpp>
|
||||
#include <Nazara/Graphics/PipelineViewer.hpp>
|
||||
#include <Nazara/Graphics/PointLight.hpp>
|
||||
#include <Nazara/Graphics/PointLightShadowData.hpp>
|
||||
#include <Nazara/Graphics/PostProcessPipelinePass.hpp>
|
||||
#include <Nazara/Graphics/PredefinedMaterials.hpp>
|
||||
#include <Nazara/Graphics/PredefinedShaderStructBuilder.hpp>
|
||||
#include <Nazara/Graphics/PredefinedShaderStructs.hpp>
|
||||
#include <Nazara/Graphics/RenderBufferPool.hpp>
|
||||
#include <Nazara/Graphics/RenderElement.hpp>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace Nz
|
||||
|
||||
struct Input
|
||||
{
|
||||
std::size_t attachmentId;
|
||||
std::optional<TextureLayout> assumedLayout;
|
||||
std::size_t attachmentId;
|
||||
bool doesRead = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -270,4 +270,3 @@ namespace Nz
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
#include "OpenGLCommandBuffer.hpp"
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <Nazara/Renderer/RenderPipelineLayout.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/ShaderBinding.hpp>
|
||||
#include <Nazara/Renderer/ShaderModule.hpp>
|
||||
#include <Nazara/Renderer/Swapchain.hpp>
|
||||
|
||||
@@ -28,9 +28,6 @@ namespace Nz
|
||||
|
||||
virtual void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const = 0;
|
||||
|
||||
virtual const Framebuffer& GetFramebuffer(std::size_t i) const = 0;
|
||||
virtual std::size_t GetFramebufferCount() const = 0;
|
||||
virtual const RenderPass& GetRenderPass() const = 0;
|
||||
virtual const Vector2ui& GetSize() const = 0;
|
||||
|
||||
NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/);
|
||||
|
||||
46
include/Nazara/Renderer/RenderTexture.hpp
Normal file
46
include/Nazara/Renderer/RenderTexture.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RENDERER_RENDERTEXTURE_HPP
|
||||
#define NAZARA_RENDERER_RENDERTEXTURE_HPP
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Texture;
|
||||
|
||||
class NAZARA_RENDERER_API RenderTexture : public RenderTarget
|
||||
{
|
||||
public:
|
||||
inline RenderTexture(std::shared_ptr<Texture> targetTexture);
|
||||
inline RenderTexture(std::shared_ptr<Texture> targetTexture, PipelineStage targetPipelineStage, MemoryAccessFlags targetMemoryFlags, TextureLayout targetLayout);
|
||||
RenderTexture(const RenderTexture&) = delete;
|
||||
RenderTexture(RenderTexture&&) = delete;
|
||||
~RenderTexture() = default;
|
||||
|
||||
void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const override;
|
||||
|
||||
const Vector2ui& GetSize() const override;
|
||||
|
||||
RenderTexture& operator=(const RenderTexture&) = delete;
|
||||
RenderTexture& operator=(RenderTexture&&) = delete;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Texture> m_targetTexture;
|
||||
MemoryAccessFlags m_targetMemoryFlags;
|
||||
PipelineStage m_targetPipelineStage;
|
||||
TextureLayout m_targetLayout;
|
||||
Vector2ui m_textureSize;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderTexture.inl>
|
||||
|
||||
#endif // NAZARA_RENDERER_RENDERTEXTURE_HPP
|
||||
16
include/Nazara/Renderer/RenderTexture.inl
Normal file
16
include/Nazara/Renderer/RenderTexture.inl
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline RenderTexture::RenderTexture(std::shared_ptr<Texture> targetTexture) :
|
||||
RenderTexture(std::move(targetTexture), PipelineStage::FragmentShader, MemoryAccess::ColorRead, TextureLayout::ColorInput)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -33,7 +33,10 @@ namespace Nz
|
||||
|
||||
virtual std::shared_ptr<CommandPool> CreateCommandPool(QueueType queueType) = 0;
|
||||
|
||||
virtual const Framebuffer& GetFramebuffer(std::size_t i) const = 0;
|
||||
virtual std::size_t GetFramebufferCount() const = 0;
|
||||
virtual PresentMode GetPresentMode() const = 0;
|
||||
virtual const RenderPass& GetRenderPass() const = 0;
|
||||
virtual PresentModeFlags GetSupportedPresentModes() const = 0;
|
||||
|
||||
virtual void NotifyResize(const Vector2ui& newSize) = 0;
|
||||
|
||||
@@ -108,4 +108,3 @@ namespace Nz
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
#include "TransientResources.hpp"
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace Nz
|
||||
|
||||
inline void EnableRenderOnlyIfFocused(bool enable = true);
|
||||
|
||||
const Framebuffer& GetFramebuffer(std::size_t i) const override;
|
||||
std::size_t GetFramebufferCount() const override;
|
||||
const RenderPass& GetRenderPass() const override;
|
||||
inline const Framebuffer& GetFramebuffer(std::size_t i) const;
|
||||
inline std::size_t GetFramebufferCount() const;
|
||||
inline const RenderPass& GetRenderPass() const;
|
||||
const Vector2ui& GetSize() const override;
|
||||
inline Swapchain& GetSwapchain();
|
||||
inline const Swapchain& GetSwapchain() const;
|
||||
|
||||
@@ -35,6 +35,24 @@ namespace Nz
|
||||
m_renderOnlyIfFocused = enable;
|
||||
}
|
||||
|
||||
inline const Framebuffer& WindowSwapchain::GetFramebuffer(std::size_t i) const
|
||||
{
|
||||
assert(m_swapchain);
|
||||
return m_swapchain->GetFramebuffer(i);
|
||||
}
|
||||
|
||||
inline std::size_t WindowSwapchain::GetFramebufferCount() const
|
||||
{
|
||||
assert(m_swapchain);
|
||||
return m_swapchain->GetFramebufferCount();
|
||||
}
|
||||
|
||||
inline const RenderPass& WindowSwapchain::GetRenderPass() const
|
||||
{
|
||||
assert(m_swapchain);
|
||||
return m_swapchain->GetRenderPass();
|
||||
}
|
||||
|
||||
inline Swapchain& WindowSwapchain::GetSwapchain()
|
||||
{
|
||||
return *m_swapchain;
|
||||
|
||||
Reference in New Issue
Block a user