diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index f58c47ddb..4ca841977 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -365,30 +365,24 @@ bool GPU_GLES::IsReady() { return shaderManagerGL_->ContinuePrecompile(); } -// Let's avoid passing nulls into snprintf(). -static const char *GetGLStringAlways(GLenum name) { - const GLubyte *value = glGetString(name); - if (!value) - return "?"; - return (const char *)value; -} - // Needs to be called on GPU thread, not reporting thread. void GPU_GLES::BuildReportingInfo() { - const char *glVendor = GetGLStringAlways(GL_VENDOR); - const char *glRenderer = GetGLStringAlways(GL_RENDERER); - const char *glVersion = GetGLStringAlways(GL_VERSION); - const char *glSlVersion = GetGLStringAlways(GL_SHADING_LANGUAGE_VERSION); - const char *glExtensions = nullptr; + GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); + + std::string glVendor = render->GetGLString(GL_VENDOR); + std::string glRenderer = render->GetGLString(GL_RENDERER); + std::string glVersion = render->GetGLString(GL_VERSION); + std::string glSlVersion = render->GetGLString(GL_SHADING_LANGUAGE_VERSION); + std::string glExtensions; if (gl_extensions.VersionGEThan(3, 0)) { - glExtensions = g_all_gl_extensions.c_str(); + glExtensions = g_all_gl_extensions; } else { - glExtensions = GetGLStringAlways(GL_EXTENSIONS); + glExtensions = render->GetGLString(GL_EXTENSIONS); } char temp[16384]; - snprintf(temp, sizeof(temp), "%s (%s %s), %s (extensions: %s)", glVersion, glVendor, glRenderer, glSlVersion, glExtensions); + snprintf(temp, sizeof(temp), "%s (%s %s), %s (extensions: %s)", glVersion.c_str(), glVendor.c_str(), glRenderer.c_str(), glSlVersion.c_str(), glExtensions.c_str()); reportingPrimaryInfo_ = glVendor; reportingFullInfo_ = temp; diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index 83820ff7e..a7072931b 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -26,6 +26,20 @@ void GLQueueRunner::CreateDeviceObjects() { // An eternal optimist. sawOutOfMemory_ = false; + + // Populate some strings from the GL thread. + auto populate = [&](int name) { + const GLubyte *value = glGetString(name); + if (!value) + glStrings_[name] = "?"; + else + glStrings_[name] = (const char *)value; + }; + populate(GL_VENDOR); + populate(GL_RENDERER); + populate(GL_VERSION); + populate(GL_SHADING_LANGUAGE_VERSION); + populate(GL_EXTENSIONS); } void GLQueueRunner::DestroyDeviceObjects() { diff --git a/ext/native/thin3d/GLQueueRunner.h b/ext/native/thin3d/GLQueueRunner.h index e04f2f495..511e3425a 100644 --- a/ext/native/thin3d/GLQueueRunner.h +++ b/ext/native/thin3d/GLQueueRunner.h @@ -2,6 +2,7 @@ #include #include +#include #include "gfx/gl_common.h" #include "thin3d/DataFormat.h" @@ -332,6 +333,12 @@ public: bool SawOutOfMemory() { return sawOutOfMemory_; } + + std::string GetGLString(int name) const { + auto it = glStrings_.find(name); + return it != glStrings_.end() ? it->second : ""; + } + private: void InitCreateFramebuffer(const GLRInitStep &step); @@ -378,6 +385,7 @@ private: GLuint AllocTextureName(); // Texture name cache. Ripped straight from TextureCacheGLES. std::vector nameCache_; + std::unordered_map glStrings_; bool sawOutOfMemory_ = false; }; diff --git a/ext/native/thin3d/GLRenderManager.h b/ext/native/thin3d/GLRenderManager.h index 703cda773..6bd2d7caf 100644 --- a/ext/native/thin3d/GLRenderManager.h +++ b/ext/native/thin3d/GLRenderManager.h @@ -660,6 +660,11 @@ public: return queueRunner_.SawOutOfMemory(); } + // Only supports a common subset. + std::string GetGLString(int name) const { + return queueRunner_.GetGLString(name); + } + private: void BeginSubmitFrame(int frame); void EndSubmitFrame(int frame); diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index a16411fbe..b831e199a 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -435,7 +435,7 @@ public: } else { return "OpenGL"; } - case VENDORSTRING: return (const char *)glGetString(GL_VENDOR); + case VENDORSTRING: return renderManager_.GetGLString(GL_VENDOR); case VENDOR: switch (caps_.vendor) { case GPUVendor::VENDOR_AMD: return "VENDOR_AMD"; @@ -450,9 +450,9 @@ public: return "VENDOR_UNKNOWN"; } break; - case DRIVER: return (const char *)glGetString(GL_RENDERER); - case SHADELANGVERSION: return (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); - case APIVERSION: return (const char *)glGetString(GL_VERSION); + case DRIVER: return renderManager_.GetGLString(GL_RENDERER); + case SHADELANGVERSION: return renderManager_.GetGLString(GL_SHADING_LANGUAGE_VERSION); + case APIVERSION: return renderManager_.GetGLString(GL_VERSION); default: return "?"; } }