Commit c74c3d81 by James Dong Committed by Commit Bot

DEBUG: Log all debug messages to console

Logs all debug messages produced by GL and EGL. This is helpful for debugging when the application does not register a debug callback. Validation errors produce log messages with level INFO, and internal errors produce log messages with level WARN. Bug: angleproject:3505 Change-Id: I269055aec49e1d77edeedb482fa6873c8f79f853 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1645817 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 70642e42
...@@ -5000,7 +5000,7 @@ void Context::debugMessageInsert(GLenum source, ...@@ -5000,7 +5000,7 @@ void Context::debugMessageInsert(GLenum source,
const GLchar *buf) const GLchar *buf)
{ {
std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf)); std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf));
mState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); mState.getDebug().insertMessage(source, type, id, severity, std::move(msg), gl::LOG_INFO);
} }
void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam)
...@@ -8344,11 +8344,13 @@ void ErrorSet::handleError(GLenum errorCode, ...@@ -8344,11 +8344,13 @@ void ErrorSet::handleError(GLenum errorCode,
std::string formattedMessage = errorStream.str(); std::string formattedMessage = errorStream.str();
// Always log a warning, this function is only called on unexpected internal errors. // Process the error, but log it with WARN severity so it shows up in logs.
WARN() << formattedMessage; ASSERT(errorCode != GL_NO_ERROR);
mErrors.insert(errorCode);
// validationError does the necessary work to process the error. mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR,
validationError(errorCode, formattedMessage.c_str()); errorCode, GL_DEBUG_SEVERITY_HIGH, message,
gl::LOG_WARN);
} }
void ErrorSet::validationError(GLenum errorCode, const char *message) void ErrorSet::validationError(GLenum errorCode, const char *message)
...@@ -8357,7 +8359,8 @@ void ErrorSet::validationError(GLenum errorCode, const char *message) ...@@ -8357,7 +8359,8 @@ void ErrorSet::validationError(GLenum errorCode, const char *message)
mErrors.insert(errorCode); mErrors.insert(errorCode);
mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR,
errorCode, GL_DEBUG_SEVERITY_HIGH, message); errorCode, GL_DEBUG_SEVERITY_HIGH, message,
gl::LOG_INFO);
} }
bool ErrorSet::empty() const bool ErrorSet::empty() const
......
...@@ -13,6 +13,67 @@ ...@@ -13,6 +13,67 @@
#include <algorithm> #include <algorithm>
#include <tuple> #include <tuple>
namespace
{
const char *GLSeverityToString(GLenum severity)
{
switch (severity)
{
case GL_DEBUG_SEVERITY_HIGH:
return "HIGH";
case GL_DEBUG_SEVERITY_MEDIUM:
return "MEDIUM";
case GL_DEBUG_SEVERITY_LOW:
return "LOW";
case GL_DEBUG_SEVERITY_NOTIFICATION:
default:
return "NOTIFICATION";
}
}
const char *EGLMessageTypeToString(egl::MessageType messageType)
{
switch (messageType)
{
case egl::MessageType::Critical:
return "CRITICAL";
case egl::MessageType::Error:
return "ERROR";
case egl::MessageType::Warn:
return "WARNING";
case egl::MessageType::Info:
default:
return "INFO";
}
}
const char *GLMessageTypeToString(GLenum type)
{
switch (type)
{
case GL_DEBUG_TYPE_ERROR:
return "error";
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
return "deprecated behavior";
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
return "undefined behavior";
case GL_DEBUG_TYPE_PORTABILITY:
return "portability";
case GL_DEBUG_TYPE_PERFORMANCE:
return "performance";
case GL_DEBUG_TYPE_MARKER:
return "marker";
case GL_DEBUG_TYPE_PUSH_GROUP:
return "start of group";
case GL_DEBUG_TYPE_POP_GROUP:
return "end of group";
case GL_DEBUG_TYPE_OTHER:
default:
return "other message";
}
}
} // namespace
namespace gl namespace gl
{ {
...@@ -87,18 +148,29 @@ void Debug::insertMessage(GLenum source, ...@@ -87,18 +148,29 @@ void Debug::insertMessage(GLenum source,
GLenum type, GLenum type,
GLuint id, GLuint id,
GLenum severity, GLenum severity,
const std::string &message) const const std::string &message,
gl::LogSeverity logSeverity) const
{ {
std::string messageCopy(message); std::string messageCopy(message);
insertMessage(source, type, id, severity, std::move(messageCopy)); insertMessage(source, type, id, severity, std::move(messageCopy), logSeverity);
} }
void Debug::insertMessage(GLenum source, void Debug::insertMessage(GLenum source,
GLenum type, GLenum type,
GLuint id, GLuint id,
GLenum severity, GLenum severity,
std::string &&message) const std::string &&message,
gl::LogSeverity logSeverity) const
{ {
{
// output all messages to the debug log
const char *messageTypeString = GLMessageTypeToString(type);
const char *severityString = GLSeverityToString(severity);
std::ostringstream messageStream;
messageStream << "GL " << messageTypeString << ": " << severityString << ": " << message;
gl::Trace(logSeverity, messageStream.str().c_str());
}
if (!isMessageEnabled(source, type, id, severity)) if (!isMessageEnabled(source, type, id, severity))
{ {
return; return;
...@@ -223,7 +295,7 @@ void Debug::setMessageControl(GLenum source, ...@@ -223,7 +295,7 @@ void Debug::setMessageControl(GLenum source,
void Debug::pushGroup(GLenum source, GLuint id, std::string &&message) void Debug::pushGroup(GLenum source, GLuint id, std::string &&message)
{ {
insertMessage(source, GL_DEBUG_TYPE_PUSH_GROUP, id, GL_DEBUG_SEVERITY_NOTIFICATION, insertMessage(source, GL_DEBUG_TYPE_PUSH_GROUP, id, GL_DEBUG_SEVERITY_NOTIFICATION,
std::string(message)); std::string(message), gl::LOG_INFO);
Group g; Group g;
g.source = source; g.source = source;
...@@ -241,7 +313,7 @@ void Debug::popGroup() ...@@ -241,7 +313,7 @@ void Debug::popGroup()
mGroups.pop_back(); mGroups.pop_back();
insertMessage(g.source, GL_DEBUG_TYPE_POP_GROUP, g.id, GL_DEBUG_SEVERITY_NOTIFICATION, insertMessage(g.source, GL_DEBUG_TYPE_POP_GROUP, g.id, GL_DEBUG_SEVERITY_NOTIFICATION,
g.message); g.message, gl::LOG_INFO);
} }
size_t Debug::getGroupStackDepth() const size_t Debug::getGroupStackDepth() const
...@@ -365,6 +437,14 @@ void Debug::insertMessage(EGLenum error, ...@@ -365,6 +437,14 @@ void Debug::insertMessage(EGLenum error,
EGLLabelKHR objectLabel, EGLLabelKHR objectLabel,
const std::string &message) const const std::string &message) const
{ {
{
// output all messages to the debug log
const char *messageTypeString = EGLMessageTypeToString(messageType);
std::ostringstream messageStream;
messageStream << "EGL " << messageTypeString << ": " << command << ": " << message;
gl::Trace(gl::LOG_INFO, messageStream.str().c_str());
}
// TODO(geofflang): Lock before checking the callback. http://anglebug.com/2464 // TODO(geofflang): Lock before checking the callback. http://anglebug.com/2464
if (mCallback && isMessageTypeEnabled(messageType)) if (mCallback && isMessageTypeEnabled(messageType))
{ {
......
...@@ -52,12 +52,14 @@ class Debug : angle::NonCopyable ...@@ -52,12 +52,14 @@ class Debug : angle::NonCopyable
GLenum type, GLenum type,
GLuint id, GLuint id,
GLenum severity, GLenum severity,
const std::string &message) const; const std::string &message,
gl::LogSeverity logSeverity) const;
void insertMessage(GLenum source, void insertMessage(GLenum source,
GLenum type, GLenum type,
GLuint id, GLuint id,
GLenum severity, GLenum severity,
std::string &&message) const; std::string &&message,
gl::LogSeverity logSeverity) const;
void setMessageControl(GLenum source, void setMessageControl(GLenum source,
GLenum type, GLenum type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment