diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index 4ed42d60c..844c7034e 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -1037,7 +1037,7 @@ int main(int argc, char* argv[]) builder.Draw(3); }); - graph.AddBackbufferOutput(toneMappingOutput); + graph.AddOutput(toneMappingOutput); return graph.Bake(); }(); diff --git a/include/Nazara/Graphics/FrameGraph.hpp b/include/Nazara/Graphics/FrameGraph.hpp index 70b9a7b99..d69f93c77 100644 --- a/include/Nazara/Graphics/FrameGraph.hpp +++ b/include/Nazara/Graphics/FrameGraph.hpp @@ -39,7 +39,7 @@ namespace Nz inline std::size_t AddAttachmentCubeFace(std::size_t attachmentId, CubemapFace face); inline std::size_t AddAttachmentProxy(std::string name, std::size_t attachmentId); inline FramePass& AddPass(std::string name); - inline void AddBackbufferOutput(std::size_t attachmentIndex); + inline void AddOutput(std::size_t attachmentIndex); BakedFrameGraph Bake(); @@ -140,7 +140,7 @@ namespace Nz using AttachmentType = std::variant; - std::vector m_backbufferOutputs; + std::vector m_graphOutputs; std::vector m_framePasses; std::vector m_attachments; std::unordered_map> m_externalTextures; diff --git a/include/Nazara/Graphics/FrameGraph.inl b/include/Nazara/Graphics/FrameGraph.inl index 8a40491db..d4b70cf9a 100644 --- a/include/Nazara/Graphics/FrameGraph.inl +++ b/include/Nazara/Graphics/FrameGraph.inl @@ -84,9 +84,9 @@ namespace Nz return m_framePasses.emplace_back(*this, id, std::move(name)); } - inline void FrameGraph::AddBackbufferOutput(std::size_t attachmentIndex) + inline void FrameGraph::AddOutput(std::size_t attachmentIndex) { - m_backbufferOutputs.push_back(attachmentIndex); + m_graphOutputs.push_back(attachmentIndex); } inline void FrameGraph::BindExternalTexture(std::size_t attachmentIndex, std::shared_ptr texture) diff --git a/src/Nazara/Graphics/FrameGraph.cpp b/src/Nazara/Graphics/FrameGraph.cpp index 99ca5875f..8099cb4fd 100644 --- a/src/Nazara/Graphics/FrameGraph.cpp +++ b/src/Nazara/Graphics/FrameGraph.cpp @@ -28,7 +28,7 @@ namespace Nz BakedFrameGraph FrameGraph::Bake() { - if (m_backbufferOutputs.empty()) + if (m_graphOutputs.empty()) throw std::runtime_error("no backbuffer output has been set"); m_pending.attachmentReadList.clear(); @@ -45,7 +45,7 @@ namespace Nz BuildReadWriteList(); - for (std::size_t output : m_backbufferOutputs) + for (std::size_t output : m_graphOutputs) { auto it = m_pending.attachmentWriteList.find(output); if (it == m_pending.attachmentWriteList.end()) @@ -291,7 +291,7 @@ namespace Nz } // Add TextureUsage::ShaderSampling and TextureUsage::TransferSource to final outputs - for (std::size_t output : m_backbufferOutputs) + for (std::size_t output : m_graphOutputs) { auto it = m_pending.attachmentToTextures.find(output); assert(it != m_pending.attachmentToTextures.end()); @@ -1089,7 +1089,7 @@ namespace Nz CheckExternalTexture(attachmentIndex, data); // Final outputs cannot be reused - if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + if (std::find(m_graphOutputs.begin(), m_graphOutputs.end(), attachmentIndex) != m_graphOutputs.end()) data.canReuse = false; return textureId; @@ -1132,7 +1132,7 @@ namespace Nz CheckExternalTexture(attachmentIndex, data); // Final outputs cannot be reused - if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + if (std::find(m_graphOutputs.begin(), m_graphOutputs.end(), attachmentIndex) != m_graphOutputs.end()) data.canReuse = false; return textureId; @@ -1174,7 +1174,7 @@ namespace Nz CheckExternalTexture(attachmentIndex, data); // Final outputs cannot be reused - if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + if (std::find(m_graphOutputs.begin(), m_graphOutputs.end(), attachmentIndex) != m_graphOutputs.end()) data.canReuse = false; return textureId; @@ -1218,7 +1218,7 @@ namespace Nz if (m_externalTextures.contains(proxy.attachmentId)) throw std::runtime_error("proxy attachments cannot be bound to external textures"); - if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + if (std::find(m_graphOutputs.begin(), m_graphOutputs.end(), attachmentIndex) != m_graphOutputs.end()) m_pending.textures[textureId].canReuse = false; return textureId; diff --git a/src/Nazara/Graphics/RenderWindow.cpp b/src/Nazara/Graphics/RenderWindow.cpp index 740a29c05..a4624ab9f 100644 --- a/src/Nazara/Graphics/RenderWindow.cpp +++ b/src/Nazara/Graphics/RenderWindow.cpp @@ -31,6 +31,11 @@ namespace Nz SetSwapchain(m_windowSwapchain->GetSwapchain()); } + void RenderWindow::OnBuildGraph(FrameGraph& graph, std::size_t attachmentIndex) const + { + graph.AddOutput(attachmentIndex); + } + void RenderWindow::OnRenderEnd(RenderFrame& renderFrame, const BakedFrameGraph& frameGraph, std::size_t finalAttachment) const { const std::shared_ptr& texture = frameGraph.GetAttachmentTexture(finalAttachment); @@ -49,11 +54,6 @@ namespace Nz }, QueueType::Graphics); } - void RenderWindow::OnBuildGraph(FrameGraph& graph, std::size_t attachmentIndex) const - { - graph.AddBackbufferOutput(attachmentIndex); - } - const Vector2ui& RenderWindow::GetSize() const { if (m_swapchain)