From 37255523b105e1abbfafc64e58beb5c3e28b39b5 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 2 Jul 2026 18:29:26 +0800 Subject: [PATCH] [Fix] (MG_Impl/GLImpl): report incomplete framebuffer attachments [skip ci] --- .../GLImpl/Framebuffer/GL_Framebuffer.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp index 8d3da96a..5de7bfd9 100644 --- a/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp @@ -64,6 +64,15 @@ namespace MobileGL::MG_Impl::GLImpl { HasCompleteRenderbufferAttachment(framebufferObject); } + Bool HasDefinedAttachment(const MG_State::GLState::FramebufferObject& framebufferObject) { + for (const auto& attachment : framebufferObject.GetAllAttachmentObjects()) { + if (attachment.IsValid() && !attachment.IsEmpty()) { + return true; + } + } + return false; + } + void RecordUnsupportedFramebufferTextureAttachmentError(const char* functionName, const char* detail) { MG_State::pGLContext->RecordError( ErrorCode::InvalidOperation, @@ -1199,7 +1208,9 @@ namespace MobileGL::MG_Impl::GLImpl { // additional GL_FRAMEBUFFER_UNSUPPORTED cases, GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, // GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS if (!framebufferObject->CheckCompleteness()) { - return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + return HasDefinedAttachment(*framebufferObject) ? + GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT : + GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; } if (IsActiveBackendDirectVulkan() && IsUnsupportedFramebufferForDirectVulkan(*framebufferObject)) { @@ -1222,7 +1233,9 @@ namespace MobileGL::MG_Impl::GLImpl { if (!framebufferObject) return GL_FRAMEBUFFER_UNDEFINED; if (!framebufferObject->CheckCompleteness()) { - return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + return HasDefinedAttachment(*framebufferObject) ? + GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT : + GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; } if (IsActiveBackendDirectVulkan() && IsUnsupportedFramebufferForDirectVulkan(*framebufferObject)) {