[Feat] (MG_Util/BackendLoaders): Detect buffer storage extension.

This commit is contained in:
BZLZHH
2025-11-29 14:26:01 +08:00
parent 521bcadbee
commit 1a9f546309
3 changed files with 23 additions and 9 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ namespace MobileGL {
MGLOG_D("Diligent Engine backend loaded"); MGLOG_D("Diligent Engine backend loaded");
#elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES #elif MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
MG_Util::BackendLoader::GLES::Init(); MG_Util::BackendLoader::GLES::Init();
MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::Caps::GLESVersion.Major, MGLOG_D("DirectGLES backend loaded, GLES version: %d.%d", MG_External::GLES::g_glesCaps.version.Major,
MG_External::GLES::Caps::GLESVersion.Minor); MG_External::GLES::g_glesCaps.version.Minor);
#else #else
MGLOG_W("Unknown backend, skipping backend initialization"); MGLOG_W("Unknown backend, skipping backend initialization");
#endif #endif
@@ -6,9 +6,7 @@
namespace MobileGL { namespace MobileGL {
namespace MG_External { namespace MG_External {
namespace GLES { namespace GLES {
namespace Caps { Caps::GLESCaps g_glesCaps;
Version GLESVersion;
}
GL_FUNC_DECL(glActiveTexture) GL_FUNC_DECL(glActiveTexture)
GL_FUNC_DECL(glAttachShader) GL_FUNC_DECL(glAttachShader)
@@ -485,8 +483,19 @@ namespace MobileGL {
} }
void InitGLESCapabilities() { void InitGLESCapabilities() {
MG_External::GLES::glGetIntegerv(GL_MAJOR_VERSION, &MG_External::GLES::Caps::GLESVersion.Major); MG_External::GLES::glGetIntegerv(GL_MAJOR_VERSION, &MG_External::GLES::g_glesCaps.version.Major);
MG_External::GLES::glGetIntegerv(GL_MINOR_VERSION, &MG_External::GLES::Caps::GLESVersion.Minor); 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() { void InitGLES() {
@@ -547,8 +547,13 @@ namespace MobileGL {
namespace GLES { namespace GLES {
namespace Caps { 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(glActiveTexture)
GL_FUNC_DECL(glAttachShader) GL_FUNC_DECL(glAttachShader)