From 88bc35b711ddca357dbde909a466a347173ff5f8 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sun, 4 Oct 2026 20:54:28 -0400 Subject: [PATCH] [Refactor] (BackendLoader): share extension name matching between GLES and EGL probes --- MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp | 11 +---------- MobileGL/MG_Backend/DirectGLES/Managers.cpp | 11 +---------- MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp | 11 +++++++++++ MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h | 2 ++ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp index cda13b7a..b4ad8cc5 100644 --- a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp +++ b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp @@ -18613,16 +18613,7 @@ namespace MobileGL::MG_Backend::DirectGLES { Bool YuvTarget = false; }; - Bool HasExtensionWord(const char* list, const char* word) { - if (list == nullptr) return false; - const SizeT n = std::strlen(word); - for (const char* at = std::strstr(list, word); at != nullptr; at = std::strstr(at + 1, word)) { - const Bool startOk = at == list || at[-1] == ' '; - const Bool endOk = at[n] == '\0' || at[n] == ' '; - if (startOk && endOk) return true; - } - return false; - } + using MG_Util::BackendLoader::HasExtensionWord; // None of these is in the loader's tables, and eglGetProcAddress hands back live-looking // stubs for entry points a driver lacks, so the extension strings decide first. Resolved diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.cpp b/MobileGL/MG_Backend/DirectGLES/Managers.cpp index 649d7ff7..83d598cd 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Managers.cpp @@ -2898,16 +2898,7 @@ namespace MobileGL::MG_Backend::DirectGLES { kT0MapReadBit | kT0MapWriteBit | kMapPersistentBit | kMapCoherentBit | kDynamicStorageBit; constexpr GLbitfield kT0MapFlags = kT0MapReadBit | kT0MapWriteBit | kMapPersistentBit | kMapCoherentBit; - Bool HasExtensionWord(const char* list, const char* word) { - if (list == nullptr) return false; - const SizeT n = std::strlen(word); - for (const char* at = std::strstr(list, word); at != nullptr; at = std::strstr(at + 1, word)) { - const Bool startOk = at == list || at[-1] == ' '; - const Bool endOk = at[n] == '\0' || at[n] == ' '; - if (startOk && endOk) return true; - } - return false; - } + using MG_Util::BackendLoader::HasExtensionWord; Bool ResolveT0EntryPoints(String& why) { if (g_t0GetNativeClientBuffer != nullptr && g_t0BufferStorageExternal != nullptr) return true; diff --git a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp index 302e1f96..7fe4fc73 100644 --- a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp +++ b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp @@ -21,6 +21,17 @@ #endif namespace MobileGL::MG_Util::BackendLoader { + Bool HasExtensionWord(const char* list, const char* word) { + if (list == nullptr || word == nullptr || *word == '\0') return false; + const SizeT n = std::strlen(word); + for (const char* at = std::strstr(list, word); at != nullptr; at = std::strstr(at + 1, word)) { + const Bool startOk = at == list || at[-1] == ' '; + const Bool endOk = at[n] == '\0' || at[n] == ' '; + if (startOk && endOk) return true; + } + return false; + } + static Bool UseAngle() { return MG_Config::Features.EsprytUseAngle; } diff --git a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h index 4ecb0065..838b4495 100644 --- a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h +++ b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h @@ -1364,6 +1364,8 @@ namespace MobileGL { } // namespace MG_External namespace MG_Util::BackendLoader { + // Match a complete name in a space-separated GLES/EGL extension string. + Bool HasExtensionWord(const char* list, const char* word); void AcquireGLESFunctions(MG_External::GLESFunctionsTable& funcs, MG_External::EGL::eglGetProcAddress_PTR procAddress); void AcquireEGLFunctions(MG_External::EGLFunctionsTable& funcs);