mirror of
https://github.com/minetest/minetest.git
synced 2025-01-08 22:37:32 +01:00
Expose OpenGL debugging as a normal setting
This commit is contained in:
parent
ecfe9c5c2f
commit
7a6ca85081
@ -1893,6 +1893,9 @@ texture_min_size (Base texture size) int 64 1 32768
|
||||
# Systems with a low-end GPU (or no GPU) would benefit from smaller values.
|
||||
client_mesh_chunk (Client Mesh Chunksize) int 1 1 16
|
||||
|
||||
# Enables debug and error-checking in the OpenGL driver.
|
||||
opengl_debug (OpenGL debug) bool false
|
||||
|
||||
[**Sound]
|
||||
# Comma-separated list of AL and ALC extensions that should not be used.
|
||||
# Useful for testing. See al_extensions.[h,cpp] for details.
|
||||
|
@ -45,10 +45,11 @@ struct SIrrlichtCreationParameters
|
||||
#endif
|
||||
PrivateData(0),
|
||||
#ifdef IRR_MOBILE_PATHS
|
||||
OGLES2ShaderPath("media/Shaders/")
|
||||
OGLES2ShaderPath("media/Shaders/"),
|
||||
#else
|
||||
OGLES2ShaderPath("../../media/Shaders/")
|
||||
OGLES2ShaderPath("../../media/Shaders/"),
|
||||
#endif
|
||||
DriverDebug(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -224,6 +225,9 @@ struct SIrrlichtCreationParameters
|
||||
/** This is about the shaders which can be found in media/Shaders by default. It's only necessary
|
||||
to set when using OGL-ES 2.0 */
|
||||
irr::io::path OGLES2ShaderPath;
|
||||
|
||||
//! Enable debug and error checks in video driver.
|
||||
bool DriverDebug;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
@ -529,7 +529,8 @@ bool CEGLManager::swapBuffers()
|
||||
|
||||
bool CEGLManager::testEGLError()
|
||||
{
|
||||
#if defined(EGL_VERSION_1_0) && defined(_DEBUG)
|
||||
if (!Params.DriverDebug)
|
||||
return false;
|
||||
EGLint status = eglGetError();
|
||||
|
||||
switch (status) {
|
||||
@ -582,9 +583,6 @@ bool CEGLManager::testEGLError()
|
||||
};
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -388,6 +388,16 @@ bool CIrrDeviceSDL::createWindow()
|
||||
if (createWindowWithContext())
|
||||
return true;
|
||||
|
||||
if (CreationParams.DriverDebug) {
|
||||
CreationParams.DriverDebug = false;
|
||||
if (createWindowWithContext()) {
|
||||
os::Printer::log("DriverDebug reduced due to lack of support!");
|
||||
// Turn it back on because the GL driver can maybe still do something useful.
|
||||
CreationParams.DriverDebug = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
while (CreationParams.AntiAlias > 0) {
|
||||
CreationParams.AntiAlias--;
|
||||
if (createWindowWithContext()) {
|
||||
@ -449,7 +459,8 @@ bool CIrrDeviceSDL::createWindow()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CIrrDeviceSDL::createWindowWithContext() {
|
||||
bool CIrrDeviceSDL::createWindowWithContext()
|
||||
{
|
||||
u32 SDL_Flags = 0;
|
||||
|
||||
if (CreationParams.Fullscreen) {
|
||||
@ -465,6 +476,8 @@ bool CIrrDeviceSDL::createWindowWithContext() {
|
||||
SDL_Flags |= SDL_WINDOW_MAXIMIZED;
|
||||
SDL_Flags |= SDL_WINDOW_OPENGL;
|
||||
|
||||
SDL_GL_ResetAttributes();
|
||||
|
||||
#ifdef _IRR_EMSCRIPTEN_PLATFORM_
|
||||
if (Width != 0 || Height != 0)
|
||||
emscripten_set_canvas_size(Width, Height);
|
||||
@ -528,13 +541,9 @@ bool CIrrDeviceSDL::createWindowWithContext() {
|
||||
default:;
|
||||
}
|
||||
|
||||
/*
|
||||
Makes context creation fail on some Android devices.
|
||||
See discussion in https://github.com/minetest/minetest/pull/14498.
|
||||
#ifdef _DEBUG
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
|
||||
#endif
|
||||
*/
|
||||
if (CreationParams.DriverDebug) {
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
|
||||
}
|
||||
|
||||
if (CreationParams.Bits == 16) {
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
|
@ -1177,7 +1177,9 @@ void COGLES1Driver::setMaterial(const SMaterial &material)
|
||||
//! prints error if an error happened.
|
||||
bool COGLES1Driver::testGLError(int code)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (!Params.DriverDebug)
|
||||
return false;
|
||||
|
||||
GLenum g = glGetError();
|
||||
switch (g) {
|
||||
case GL_NO_ERROR:
|
||||
@ -1201,11 +1203,7 @@ bool COGLES1Driver::testGLError(int code)
|
||||
os::Printer::log("GL_OUT_OF_MEMORY", core::stringc(code).c_str(), ELL_ERROR);
|
||||
break;
|
||||
};
|
||||
// _IRR_DEBUG_BREAK_IF(true);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//! sets the needed renderstates
|
||||
|
@ -1642,7 +1642,9 @@ void COpenGLDriver::setMaterial(const SMaterial &material)
|
||||
//! prints error if an error happened.
|
||||
bool COpenGLDriver::testGLError(int code)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (!Params.DriverDebug)
|
||||
return false;
|
||||
|
||||
GLenum g = glGetError();
|
||||
switch (g) {
|
||||
case GL_NO_ERROR:
|
||||
@ -1674,11 +1676,7 @@ bool COpenGLDriver::testGLError(int code)
|
||||
break;
|
||||
#endif
|
||||
};
|
||||
// _IRR_DEBUG_BREAK_IF(true);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//! sets the needed renderstates
|
||||
|
@ -179,9 +179,8 @@ bool CWGLManager::initialize(const SIrrlichtCreationParameters ¶ms, const SE
|
||||
const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1);
|
||||
const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) ||
|
||||
(wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1));
|
||||
#ifdef _DEBUG
|
||||
os::Printer::log("WGL_extensions", wglExtensions);
|
||||
#endif
|
||||
if (params.DriverDebug)
|
||||
os::Printer::log("WGL_extensions", wglExtensions);
|
||||
|
||||
// Without a GL context we can't call wglGetProcAddress so store this for later
|
||||
FunctionPointers[0] = (void *)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
|
@ -143,7 +143,7 @@ COpenGL3DriverBase::COpenGL3DriverBase(const SIrrlichtCreationParameters ¶ms
|
||||
MaterialRenderer2DActive(0), MaterialRenderer2DTexture(0), MaterialRenderer2DNoTexture(0),
|
||||
CurrentRenderMode(ERM_NONE), Transformation3DChanged(true),
|
||||
OGLES2ShaderPath(params.OGLES2ShaderPath),
|
||||
ColorFormat(ECF_R8G8B8), ContextManager(contextManager)
|
||||
ColorFormat(ECF_R8G8B8), ContextManager(contextManager), EnableErrorTest(params.DriverDebug)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("Driver");
|
||||
@ -158,7 +158,10 @@ COpenGL3DriverBase::COpenGL3DriverBase(const SIrrlichtCreationParameters ¶ms
|
||||
ExposedData = ContextManager->getContext();
|
||||
ContextManager->activateContext(ExposedData, false);
|
||||
GL.LoadAllProcedures(ContextManager);
|
||||
GL.DebugMessageCallback(debugCb, this);
|
||||
if (EnableErrorTest) {
|
||||
GL.Enable(GL_DEBUG_OUTPUT);
|
||||
GL.DebugMessageCallback(debugCb, this);
|
||||
}
|
||||
initQuadsIndices();
|
||||
}
|
||||
|
||||
@ -1125,7 +1128,9 @@ void COpenGL3DriverBase::setMaterial(const SMaterial &material)
|
||||
//! prints error if an error happened.
|
||||
bool COpenGL3DriverBase::testGLError(int code)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (!EnableErrorTest)
|
||||
return false;
|
||||
|
||||
GLenum g = GL.GetError();
|
||||
switch (g) {
|
||||
case GL_NO_ERROR:
|
||||
@ -1144,66 +1149,6 @@ bool COpenGL3DriverBase::testGLError(int code)
|
||||
break;
|
||||
};
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//! prints error if an error happened.
|
||||
bool COpenGL3DriverBase::testEGLError()
|
||||
{
|
||||
#if defined(EGL_VERSION_1_0) && defined(_DEBUG)
|
||||
EGLint g = eglGetError();
|
||||
switch (g) {
|
||||
case EGL_SUCCESS:
|
||||
return false;
|
||||
case EGL_NOT_INITIALIZED:
|
||||
os::Printer::log("Not Initialized", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ACCESS:
|
||||
os::Printer::log("Bad Access", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ALLOC:
|
||||
os::Printer::log("Bad Alloc", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_ATTRIBUTE:
|
||||
os::Printer::log("Bad Attribute", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CONTEXT:
|
||||
os::Printer::log("Bad Context", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CONFIG:
|
||||
os::Printer::log("Bad Config", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_CURRENT_SURFACE:
|
||||
os::Printer::log("Bad Current Surface", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_DISPLAY:
|
||||
os::Printer::log("Bad Display", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_SURFACE:
|
||||
os::Printer::log("Bad Surface", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_MATCH:
|
||||
os::Printer::log("Bad Match", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_PARAMETER:
|
||||
os::Printer::log("Bad Parameter", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_NATIVE_PIXMAP:
|
||||
os::Printer::log("Bad Native Pixmap", ELL_ERROR);
|
||||
break;
|
||||
case EGL_BAD_NATIVE_WINDOW:
|
||||
os::Printer::log("Bad Native Window", ELL_ERROR);
|
||||
break;
|
||||
case EGL_CONTEXT_LOST:
|
||||
os::Printer::log("Context Lost", ELL_ERROR);
|
||||
break;
|
||||
};
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void COpenGL3DriverBase::setRenderStates3DMode()
|
||||
|
@ -224,9 +224,6 @@ public:
|
||||
//! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number)
|
||||
bool testGLError(int code = 0);
|
||||
|
||||
//! checks if an OGLES1 error has happened and prints it
|
||||
bool testEGLError();
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override;
|
||||
|
||||
@ -385,7 +382,7 @@ private:
|
||||
|
||||
void printTextureFormats();
|
||||
|
||||
void addDummyMaterial(E_MATERIAL_TYPE type);
|
||||
bool EnableErrorTest;
|
||||
|
||||
unsigned QuadIndexCount;
|
||||
GLuint QuadIndexBuffer = 0;
|
||||
|
@ -229,6 +229,7 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
|
||||
params.Stencilbuffer = false;
|
||||
params.Vsync = vsync;
|
||||
params.EventReceiver = receiver;
|
||||
params.DriverDebug = g_settings->getBool("opengl_debug");
|
||||
|
||||
// there is no standardized path for these on desktop
|
||||
std::string rel_path = std::string("client") + DIR_DELIM
|
||||
|
@ -114,7 +114,7 @@ void set_default_settings()
|
||||
settings->setDefault("keymap_toggle_hud", "KEY_F1");
|
||||
settings->setDefault("keymap_toggle_chat", "KEY_F2");
|
||||
settings->setDefault("keymap_toggle_fog", "KEY_F3");
|
||||
#if DEBUG
|
||||
#ifndef NDEBUG
|
||||
settings->setDefault("keymap_toggle_update_camera", "KEY_F4");
|
||||
#else
|
||||
settings->setDefault("keymap_toggle_update_camera", "");
|
||||
@ -174,8 +174,10 @@ void set_default_settings()
|
||||
// Visuals
|
||||
#ifdef NDEBUG
|
||||
settings->setDefault("show_debug", "false");
|
||||
settings->setDefault("opengl_debug", "false");
|
||||
#else
|
||||
settings->setDefault("show_debug", "true");
|
||||
settings->setDefault("opengl_debug", "true");
|
||||
#endif
|
||||
settings->setDefault("fsaa", "2");
|
||||
settings->setDefault("undersampling", "1");
|
||||
|
Loading…
Reference in New Issue
Block a user