[Fix] (MG_Impl/EGLImpl, MG_Backend): handle EGL current handoff for NeoForge earlydisplay

Treat valid-display no-surface eglMakeCurrent calls as EGL release requests, keep EGLState and backend current records consistent across threads, and rebind the native DirectGLES EGL context during attach/release.

Add EGLState coverage for cross-thread owner transfer and same-thread release/reattach behavior.
This commit is contained in:
2026-06-30 16:44:38 +08:00
parent 2f1949e093
commit 5b116696f0
12 changed files with 271 additions and 20 deletions
+12 -1
View File
@@ -1054,9 +1054,20 @@ namespace MobileGL {
EGLContextHandle context) {
const std::lock_guard<std::recursive_mutex> lock(m_mutex);
const Bool releaseCurrentRequest =
display == EGL_NO_DISPLAY && draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE && context == nullptr;
draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE && context == nullptr;
const auto threadKey = CurrentThreadKey();
if (releaseCurrentRequest) {
if (display != EGL_NO_DISPLAY) {
auto* displayObject = TryGetDisplay(display);
if (!displayObject) {
SetError(EGL_BAD_DISPLAY);
return false;
}
if (!displayObject->Initialized) {
SetError(EGL_NOT_INITIALIZED);
return false;
}
}
ReleaseThreadUnlocked(threadKey);
return true;
}