Graphics: Add DebugDrawer support

This commit is contained in:
SirLynix
2022-08-17 20:12:49 +02:00
parent 4a5f866754
commit f1549b934c
11 changed files with 156 additions and 9 deletions

View File

@@ -0,0 +1,50 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GRAPHICS_DEBUGDRAWPIPELINEPASS_HPP
#define NAZARA_GRAPHICS_DEBUGDRAWPIPELINEPASS_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/ElementRenderer.hpp>
#include <Nazara/Graphics/FramePipelinePass.hpp>
#include <Nazara/Graphics/MaterialPass.hpp>
#include <Nazara/Graphics/RenderElement.hpp>
#include <Nazara/Graphics/RenderQueue.hpp>
#include <Nazara/Graphics/RenderQueueRegistry.hpp>
#include <Nazara/Math/Frustum.hpp>
namespace Nz
{
class AbstractViewer;
class FrameGraph;
class FramePipeline;
class Material;
class NAZARA_GRAPHICS_API DebugDrawPipelinePass : public FramePipelinePass
{
public:
DebugDrawPipelinePass(FramePipeline& owner, AbstractViewer* viewer);
DebugDrawPipelinePass(const DebugDrawPipelinePass&) = delete;
DebugDrawPipelinePass(DebugDrawPipelinePass&&) = delete;
~DebugDrawPipelinePass() = default;
void Prepare(RenderFrame& renderFrame);
void RegisterToFrameGraph(FrameGraph& frameGraph, std::size_t inputColorBufferIndex, std::size_t outputColorBufferIndex);
DepthPipelinePass& operator=(const DepthPipelinePass&) = delete;
DepthPipelinePass& operator=(DepthPipelinePass&&) = delete;
private:
AbstractViewer* m_viewer;
FramePipeline& m_pipeline;
};
}
#include <Nazara/Graphics/DebugDrawPipelinePass.inl>
#endif // NAZARA_GRAPHICS_DEBUGDRAWPIPELINEPASS_HPP

View File

@@ -0,0 +1,12 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/DebugDrawPipelinePass.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -11,6 +11,7 @@
#include <Nazara/Graphics/BakedFrameGraph.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/DepthPipelinePass.hpp>
#include <Nazara/Graphics/DebugDrawPipelinePass.hpp>
#include <Nazara/Graphics/ElementRenderer.hpp>
#include <Nazara/Graphics/ForwardPipelinePass.hpp>
#include <Nazara/Graphics/FramePipeline.hpp>
@@ -106,10 +107,12 @@ namespace Nz
struct ViewerData
{
std::size_t colorAttachment;
std::size_t forwardColorAttachment;
std::size_t debugColorAttachment;
std::size_t depthStencilAttachment;
std::unique_ptr<DepthPipelinePass> depthPrepass;
std::unique_ptr<ForwardPipelinePass> forwardPass;
std::unique_ptr<DebugDrawPipelinePass> debugDrawPass;
AbstractViewer* viewer;
Int32 renderOrder = 0;
RenderQueueRegistry forwardRegistry;

View File

@@ -12,6 +12,7 @@
#include <Nazara/Graphics/RenderElement.hpp>
#include <Nazara/Graphics/RenderQueue.hpp>
#include <Nazara/Graphics/WorldInstance.hpp>
#include <Nazara/Renderer/DebugDrawer.hpp>
#include <memory>
#include <vector>
@@ -34,6 +35,7 @@ namespace Nz
template<typename F> void ForEachElementRenderer(F&& callback);
inline DebugDrawer& GetDebugDrawer();
inline ElementRenderer& GetElementRenderer(std::size_t elementIndex);
inline std::size_t GetElementRendererCount() const;
@@ -66,6 +68,7 @@ namespace Nz
private:
std::vector<std::unique_ptr<ElementRenderer>> m_elementRenderers;
DebugDrawer m_debugDrawer;
};
}

View File

@@ -8,6 +8,11 @@
namespace Nz
{
inline DebugDrawer& FramePipeline::GetDebugDrawer()
{
return m_debugDrawer;
}
inline ElementRenderer& FramePipeline::GetElementRenderer(std::size_t elementIndex)
{
assert(elementIndex < m_elementRenderers.size());

View File

@@ -40,6 +40,9 @@ namespace Nz
template<typename T = RenderWindow, typename... Args> T& CreateWindow(Args&&... args);
inline FramePipeline& GetFramePipeline();
inline const FramePipeline& GetFramePipeline() const;
void Update(float elapsedTime);
RenderSystem& operator=(const RenderSystem&) = delete;

View File

@@ -20,6 +20,16 @@ namespace Nz
return windowRef;
}
inline FramePipeline& RenderSystem::GetFramePipeline()
{
return *m_pipeline;
}
inline const FramePipeline& RenderSystem::GetFramePipeline() const
{
return *m_pipeline;
}
}
#include <Nazara/Graphics/DebugOff.hpp>