From e4957e089a8d3ef7dcb22ff72f59f620c0c601d7 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 2 Jul 2026 12:51:51 +0800 Subject: [PATCH] [Fix] (MG_State/GLState): ignore inactive frag data bindings [skip ci] --- .../GLState/ProgramState/ProgramObject.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp index a76988e9..f1a9e16c 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp @@ -585,9 +585,16 @@ namespace MobileGL::MG_State::GLState { } Int ProgramObject::GetFragmentDataLocation(const char* name) { - // TODO: should retrieve "post-mortem" location from glslang instead - auto it = m_explicitFragDataLocation.find(name); - if (it == m_explicitFragDataLocation.end()) return -1; - return (Int)it->second; + if (!m_program || !name) return -1; + + const auto explicitLocation = m_explicitFragDataLocation.find(name); + const Int outputCount = m_program->getNumPipeOutputs(); + for (Int index = 0; index < outputCount; ++index) { + const auto& output = m_program->getPipeOutput(index); + if (output.name != name) continue; + if (explicitLocation != m_explicitFragDataLocation.end()) return static_cast(explicitLocation->second); + return static_cast(output.layoutLocation()); + } + return -1; } } // namespace MobileGL::MG_State::GLState