From 9f2d13a2b65ca42b553e71af0747fc24d9aecc15 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 21 Feb 2024 18:58:42 +0100 Subject: [PATCH] OpenGL: Print more debug info at init time --- source/Irrlicht/OpenGL/Driver.cpp | 19 ++++++++++++++++++- source/Irrlicht/OpenGL/Driver.h | 3 ++- source/Irrlicht/OpenGL/ExtensionHandler.cpp | 14 ++++++++++---- source/Irrlicht/OpenGL/ExtensionHandler.h | 4 ++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/source/Irrlicht/OpenGL/Driver.cpp b/source/Irrlicht/OpenGL/Driver.cpp index e030b4ed..985c5c1e 100644 --- a/source/Irrlicht/OpenGL/Driver.cpp +++ b/source/Irrlicht/OpenGL/Driver.cpp @@ -205,7 +205,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase() // print renderer information VendorName = GL.GetString(GL_VENDOR); - os::Printer::log(VendorName.c_str(), ELL_INFORMATION); + os::Printer::log("Vendor", VendorName.c_str(), ELL_INFORMATION); Version = getVersionFromOpenGL(); } @@ -222,6 +222,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase() { initVersion(); initFeatures(); + printTextureFormats(); // reset cache handler delete CacheHandler; @@ -276,6 +277,22 @@ COpenGL3DriverBase::~COpenGL3DriverBase() return true; } + void COpenGL3DriverBase::printTextureFormats() + { + char buf[128]; + for (u32 i = 0; i < static_cast(ECF_UNKNOWN); i++) { + auto &info = TextureFormats[i]; + if (!info.InternalFormat) { + snprintf_irr(buf, sizeof(buf), "%s -> unsupported", ColorFormatNames[i]); + } else { + snprintf_irr(buf, sizeof(buf), "%s -> %#06x %#06x %#06x%s", + ColorFormatNames[i], info.InternalFormat, info.PixelFormat, + info.PixelType, info.Converter ? " (c)" : ""); + } + os::Printer::log(buf, ELL_DEBUG); + } + } + void COpenGL3DriverBase::loadShaderData(const io::path& vertexShaderName, const io::path& fragmentShaderName, c8** vertexShaderData, c8** fragmentShaderData) { io::path vsPath(OGLES2ShaderPath); diff --git a/source/Irrlicht/OpenGL/Driver.h b/source/Irrlicht/OpenGL/Driver.h index 01db87f7..1b5a8e85 100644 --- a/source/Irrlicht/OpenGL/Driver.h +++ b/source/Irrlicht/OpenGL/Driver.h @@ -272,7 +272,6 @@ namespace video COpenGL3CacheHandler* getCacheHandler() const; protected: - //! inits the opengl-es driver virtual bool genericDriverInit(const core::dimension2d& screenSize, bool stencilBuffer); void initVersion(); @@ -391,6 +390,8 @@ private: IContextManager* ContextManager; + void printTextureFormats(); + void addDummyMaterial(E_MATERIAL_TYPE type); unsigned QuadIndexCount; diff --git a/source/Irrlicht/OpenGL/ExtensionHandler.cpp b/source/Irrlicht/OpenGL/ExtensionHandler.cpp index 6b2c0384..594fa4a2 100644 --- a/source/Irrlicht/OpenGL/ExtensionHandler.cpp +++ b/source/Irrlicht/OpenGL/ExtensionHandler.cpp @@ -9,8 +9,11 @@ #include "irrString.h" #include "SMaterial.h" #include "fast_atof.h" +#include "os.h" #include +// FIXME: this basically duplicates what mt_opengl.h already does + namespace irr { namespace video @@ -24,7 +27,7 @@ namespace video pos = next + 1; } addExtension(pos); - updateLegacyExtensionList(); + extensionsLoaded(); } void COpenGL3ExtensionHandler::initExtensionsNew() @@ -32,10 +35,10 @@ namespace video int ext_count = GetInteger(GL_NUM_EXTENSIONS); for (int k = 0; k < ext_count; k++) addExtension(reinterpret_cast(GL.GetStringi(GL_EXTENSIONS, k))); - updateLegacyExtensionList(); + extensionsLoaded(); } - void COpenGL3ExtensionHandler::addExtension(std::string name) { + void COpenGL3ExtensionHandler::addExtension(std::string &&name) { Extensions.emplace(std::move(name)); } @@ -43,7 +46,10 @@ namespace video return Extensions.find(name) != Extensions.end(); } - void COpenGL3ExtensionHandler::updateLegacyExtensionList() { + void COpenGL3ExtensionHandler::extensionsLoaded() { + os::Printer::log((std::string("Loaded ") + std::to_string(Extensions.size()) + " extensions:").c_str(), ELL_DEBUG); + for (const auto &it : Extensions) + os::Printer::log((std::string(" ") + it).c_str(), ELL_DEBUG); for (size_t j = 0; j < IRR_OGLES_Feature_Count; ++j) FeatureAvailable[j] = queryExtension(getFeatureString(j)); } diff --git a/source/Irrlicht/OpenGL/ExtensionHandler.h b/source/Irrlicht/OpenGL/ExtensionHandler.h index a6a7963b..5b6420a5 100644 --- a/source/Irrlicht/OpenGL/ExtensionHandler.h +++ b/source/Irrlicht/OpenGL/ExtensionHandler.h @@ -159,8 +159,8 @@ namespace video bool BlendMinMaxSupported = false; private: - void addExtension(std::string name); - void updateLegacyExtensionList(); + void addExtension(std::string &&name); + void extensionsLoaded(); std::unordered_set Extensions; };