Only use KHR_debug if available

This commit is contained in:
Magnus Norddahl 2016-08-22 19:25:13 +02:00
parent 250be72939
commit 1594cc9570
4 changed files with 20 additions and 6 deletions

View file

@ -49,7 +49,14 @@
#include <signal.h> #include <signal.h>
#endif #endif
CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CUSTOM_CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (!FGLDebug::HasDebugApi())
{
Printf("No OpenGL debug support detected.\n");
}
}
CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -60,6 +67,9 @@ CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
void FGLDebug::Update() void FGLDebug::Update()
{ {
if (!HasDebugApi())
return;
SetupBreakpointMode(); SetupBreakpointMode();
UpdateLoggingLevel(); UpdateLoggingLevel();
OutputMessageLog(); OutputMessageLog();
@ -74,7 +84,7 @@ void FGLDebug::Update()
void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name) void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name)
{ {
if (gl_debug_level != 0) if (HasDebugApi() && gl_debug_level != 0)
{ {
glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars()); glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars());
} }
@ -82,7 +92,7 @@ void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name)
void FGLDebug::LabelObjectPtr(void *ptr, const FString &name) void FGLDebug::LabelObjectPtr(void *ptr, const FString &name)
{ {
if (gl_debug_level != 0) if (HasDebugApi() && gl_debug_level != 0)
{ {
glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars()); glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars());
} }
@ -97,7 +107,7 @@ void FGLDebug::LabelObjectPtr(void *ptr, const FString &name)
void FGLDebug::PushGroup(const FString &name) void FGLDebug::PushGroup(const FString &name)
{ {
if (gl_debug_level != 0) if (HasDebugApi() && gl_debug_level != 0)
{ {
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars()); glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars());
} }
@ -105,7 +115,7 @@ void FGLDebug::PushGroup(const FString &name)
void FGLDebug::PopGroup() void FGLDebug::PopGroup()
{ {
if (gl_debug_level != 0) if (HasDebugApi() && gl_debug_level != 0)
{ {
glPopDebugGroup(); glPopDebugGroup();
} }

View file

@ -17,6 +17,8 @@ public:
static void PushGroup(const FString &name); static void PushGroup(const FString &name);
static void PopGroup(); static void PopGroup();
static bool HasDebugApi() { return (gl.flags & RFL_DEBUG) != 0; }
private: private:
void SetupBreakpointMode(); void SetupBreakpointMode();
void UpdateLoggingLevel(); void UpdateLoggingLevel();

View file

@ -253,6 +253,7 @@ void gl_LoadExtensions()
} }
if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
if (gl.version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG;
const char *lm = Args->CheckValue("-lightmethod"); const char *lm = Args->CheckValue("-lightmethod");
if (lm != NULL) if (lm != NULL)

View file

@ -25,7 +25,8 @@ enum RenderFlags
RFL_NO_DEPTHSTENCIL = 64, RFL_NO_DEPTHSTENCIL = 64,
RFL_NO_CLIP_PLANES = 128, RFL_NO_CLIP_PLANES = 128,
RFL_INVALIDATE_BUFFER = 256 RFL_INVALIDATE_BUFFER = 256,
RFL_DEBUG = 512
}; };
enum TexMode enum TexMode