From c93a5f1975c7224a877bab9f17b840057ff76435 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 21 Nov 2023 08:05:26 +0100 Subject: [PATCH] Graphics: Fix texture reuse when backbuffer is a proxy --- src/Nazara/Graphics/FrameGraph.cpp | 33 ++++++++---------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/Nazara/Graphics/FrameGraph.cpp b/src/Nazara/Graphics/FrameGraph.cpp index 840605319..99ca5875f 100644 --- a/src/Nazara/Graphics/FrameGraph.cpp +++ b/src/Nazara/Graphics/FrameGraph.cpp @@ -1089,14 +1089,8 @@ namespace Nz CheckExternalTexture(attachmentIndex, data); // Final outputs cannot be reused - for (std::size_t outputAttachmentIndex : m_backbufferOutputs) - { - if (attachmentIndex == outputAttachmentIndex) - { - data.canReuse = false; - break; - } - } + if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + data.canReuse = false; return textureId; } @@ -1138,14 +1132,8 @@ namespace Nz CheckExternalTexture(attachmentIndex, data); // Final outputs cannot be reused - for (std::size_t outputAttachmentIndex : m_backbufferOutputs) - { - if (attachmentIndex == outputAttachmentIndex) - { - data.canReuse = false; - break; - } - } + if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + data.canReuse = false; return textureId; } @@ -1186,14 +1174,8 @@ namespace Nz CheckExternalTexture(attachmentIndex, data); // Final outputs cannot be reused - for (std::size_t outputAttachmentIndex : m_backbufferOutputs) - { - if (attachmentIndex == outputAttachmentIndex) - { - data.canReuse = false; - break; - } - } + if (std::find(m_backbufferOutputs.begin(), m_backbufferOutputs.end(), attachmentIndex) != m_backbufferOutputs.end()) + data.canReuse = false; return textureId; } @@ -1236,6 +1218,9 @@ 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()) + m_pending.textures[textureId].canReuse = false; + return textureId; } else