1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

gl: Rewrite Debug Output

Remove Windows restriction, enable Debug Output for every supported OS
Filter our severity by Khronos severity
Handle and log source and type enums
This commit is contained in:
AniLeo 2020-05-14 13:23:15 +01:00 committed by Ani
parent db4414ca87
commit 308cdfac35
2 changed files with 108 additions and 17 deletions

View File

@ -52,33 +52,119 @@ namespace gl
g_compute_tasks.clear(); g_compute_tasks.clear();
} }
#ifdef WIN32 // https://www.khronos.org/opengl/wiki/Debug_Output
void APIENTRY dbgFunc(GLenum source, GLenum type, GLuint id, void APIENTRY log_debug(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei lenght, const GLchar* message, GLenum severity, GLsizei length, const GLchar* message,
const void* userParam) const void* user_param)
{ {
// Message source
std::string str_source;
switch (source)
{
// Calls to the OpenGL API
case GL_DEBUG_SOURCE_API:
str_source = "API";
break;
// Calls to a window-system API
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
str_source = "WINDOW_SYSTEM";
break;
// A compiler for a shading language
case GL_DEBUG_SOURCE_SHADER_COMPILER:
str_source = "SHADER_COMPILER";
break;
// An application associated with OpenGL
case GL_DEBUG_SOURCE_THIRD_PARTY:
str_source = "THIRD_PARTY";
break;
// Generated by the user of this application
case GL_DEBUG_SOURCE_APPLICATION:
str_source = "APPLICATION";
break;
// Some source that isn't one of these
case GL_DEBUG_SOURCE_OTHER:
str_source = "OTHER";
break;
// Not on documentation
default:
str_source = "UNKNOWN";
rsx_log.error("log_debug(source=%d): Unknown message source", source);
}
// Message type
std::string str_type;
switch (type) switch (type)
{ {
// An error, typically from the API
case GL_DEBUG_TYPE_ERROR: case GL_DEBUG_TYPE_ERROR:
{ str_type = "ERROR";
rsx_log.error("%s", message); break;
return; // Some behavior marked deprecated has been used
} case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
str_type = "DEPRECATED";
break;
// Something has invoked undefined behavior
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
str_type = "UNDEFINED";
break;
// Some functionality the user relies upon is not portable
case GL_DEBUG_TYPE_PORTABILITY:
str_type = "PORTABILITY";
break;
// Code has triggered possible performance issues
case GL_DEBUG_TYPE_PERFORMANCE:
str_type = "PERFORMANCE";
break;
// Command stream annotation
case GL_DEBUG_TYPE_MARKER:
str_type = "MARKER";
break;
// Group pushing
case GL_DEBUG_TYPE_PUSH_GROUP:
str_type = "PUSH_GROUP";
break;
// foo
case GL_DEBUG_TYPE_POP_GROUP:
str_type = "POP_GROUP";
break;
// Some type that isn't one of these
case GL_DEBUG_TYPE_OTHER:
str_type = "OTHER";
break;
// Not on documentation
default: default:
{ str_type = "UNKNOWN";
rsx_log.warning("%s", message); rsx_log.error("log_debug(type=%d): Unknown message type", type);
}
switch (severity)
{
// All OpenGL Errors, shader compilation/linking errors, or highly-dangerous undefined behavior
case GL_DEBUG_SEVERITY_HIGH:
// Major performance warnings, shader compilation/linking warnings, or the use of deprecated functionality
case GL_DEBUG_SEVERITY_MEDIUM:
rsx_log.error("[DEBUG_OUTPUT] [%s] [%s] [%d]: %s", str_source, str_type, id, message);
return; return;
} // Redundant state change performance warning, or unimportant undefined behavior
} case GL_DEBUG_SEVERITY_LOW:
rsx_log.warning("[DEBUG_OUTPUT] [%s] [%s] [%d]: %s", str_source, str_type, id, message);
return;
// Anything that isn't an error or performance issue
case GL_DEBUG_SEVERITY_NOTIFICATION:
rsx_log.notice("[DEBUG_OUTPUT] [%s] [%s] [%d]: %s", str_source, str_type, id, message);
return;
// Not on documentation
default:
rsx_log.error("log_debug(severity=%d): Unknown severity level", severity);
rsx_log.error("[DEBUG_OUTPUT] [%s] [%s] [%d]: %s", str_source, str_type, id, message);
return;
}
} }
#endif
void enable_debugging() void enable_debugging()
{ {
#ifdef WIN32 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback(log_debug, nullptr);
glDebugMessageCallback(static_cast<GLDEBUGPROC>(dbgFunc), nullptr);
#endif
} }
capabilities &get_driver_caps() capabilities &get_driver_caps()

View File

@ -31,6 +31,11 @@
#define GL_INTERPRETER_FRAGMENT_BLOCK 7 #define GL_INTERPRETER_FRAGMENT_BLOCK 7
#define GL_COMPUTE_BUFFER_SLOT(index) (index + 8) #define GL_COMPUTE_BUFFER_SLOT(index) (index + 8)
// Noop keyword outside of Windows (used in log_debug)
#if !defined(_WIN32) && !defined(APIENTRY)
#define APIENTRY
#endif
inline static void _SelectTexture(int unit) { glActiveTexture(GL_TEXTURE0 + unit); } inline static void _SelectTexture(int unit) { glActiveTexture(GL_TEXTURE0 + unit); }
namespace gl namespace gl