mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 12:18:30 +09:00
[Improvement] (Getter): better glGetString with GPU name
This commit is contained in:
@@ -701,6 +701,22 @@ namespace MG_EGL::Diligent {
|
||||
if (MG_Diligent::g_pDevice && MG_Diligent::g_pContext) {
|
||||
MG_Util::Debug::LogD("Vulkan device created: device=%p, context=%p",
|
||||
MG_Diligent::g_pDevice, MG_Diligent::g_pContext);
|
||||
auto version = MG_Diligent::g_pDevice->GetDeviceInfo().APIVersion;
|
||||
std::string apiVersion;
|
||||
switch (MG_Diligent::DILIGENT_BACKEND_TYPE) {
|
||||
case MG_Constants::Backend::BACKEND_DILIGENT_VULKAN:
|
||||
apiVersion = std::format("Vulkan {}.{}", version.Major, version.Minor);
|
||||
break;
|
||||
case MG_Constants::Backend::BACKEND_DILIGENT_METAL:
|
||||
apiVersion = std::format("Metal {}.{}", version.Major, version.Minor);
|
||||
break;
|
||||
case MG_Constants::Backend::BACKEND_DILIGENT_OPENGL:
|
||||
apiVersion = std::format("OpenGL {}.{}", version.Major, version.Minor);
|
||||
break;
|
||||
default:
|
||||
apiVersion = "<unknown>";
|
||||
}
|
||||
MG_Util::Debug::LogD("Running on %s, %s", MG_Diligent::g_pDevice->GetAdapterInfo().Description, apiVersion.c_str());
|
||||
} else {
|
||||
MG_Util::Debug::LogE("Failed to create Vulkan device");
|
||||
}
|
||||
|
||||
@@ -51,6 +51,53 @@ namespace MG_GL::Getter {
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string GetBackendGfxAPIName() {
|
||||
#if BACKEND_TYPE == BACKEND_VULKAN
|
||||
return "Vulkan";
|
||||
#elif BACKEND_TYPE == BACKEND_METAL
|
||||
return "Metal";
|
||||
#elif BACKEND_TYPE == BACKEND_GLES
|
||||
return "OpenGL ES";
|
||||
#elif BACKEND_TYPE == BACKEND_DILIGENT
|
||||
switch (MG_Diligent::DILIGENT_BACKEND_TYPE) {
|
||||
case MG_Constants::Backend::BACKEND_DILIGENT_VULKAN:
|
||||
return "Vulkan";
|
||||
case MG_Constants::Backend::BACKEND_DILIGENT_METAL:
|
||||
return "Metal";
|
||||
case MG_Constants::Backend::BACKEND_DILIGENT_OPENGL:
|
||||
return "OpenGL";
|
||||
default:
|
||||
return "<unknown>";
|
||||
}
|
||||
#else
|
||||
return "<Unknown Backend>";
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string GetGPUName() {
|
||||
#if BACKEND_TYPE == BACKEND_DILIGENT
|
||||
return MG_Diligent::g_pDevice->GetAdapterInfo().Description;
|
||||
#else
|
||||
return "<unknown GPU>";
|
||||
#endif
|
||||
}
|
||||
|
||||
const uint32_t GetBackendGfxAPIVersionMajor() {
|
||||
#if BACKEND_TYPE == BACKEND_DILIGENT
|
||||
return MG_Diligent::g_pDevice->GetDeviceInfo().APIVersion.Major;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
const uint32_t GetBackendGfxAPIVersionMinor() {
|
||||
#if BACKEND_TYPE == BACKEND_DILIGENT
|
||||
return MG_Diligent::g_pDevice->GetDeviceInfo().APIVersion.Minor;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LogMGInfo() {
|
||||
std::string MGName = MG_GL::Getter::GetMGName() + " (MobileGL Core)";
|
||||
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
#include "../../../../Includes.h"
|
||||
|
||||
namespace MG_GL::Getter {
|
||||
const std::string GetGPUName();
|
||||
const std::string GetBackendName();
|
||||
const std::string GetBackendGfxAPIName();
|
||||
const uint32_t GetBackendGfxAPIVersionMajor();
|
||||
const uint32_t GetBackendGfxAPIVersionMinor();
|
||||
const std::string GetMGName();
|
||||
void LogMGInfo();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace MG_GL::GL {
|
||||
MG_Util::Debug::LogD("glGetString, name: %s", MG_Util::Debug::GLEnumToString(name));
|
||||
switch (name) {
|
||||
case GL_VENDOR:
|
||||
return (const GLubyte *)"MobileGL-Dev";
|
||||
return (const GLubyte *)"MobileGL-Dev (BZLZHH, Swung0x48, Tungsten)";
|
||||
case GL_VERSION: {
|
||||
static std::string versionStr;
|
||||
if (versionStr.empty()) {
|
||||
@@ -44,7 +44,11 @@ namespace MG_GL::GL {
|
||||
}
|
||||
return (const GLubyte *)rendererString.c_str();
|
||||
*/
|
||||
return (const GLubyte *)(MG_GL::Getter::GetMGName() + " (MobileGL Core) Renderer").c_str();
|
||||
return (const GLubyte *)std::format("{} | {} {}.{}",
|
||||
MG_GL::Getter::GetGPUName(),
|
||||
MG_GL::Getter::GetBackendGfxAPIName(),
|
||||
MG_GL::Getter::GetBackendGfxAPIVersionMajor(),
|
||||
MG_GL::Getter::GetBackendGfxAPIVersionMinor()).c_str();
|
||||
}
|
||||
case GL_SHADING_LANGUAGE_VERSION:
|
||||
return (const GLubyte *) "4.50 MobileGL with glslang";
|
||||
|
||||
Reference in New Issue
Block a user