diff --git a/MG/Global.h b/MG/Global.h index c1edb85d..9b3c2fc5 100644 --- a/MG/Global.h +++ b/MG/Global.h @@ -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"; diff --git a/MG/Includes.h b/MG/Includes.h index ea509ffa..b8f29bcc 100644 --- a/MG/Includes.h +++ b/MG/Includes.h @@ -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 #include @@ -31,6 +34,10 @@ #include #include #include +#include +#include +#include +#include #ifdef __ANDROID__ #include diff --git a/MG/Init.cpp b/MG/Init.cpp index 1e26ec18..9b8847b0 100644 --- a/MG/Init.cpp +++ b/MG/Init.cpp @@ -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..."); } \ No newline at end of file diff --git a/MG/MG_GL/GL/Getter/BackendInfo.cpp b/MG/MG_GL/GL/Getter/BackendInfo.cpp index f8dde84e..4540fa15 100644 --- a/MG/MG_GL/GL/Getter/BackendInfo.cpp +++ b/MG/MG_GL/GL/Getter/BackendInfo.cpp @@ -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 ""; #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 ""; +#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 = ""; +#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()); + } } \ No newline at end of file diff --git a/MG/MG_GL/GL/Getter/BackendInfo.h b/MG/MG_GL/GL/Getter/BackendInfo.h index 679e7503..319c766e 100644 --- a/MG/MG_GL/GL/Getter/BackendInfo.h +++ b/MG/MG_GL/GL/Getter/BackendInfo.h @@ -9,6 +9,8 @@ namespace MG_GL::Getter { const std::string GetBackendName(); + const std::string GetMGName(); + void LogMGInfo(); } #endif //MOBILEGL_BACKENDINFO_H diff --git a/MG/MG_GL/GL/Getter/GL_Getter.cpp b/MG/MG_GL/GL/Getter/GL_Getter.cpp index f69eda9b..5f9e7b3f 100644 --- a/MG/MG_GL/GL/Getter/GL_Getter.cpp +++ b/MG/MG_GL/GL/Getter/GL_Getter.cpp @@ -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); diff --git a/MG/MG_GL/TEMP_MESA/MesaEmu.cpp b/MG/MG_GL/TEMP_MESA/MesaEmu.cpp index d07885f2..f0f006dc 100644 --- a/MG/MG_GL/TEMP_MESA/MesaEmu.cpp +++ b/MG/MG_GL/TEMP_MESA/MesaEmu.cpp @@ -6,26 +6,6 @@ // Code From DeepSeek -#include -#include -#include -#include -#include -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 ctxMap; static thread_local OSMesaContext currentContext = nullptr; static uint32_t findGraphicsQueueFamily(VkPhysicalDevice physicalDevice) { uint32_t queueFamilyCount = 0; diff --git a/MG/MG_GL/TEMP_MESA/MesaEmu.h b/MG/MG_GL/TEMP_MESA/MesaEmu.h index ce5e040f..e0859707 100644 --- a/MG/MG_GL/TEMP_MESA/MesaEmu.h +++ b/MG/MG_GL/TEMP_MESA/MesaEmu.h @@ -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 \ No newline at end of file +#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 ctxMap; + +#endif //MOBILEGL_MESAEMU_H \ No newline at end of file