From 39145252e34b9aec6ee7d2b17c9bd05d0ed30817 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 11 Oct 2015 11:46:24 +0200 Subject: [PATCH] Windows: Add the ability to turn on GL_ARB_debug_output via a hidden config option --- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/EmuScreen.cpp | 4 ++++ Windows/OpenGLBase.cpp | 21 +++++++++++++++------ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 1892c4a68a..153ad839f6 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -467,6 +467,7 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("DisableSlowFramebufEffects", &g_Config.bDisableSlowFramebufEffects, false, true, true), ReportedConfigSetting("FragmentTestCache", &g_Config.bFragmentTestCache, true, true, true), + ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, false, false), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index e360488880..a6a5532bb4 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -193,6 +193,7 @@ public: bool bFragmentTestCache; int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High std::string sPostShaderName; // Off for off. + bool bGfxDebugOutput; // Sound bool bEnableSound; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 7852d279ec..59e1792a83 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -157,6 +157,10 @@ void EmuScreen::bootComplete() { } else if (strstr(renderer, "GLTools") != 0) { osm.Show(sc->T("GLToolsWarning", "WARNING: GLTools detected, may cause problems"), 10.0f, 0xFF30a0FF, -1, true); } + + if (g_Config.bGfxDebugOutput) { + osm.Show("WARNING: GfxDebugOutput is enabled via ppsspp.ini. Things may be slow.", 10.0f, 0xFF30a0FF, -1, true); + } } System_SendMessage("event", "startgame"); diff --git a/Windows/OpenGLBase.cpp b/Windows/OpenGLBase.cpp index 7412269e15..7f387ddbec 100644 --- a/Windows/OpenGLBase.cpp +++ b/Windows/OpenGLBase.cpp @@ -26,6 +26,7 @@ #include "Core/Config.h" #include "util/text/utf8.h" #include "i18n/i18n.h" +#include "UI/OnScreenDisplay.h" #include "Windows/W32Util/Misc.h" #include "Windows/OpenGLBase.h" @@ -40,9 +41,6 @@ static HANDLE resumeEvent; static int xres, yres; -// TODO: Make config? -static bool enableGLDebug = false; - void GL_SwapBuffers() { SwapBuffers(hDC); @@ -135,7 +133,7 @@ void DebugCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity, char finalMessage[256]; FormatDebugOutputARB(finalMessage, 256, source, type, id, severity, message); OutputDebugStringA(finalMessage); - ERROR_LOG(G3D, "GL: %s", finalMessage); + NOTICE_LOG(G3D, "GL: %s", finalMessage); } bool GL_Init(HWND window, std::string *error_message) { @@ -246,7 +244,7 @@ bool GL_Init(HWND window, std::string *error_message) { CheckGLExtensions(); - int contextFlags = enableGLDebug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0; + int contextFlags = g_Config.bGfxDebugOutput ? WGL_CONTEXT_DEBUG_BIT_ARB : 0; // Alright, now for the modernity. First try a 4.4, then 4.3, context, if that fails try 3.3. // I can't seem to find a way that lets you simply request the newest version available. @@ -307,9 +305,20 @@ bool GL_Init(HWND window, std::string *error_message) { GL_SwapInterval(0); - if (enableGLDebug && glewIsSupported("GL_ARB_debug_output")) { + // TODO: Also support GL_KHR_debug which might be more widely supported? + if (g_Config.bGfxDebugOutput && glewIsSupported("GL_ARB_debug_output")) { + glGetError(); glDebugMessageCallbackARB((GLDEBUGPROCARB)&DebugCallbackARB, 0); // print debug output to stderr + if (glGetError()) { + ERROR_LOG(G3D, "Failed to register a debug log callback"); + } glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + if (glGetError()) { + ERROR_LOG(G3D, "Failed to enable synchronous debug output"); + } + + // For extra verbosity uncomment this (MEDIUM and HIGH are on by default): + // glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, nullptr, GL_TRUE); } pauseRequested = false;