From 164bfd810b979171fbe99a92840261500c9fec98 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 16 Jul 2026 05:29:46 -0400 Subject: [PATCH] [Fix] (MG_State/ErrorState): GL error flags are sticky per error code, not an unbounded queue - repeated same-code errors accumulated and leaked into later unrelated glGetError checks (GL CTS "Texture state reset failed" deinit noise and false "Error during glGetTexImage" failures) --- MobileGL/MG_State/GLState/ErrorState/Error.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MobileGL/MG_State/GLState/ErrorState/Error.cpp b/MobileGL/MG_State/GLState/ErrorState/Error.cpp index b42c02db..5c0afc85 100644 --- a/MobileGL/MG_State/GLState/ErrorState/Error.cpp +++ b/MobileGL/MG_State/GLState/ErrorState/Error.cpp @@ -7,6 +7,7 @@ // End of Source File Header #include "Error.h" +#include #include #include @@ -19,7 +20,15 @@ namespace MobileGL::MG_State::GLState { MGLOG_E("Recording OpenGL error (%s):\n%s", MG_Util::ConvertGLEnumToString(MG_Util::ConvertErrorCodeToGLEnum(code)).c_str(), info->toString().c_str()); - m_errors.push_back(MakeUnique(code, Move(info))); + // GL error semantics are sticky flags, not a queue (GL 3.3 core §2.5): with multiple + // error flags, each is set only while currently unset — repeated errors of the same + // code are discarded until glGetError reads the flag. Unbounded accumulation leaked + // stale errors into later, unrelated glGetError checks (GL CTS deinit noise). + const Bool alreadyPending = std::any_of(m_errors.begin(), m_errors.end(), + [code](const auto& e) { return e->code == code; }); + if (!alreadyPending) { + m_errors.push_back(MakeUnique(code, Move(info))); + } } }