From 5963f4c848f0842603c80c151073a88605ce6e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 19 Dec 2021 18:29:20 +0100 Subject: [PATCH] Graphics/FrameGraph: Fix texture pool issue --- include/Nazara/Graphics/FramePass.hpp | 2 +- include/Nazara/Graphics/FramePass.inl | 7 +++++-- src/Nazara/Graphics/FrameGraph.cpp | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Graphics/FramePass.hpp b/include/Nazara/Graphics/FramePass.hpp index 06cf6a521..45e437fcb 100644 --- a/include/Nazara/Graphics/FramePass.hpp +++ b/include/Nazara/Graphics/FramePass.hpp @@ -46,7 +46,7 @@ namespace Nz inline std::size_t AddInput(std::size_t attachmentId); inline std::size_t AddOutput(std::size_t attachmentId); - template void ForEachAttachment(F&& func) const; + template void ForEachAttachment(F&& func, bool singleDSInputOutputCall = true) const; inline const CommandCallback& GetCommandCallback() const; inline const std::optional& GetDepthStencilClear() const; diff --git a/include/Nazara/Graphics/FramePass.inl b/include/Nazara/Graphics/FramePass.inl index 3a38bfab2..b4f970b88 100644 --- a/include/Nazara/Graphics/FramePass.inl +++ b/include/Nazara/Graphics/FramePass.inl @@ -39,7 +39,7 @@ namespace Nz return outputIndex; } template - void FramePass::ForEachAttachment(F&& func) const + void FramePass::ForEachAttachment(F&& func, bool singleDSInputOutputCall) const { for (const auto& input : m_inputs) func(input.attachmentId); @@ -52,7 +52,10 @@ namespace Nz func(m_depthStencilInput); if (m_depthStencilOutput != FramePass::InvalidAttachmentId && m_depthStencilOutput != m_depthStencilInput) - func(m_depthStencilOutput); + { + if (!singleDSInputOutputCall || m_depthStencilOutput != m_depthStencilInput) + func(m_depthStencilOutput); + } } else if (m_depthStencilOutput != FramePass::InvalidAttachmentId) func(m_depthStencilOutput); diff --git a/src/Nazara/Graphics/FrameGraph.cpp b/src/Nazara/Graphics/FrameGraph.cpp index a21dbedaa..6d7d6b2c4 100644 --- a/src/Nazara/Graphics/FrameGraph.cpp +++ b/src/Nazara/Graphics/FrameGraph.cpp @@ -245,9 +245,7 @@ namespace Nz if (passIndex == lastUsingPassId) { std::size_t textureId = Retrieve(m_pending.attachmentToTextures, attachmentId); - - // For input/output depth-stencil buffer, the same texture can be used - if (m_pending.texturePool.empty() || m_pending.texturePool.back() != textureId) + if (m_pending.texturePool.empty()) { assert(std::find(m_pending.texturePool.begin(), m_pending.texturePool.end(), textureId) == m_pending.texturePool.end()); m_pending.texturePool.push_back(textureId);