From 1a9f546309980c85572a90fe74e1435da25785da Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sat, 29 Nov 2025 14:26:01 +0800 Subject: [PATCH] [Feat] (MG_Util/BackendLoaders): Detect buffer storage extension. --- MobileGL/MG_Backend/Init.cpp | 4 ++-- .../MG_Util/BackendLoaders/OpenGL/Loader.cpp | 19 ++++++++++++++----- .../MG_Util/BackendLoaders/OpenGL/Loader.h | 9 +++++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/MobileGL/MG_Backend/Init.cpp b/MobileGL/MG_Backend/Init.cpp index 19b3ec0c..82adf1fa 100644 --- a/MobileGL/MG_Backend/Init.cpp +++ b/MobileGL/MG_Backend/Init.cpp @@ -39,8 +39,8 @@ namespace MobileGL { MGLOG_D("Diligent Engine backend loaded"); #elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES MG_Util::BackendLoader::GLES::Init(); - MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::Caps::GLESVersion.Major, - MG_External::GLES::Caps::GLESVersion.Minor); + MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::g_glesCaps.version.Major, + MG_External::GLES::g_glesCaps.version.Minor); #else MGLOG_W("Unknown backend, skipping backend initialization"); #endif diff --git a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp index 3ad17aa6..c9132f50 100644 --- a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp +++ b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp @@ -6,9 +6,7 @@ namespace MobileGL { namespace MG_External { namespace GLES { - namespace Caps { - Version GLESVersion; - } + Caps::GLESCaps g_glesCaps; GL_FUNC_DECL(glActiveTexture) GL_FUNC_DECL(glAttachShader) @@ -485,8 +483,19 @@ namespace MobileGL { } void InitGLESCapabilities() { - MG_External::GLES::glGetIntegerv(GL_MAJOR_VERSION, &MG_External::GLES::Caps::GLESVersion.Major); - MG_External::GLES::glGetIntegerv(GL_MINOR_VERSION, &MG_External::GLES::Caps::GLESVersion.Minor); + MG_External::GLES::glGetIntegerv(GL_MAJOR_VERSION, &MG_External::GLES::g_glesCaps.version.Major); + MG_External::GLES::glGetIntegerv(GL_MINOR_VERSION, &MG_External::GLES::g_glesCaps.version.Minor); + + GLint extCount = 0; + MG_External::GLES::glGetIntegerv(GL_NUM_EXTENSIONS, &extCount); + for (GLint i = 0; i < extCount; ++i) { + const char* extension = (const char*)MG_External::GLES::glGetStringi(GL_EXTENSIONS, i); + if (extension) { + if (std::strcmp(extension, "GL_EXT_buffer_storage") == 0) { + MG_External::GLES::g_glesCaps.hasPersistentMapping = true; + } + } + } } void InitGLES() { diff --git a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h index b5f1a929..de3a0c10 100644 --- a/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h +++ b/MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.h @@ -547,8 +547,13 @@ namespace MobileGL { namespace GLES { namespace Caps { - extern Version GLESVersion; - } + struct GLESCaps { + Version version; + Bool hasPersistentMapping; + }; + } // namespace Caps + + extern Caps::GLESCaps g_glesCaps; GL_FUNC_DECL(glActiveTexture) GL_FUNC_DECL(glAttachShader)