From f4ce17af51548efa351bf0426acf221da66b0092 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 4 Feb 2026 10:42:23 +0800 Subject: [PATCH] [Perf] (MG_Backend/DirectGLES): skip redundant attachment object sync --- MobileGL/MG_Backend/DirectGLES/Managers.cpp | 8 +++++++- MobileGL/MG_Backend/DirectGLES/Managers.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.cpp b/MobileGL/MG_Backend/DirectGLES/Managers.cpp index 8684b92a..db099558 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Managers.cpp @@ -870,12 +870,18 @@ namespace MobileGL::MG_Backend::DirectGLES { // attach texture to fbo // TODO: attach according to remapped const auto& attachments = stateFBOObject->GetAllAttachmentObjects(); + const auto& attachmentVersions = stateFBOObject->GetAllFramebufferAttachmentVersions(); for (SizeT i = 0; i < attachments.size(); ++i) { const auto& attachmentObject = attachments[i]; FramebufferAttachmentType type = static_cast(i); + // should retrieve BACKEND attachment here GLenum glBackendAttachment = MG_Util::ConvertFramebufferAttachmentTypeToGLEnum(type); - SyncAttachmentObject(glFBOTarget, attachmentObject, glBackendAttachment); + // relevant FRONTEND!!! version should be checked and updated + if (m_syncedFrontendAttachmentVersions[i] != attachmentVersions[i]) { + SyncAttachmentObject(glFBOTarget, attachmentObject, glBackendAttachment); + m_syncedFrontendAttachmentVersions[i] = attachmentVersions[i]; + } } } diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.h b/MobileGL/MG_Backend/DirectGLES/Managers.h index 5ae73d4d..b84c953b 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.h +++ b/MobileGL/MG_Backend/DirectGLES/Managers.h @@ -164,7 +164,7 @@ namespace MobileGL::MG_Backend::DirectGLES { GLenum m_backendReadBuffer = GL_COLOR_ATTACHMENT0; using FramebufferObject = MG_State::GLState::FramebufferObject; - FramebufferObject::FramebufferAttachmentVersionArray m_syncedAttachmentVersions = {0}; + FramebufferObject::FramebufferAttachmentVersionArray m_syncedFrontendAttachmentVersions = {0}; }; extern UnorderedMap, SharedPtr>