mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 20:28:32 +09:00
[Improvement] (...): Log more info.
Signed-off-by: BZLZHH <admin@bzlzhh.top>
This commit is contained in:
+4
-4
@@ -9,11 +9,11 @@
|
||||
|
||||
namespace MG_Global {
|
||||
namespace MG {
|
||||
inline const int VersionMajor = 0;
|
||||
inline const int VersionMajor = 1;
|
||||
inline const int VersionMinor = 0;
|
||||
inline const int VersionRevision = 1;
|
||||
inline const int VersionRevision = 0;
|
||||
inline const int VersionPatch = 0;
|
||||
inline const std::string VersionSuffix = "";
|
||||
inline const std::string VersionSuffix = "-Dev";
|
||||
}
|
||||
|
||||
namespace Backend {
|
||||
@@ -27,7 +27,7 @@ namespace MG_Global {
|
||||
}
|
||||
|
||||
namespace Common {
|
||||
inline const int LogLevel = MG_Constants::Common::LOG_LEVEL_DEBUG;
|
||||
inline const int LogLevel = MG_Constants::Common::LOG_LEVEL_INFO;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
inline const char* LOG_FILE_PATH = "/sdcard/MG/latest.log";
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#ifndef MOBILEGL_DEBUG_H
|
||||
#include "MG_UTIL/Debug/Debug.h"
|
||||
#endif
|
||||
#ifndef MOBILEGL_MESAEMU_H
|
||||
#include "MG_GL/TEMP_MESA/MesaEmu.h"
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
@@ -31,6 +34,10 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@
|
||||
#include "Includes.h"
|
||||
|
||||
__attribute__((constructor)) void MG_Initialize() {
|
||||
MG_Util::Debug::LogI("MobileGL Initializing...");
|
||||
MG_Util::Debug::LogInit();
|
||||
MG_Util::Debug::LogI("MobileGL Initializing...");
|
||||
}
|
||||
@@ -8,12 +8,82 @@ namespace MG_GL::Getter {
|
||||
const std::string GetBackendName() {
|
||||
#if BACKEND_TYPE == BACKEND_VULKAN
|
||||
return "Vulkan";
|
||||
#elif BACKEND_TYPE == BACKEND_VULKAN
|
||||
#elif BACKEND_TYPE == BACKEND_METAL
|
||||
return "Metal";
|
||||
#elif BACKEND_TYPE == BACKEND_VULKAN
|
||||
#elif BACKEND_TYPE == BACKEND_GLES
|
||||
return "OpenGL ES";
|
||||
#else
|
||||
return "<Unknown Backend>";
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string GetMGName() {
|
||||
#if BACKEND_TYPE == BACKEND_VULKAN
|
||||
return "MobileGLUVK";
|
||||
#elif BACKEND_TYPE == BACKEND_METAL
|
||||
return "MobileGLUMTL";
|
||||
#elif BACKEND_TYPE == BACKEND_GLES
|
||||
return "MobileGLUES";
|
||||
#else
|
||||
return "<Unknown MobileGL Version>";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LogMGInfo() {
|
||||
std::string MGName = MG_GL::Getter::GetMGName()+
|
||||
", MobileGL (" + MG_GL::Getter::GetBackendName() + ")";
|
||||
|
||||
std::string MGVersion = std::to_string(MG_Global::MG::VersionMajor) + "."
|
||||
+ std::to_string(MG_Global::MG::VersionMinor) + "."
|
||||
+ std::to_string(MG_Global::MG::VersionRevision);
|
||||
if (MG_Global::MG::VersionPatch != 0)
|
||||
MGVersion += "." + std::to_string(MG_Global::MG::VersionPatch);
|
||||
MGVersion += MG_Global::MG::VersionSuffix;
|
||||
|
||||
std::string GLVersion = std::to_string(MG_Global::GL::GLVersionMajor) + "."
|
||||
+ std::to_string(MG_Global::GL::GLVersionMinor) + "."
|
||||
+ std::to_string(MG_Global::GL::GLVersionRevision);
|
||||
|
||||
std::string backendVersion;
|
||||
#if BACKEND_TYPE == BACKEND_VULKAN
|
||||
VkApplicationInfo appInfo = {};
|
||||
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
appInfo.pApplicationName = "Vulkan Version Query";
|
||||
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||
appInfo.pEngineName = "No Engine";
|
||||
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||
appInfo.apiVersion = VK_API_VERSION_1_0;
|
||||
VkInstanceCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
createInfo.pApplicationInfo = &appInfo;
|
||||
VkInstance instance;
|
||||
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
|
||||
throw std::runtime_error("Failed to create Vulkan instance!");
|
||||
}
|
||||
uint32_t deviceCount = 0;
|
||||
vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);
|
||||
if (deviceCount == 0) {
|
||||
throw std::runtime_error("No Vulkan devices found!");
|
||||
}
|
||||
VkPhysicalDevice physicalDevice;
|
||||
vkEnumeratePhysicalDevices(instance, &deviceCount, &physicalDevice);
|
||||
VkPhysicalDeviceProperties deviceProperties;
|
||||
vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
|
||||
uint32_t major = VK_VERSION_MAJOR(deviceProperties.apiVersion);
|
||||
uint32_t minor = VK_VERSION_MINOR(deviceProperties.apiVersion);
|
||||
uint32_t patch = VK_VERSION_PATCH(deviceProperties.apiVersion);
|
||||
vkDestroyInstance(instance, nullptr);
|
||||
|
||||
backendVersion = "Vulkan " + std::to_string(major) + "." +
|
||||
std::to_string(minor)+"." + std::to_string(patch);
|
||||
#else
|
||||
backendVersion = "<Unknown Backend>";
|
||||
#endif
|
||||
|
||||
MG_Util::Debug::LogI("MobileGL Renderer Info:\n");
|
||||
MG_Util::Debug::LogI("----%s:", MGName.c_str());
|
||||
MG_Util::Debug::LogI("--------MobileGL Version: %s", MGVersion.c_str());
|
||||
MG_Util::Debug::LogI("--------Implemented OpenGL Version: %s", GLVersion.c_str());
|
||||
MG_Util::Debug::LogI("--------Backend Version: %s", backendVersion.c_str());
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
namespace MG_GL::Getter {
|
||||
const std::string GetBackendName();
|
||||
const std::string GetMGName();
|
||||
void LogMGInfo();
|
||||
}
|
||||
|
||||
#endif //MOBILEGL_BACKENDINFO_H
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
|
||||
namespace MG_GL::GL {
|
||||
static std::string rendererString;
|
||||
static bool loggedMGInfo;
|
||||
const GLubyte* GetString(GLenum name) {
|
||||
if (!loggedMGInfo) {
|
||||
loggedMGInfo = true;
|
||||
MG_GL::Getter::LogMGInfo();
|
||||
}
|
||||
MG_Util::Debug::LogD("glGetString, name: %s", MG_Util::Debug::GLEnumToString(name));
|
||||
switch (name) {
|
||||
case GL_VENDOR:
|
||||
@@ -17,8 +22,8 @@ namespace MG_GL::GL {
|
||||
versionStr == std::to_string(MG_Global::GL::GLVersionMajor) + "."
|
||||
+ std::to_string(MG_Global::GL::GLVersionMinor) + "."
|
||||
+ std::to_string(MG_Global::GL::GLVersionRevision)
|
||||
+ " MobileGL (" + MG_GL::Getter::GetBackendName() + ") ";
|
||||
|
||||
+ " "+ MG_GL::Getter::GetMGName()+
|
||||
", MobileGL (" + MG_GL::Getter::GetBackendName() + ") ";
|
||||
versionStr += std::to_string(MG_Global::MG::VersionMajor) + "."
|
||||
+ std::to_string(MG_Global::MG::VersionMinor) + "."
|
||||
+ std::to_string(MG_Global::MG::VersionRevision);
|
||||
|
||||
@@ -6,26 +6,6 @@
|
||||
|
||||
// Code From DeepSeek
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
struct OSMesaContextData {
|
||||
VkInstance instance = VK_NULL_HANDLE;
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||
VkDevice device = VK_NULL_HANDLE;
|
||||
VkQueue graphicsQueue = VK_NULL_HANDLE;
|
||||
VkImage targetImage = VK_NULL_HANDLE;
|
||||
VkImageView imageView = VK_NULL_HANDLE;
|
||||
VkCommandPool commandPool = VK_NULL_HANDLE;
|
||||
GLsizei currentWidth = 0;
|
||||
GLsizei currentHeight = 0;
|
||||
GLint packAlignment = 4;
|
||||
GLubyte* frontBuffer = nullptr;
|
||||
uint32_t queueFamilyIndex = 0;
|
||||
};
|
||||
static std::map<OSMesaContext, OSMesaContextData> ctxMap;
|
||||
static thread_local OSMesaContext currentContext = nullptr;
|
||||
static uint32_t findGraphicsQueueFamily(VkPhysicalDevice physicalDevice) {
|
||||
uint32_t queueFamilyCount = 0;
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
#include "../../Includes.h"
|
||||
|
||||
#endif //MOBILEGL_MESAEMU_H
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
*
|
||||
@@ -340,4 +338,23 @@ OSMesaPostprocess(OSMesaContext osmesa, const char *filter,
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct OSMesaContextData {
|
||||
VkInstance instance = VK_NULL_HANDLE;
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||
VkDevice device = VK_NULL_HANDLE;
|
||||
VkQueue graphicsQueue = VK_NULL_HANDLE;
|
||||
VkImage targetImage = VK_NULL_HANDLE;
|
||||
VkImageView imageView = VK_NULL_HANDLE;
|
||||
VkCommandPool commandPool = VK_NULL_HANDLE;
|
||||
GLsizei currentWidth = 0;
|
||||
GLsizei currentHeight = 0;
|
||||
GLint packAlignment = 4;
|
||||
GLubyte* frontBuffer = nullptr;
|
||||
uint32_t queueFamilyIndex = 0;
|
||||
};
|
||||
|
||||
static std::map<OSMesaContext, OSMesaContextData> ctxMap;
|
||||
|
||||
#endif //MOBILEGL_MESAEMU_H
|
||||
Reference in New Issue
Block a user