Graphics: Rework RenderTargets
- RenderTarget have been moved to the Graphics module and are now lightweight objects between the target of rendering (swapchain or texture) - RenderTexture no longer require a blit between the framegraph texture and the target texture (the target texture is now directly rendered onto using a new feature of the framegraph) - ForwardFramePipeline viewers are now properly ordered by render order
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
// 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_RENDERTARGET_HPP
|
||||
#define NAZARA_RENDERER_RENDERTARGET_HPP
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CommandBufferBuilder;
|
||||
class Framebuffer;
|
||||
class RenderFrame;
|
||||
class RenderPass;
|
||||
class Texture;
|
||||
|
||||
class NAZARA_RENDERER_API RenderTarget
|
||||
{
|
||||
public:
|
||||
RenderTarget() = default;
|
||||
virtual ~RenderTarget();
|
||||
|
||||
virtual void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const = 0;
|
||||
|
||||
virtual const Vector2ui& GetSize() const = 0;
|
||||
|
||||
NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/);
|
||||
NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/, const Vector2ui& /*newSize*/);
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderTarget.inl>
|
||||
|
||||
#endif // NAZARA_RENDERER_RENDERTARGET_HPP
|
||||
@@ -1,11 +0,0 @@
|
||||
// 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/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -1,46 +0,0 @@
|
||||
// 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);
|
||||
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
|
||||
@@ -1,16 +0,0 @@
|
||||
// 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>
|
||||
@@ -12,16 +12,17 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderFrame.hpp>
|
||||
#include <Nazara/Renderer/RenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class CommandPool;
|
||||
class Framebuffer;
|
||||
class RenderDevice;
|
||||
class TransientResources;
|
||||
|
||||
class NAZARA_RENDERER_API Swapchain : public RenderTarget
|
||||
class NAZARA_RENDERER_API Swapchain
|
||||
{
|
||||
public:
|
||||
Swapchain() = default;
|
||||
@@ -29,14 +30,13 @@ namespace Nz
|
||||
|
||||
virtual RenderFrame AcquireFrame() = 0;
|
||||
|
||||
void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const override;
|
||||
|
||||
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 const Vector2ui& GetSize() const = 0;
|
||||
virtual PresentModeFlags GetSupportedPresentModes() const = 0;
|
||||
|
||||
virtual void NotifyResize(const Vector2ui& newSize) = 0;
|
||||
@@ -45,6 +45,8 @@ namespace Nz
|
||||
|
||||
virtual TransientResources& Transient() = 0;
|
||||
|
||||
NazaraSignal(OnSwapchainResize, Swapchain* /*swapchain*/, const Vector2ui& /*newSize*/);
|
||||
|
||||
protected:
|
||||
static void BuildRenderPass(PixelFormat colorFormat, PixelFormat depthFormat, std::vector<RenderPass::Attachment>& attachments, std::vector<RenderPass::SubpassDescription>& subpassDescriptions, std::vector<RenderPass::SubpassDependency>& subpassDependencies);
|
||||
};
|
||||
|
||||
@@ -9,28 +9,26 @@
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Platform/WindowEventHandler.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Renderer/Swapchain.hpp>
|
||||
#include <Nazara/Renderer/SwapchainParameters.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Framebuffer;
|
||||
class RenderDevice;
|
||||
class Window;
|
||||
|
||||
class NAZARA_RENDERER_API WindowSwapchain : public RenderTarget
|
||||
class NAZARA_RENDERER_API WindowSwapchain
|
||||
{
|
||||
public:
|
||||
WindowSwapchain(std::shared_ptr<RenderDevice> renderDevice, Window& window, SwapchainParameters parameters = SwapchainParameters());
|
||||
WindowSwapchain(const WindowSwapchain&) = delete;
|
||||
WindowSwapchain(WindowSwapchain&&) = delete;
|
||||
inline ~WindowSwapchain();
|
||||
~WindowSwapchain() = default;
|
||||
|
||||
inline RenderFrame AcquireFrame();
|
||||
|
||||
inline void BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const override;
|
||||
|
||||
inline bool DoesRenderOnlyIfFocused() const;
|
||||
|
||||
inline void EnableRenderOnlyIfFocused(bool enable = true);
|
||||
@@ -38,15 +36,18 @@ namespace Nz
|
||||
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;
|
||||
const Vector2ui& GetSize() const;
|
||||
inline Swapchain* GetSwapchain();
|
||||
inline const Swapchain* GetSwapchain() const;
|
||||
|
||||
inline TransientResources& Transient();
|
||||
|
||||
WindowSwapchain& operator=(const WindowSwapchain&) = delete;
|
||||
WindowSwapchain& operator=(WindowSwapchain&& windowSwapchain) = delete;
|
||||
|
||||
NazaraSignal(OnSwapchainCreated, WindowSwapchain* /*swapchain*/, Swapchain& /*swapchain*/);
|
||||
NazaraSignal(OnSwapchainDestroy, WindowSwapchain* /*swapchain*/);
|
||||
|
||||
private:
|
||||
void ConnectSignals();
|
||||
inline void DisconnectSignals();
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline WindowSwapchain::~WindowSwapchain()
|
||||
{
|
||||
OnRenderTargetRelease(this);
|
||||
}
|
||||
|
||||
inline RenderFrame WindowSwapchain::AcquireFrame()
|
||||
{
|
||||
if (m_isMinimized || (!m_hasFocus && m_renderOnlyIfFocused))
|
||||
@@ -20,11 +15,6 @@ namespace Nz
|
||||
return m_swapchain->AcquireFrame();
|
||||
}
|
||||
|
||||
inline void WindowSwapchain::BlitTexture(RenderFrame& renderFrame, CommandBufferBuilder& builder, const Texture& texture) const
|
||||
{
|
||||
return m_swapchain->BlitTexture(renderFrame, builder, texture);
|
||||
}
|
||||
|
||||
inline bool WindowSwapchain::DoesRenderOnlyIfFocused() const
|
||||
{
|
||||
return m_renderOnlyIfFocused;
|
||||
@@ -53,14 +43,14 @@ namespace Nz
|
||||
return m_swapchain->GetRenderPass();
|
||||
}
|
||||
|
||||
inline Swapchain& WindowSwapchain::GetSwapchain()
|
||||
inline Swapchain* WindowSwapchain::GetSwapchain()
|
||||
{
|
||||
return *m_swapchain;
|
||||
return m_swapchain.get();
|
||||
}
|
||||
|
||||
inline const Swapchain& WindowSwapchain::GetSwapchain() const
|
||||
inline const Swapchain* WindowSwapchain::GetSwapchain() const
|
||||
{
|
||||
return *m_swapchain;
|
||||
return m_swapchain.get();
|
||||
}
|
||||
|
||||
inline TransientResources& WindowSwapchain::Transient()
|
||||
|
||||
Reference in New Issue
Block a user