Commit ee6884e7 by Geoff Lang Committed by Commit Bot

Generate generic error messages for Error objects without messages.

Makes sure that the debug output is fired for all generated errors. BUG=783054 Change-Id: Ia30870cd950c53da892554e0862276d4be5360ac Reviewed-on: https://chromium-review.googlesource.com/761760 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarAntoine Labour <piman@chromium.org>
parent 9e888a46
......@@ -800,6 +800,32 @@ unsigned int ParseArrayIndex(const std::string &name, size_t *nameLengthWithoutA
return subscript;
}
const char *GetGenericErrorMessage(GLenum error)
{
switch (error)
{
case GL_NO_ERROR:
return "";
case GL_INVALID_ENUM:
return "Invalid enum.";
case GL_INVALID_VALUE:
return "Invalid value.";
case GL_INVALID_OPERATION:
return "Invalid operation.";
case GL_STACK_OVERFLOW:
return "Stack overflow.";
case GL_STACK_UNDERFLOW:
return "Stack underflow.";
case GL_OUT_OF_MEMORY:
return "Out of memory.";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "Invalid framebuffer operation.";
default:
UNREACHABLE();
return "Unknown error.";
}
}
} // namespace gl
namespace egl
......@@ -855,6 +881,51 @@ bool IsRenderbufferTarget(EGLenum target)
{
return target == EGL_GL_RENDERBUFFER_KHR;
}
const char *GetGenericErrorMessage(EGLint error)
{
switch (error)
{
case EGL_SUCCESS:
return "";
case EGL_NOT_INITIALIZED:
return "Not initialized.";
case EGL_BAD_ACCESS:
return "Bad access.";
case EGL_BAD_ALLOC:
return "Bad allocation.";
case EGL_BAD_ATTRIBUTE:
return "Bad attribute.";
case EGL_BAD_CONFIG:
return "Bad config.";
case EGL_BAD_CONTEXT:
return "Bad context.";
case EGL_BAD_CURRENT_SURFACE:
return "Bad current surface.";
case EGL_BAD_DISPLAY:
return "Bad display.";
case EGL_BAD_MATCH:
return "Bad match.";
case EGL_BAD_NATIVE_WINDOW:
return "Bad native window.";
case EGL_BAD_PARAMETER:
return "Bad parameter.";
case EGL_BAD_SURFACE:
return "Bad surface.";
case EGL_CONTEXT_LOST:
return "Context lost.";
case EGL_BAD_STREAM_KHR:
return "Bad stream.";
case EGL_BAD_STATE_KHR:
return "Bad state.";
case EGL_BAD_DEVICE_EXT:
return "Bad device.";
default:
UNREACHABLE();
return "Unknown error.";
}
}
} // namespace egl
namespace egl_gl
......
......@@ -126,6 +126,8 @@ struct UniformTypeInfo final : angle::NonCopyable
const UniformTypeInfo &GetUniformTypeInfo(GLenum uniformType);
const char *GetGenericErrorMessage(GLenum error);
} // namespace gl
namespace egl
......@@ -137,7 +139,9 @@ size_t CubeMapTextureTargetToLayerIndex(EGLenum target);
EGLenum LayerIndexToCubeMapTextureTarget(size_t index);
bool IsTextureTarget(EGLenum target);
bool IsRenderbufferTarget(EGLenum target);
}
const char *GetGenericErrorMessage(EGLint error);
} // namespace egl
namespace egl_gl
{
......
......@@ -2153,12 +2153,9 @@ void Context::handleError(const Error &error)
markContextLost();
}
if (!error.getMessage().empty())
{
auto *debug = &mGLState.getDebug();
debug->insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, error.getID(),
GL_DEBUG_SEVERITY_HIGH, error.getMessage());
}
ASSERT(!error.getMessage().empty());
mGLState.getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, error.getID(),
GL_DEBUG_SEVERITY_HIGH, error.getMessage());
}
}
......
......@@ -11,19 +11,29 @@
#include "common/angleutils.h"
#include "common/debug.h"
#include "common/utilities.h"
#include <cstdarg>
namespace
{
std::unique_ptr<std::string> EmplaceErrorString(std::string &&message)
{
return message.empty() ? std::unique_ptr<std::string>()
: std::unique_ptr<std::string>(new std::string(std::move(message)));
}
} // anonymous namespace
namespace gl
{
Error::Error(GLenum errorCode, std::string &&message)
: mCode(errorCode), mID(errorCode), mMessage(new std::string(std::move(message)))
: mCode(errorCode), mID(errorCode), mMessage(EmplaceErrorString(std::move(message)))
{
}
Error::Error(GLenum errorCode, GLuint id, std::string &&message)
: mCode(errorCode), mID(id), mMessage(new std::string(std::move(message)))
: mCode(errorCode), mID(id), mMessage(EmplaceErrorString(std::move(message)))
{
}
......@@ -31,7 +41,7 @@ void Error::createMessageString() const
{
if (!mMessage)
{
mMessage.reset(new std::string);
mMessage.reset(new std::string(GetGenericErrorMessage(mCode)));
}
}
......@@ -69,12 +79,12 @@ namespace egl
{
Error::Error(EGLint errorCode, std::string &&message)
: mCode(errorCode), mID(errorCode), mMessage(new std::string(std::move(message)))
: mCode(errorCode), mID(errorCode), mMessage(EmplaceErrorString(std::move(message)))
{
}
Error::Error(EGLint errorCode, EGLint id, std::string &&message)
: mCode(errorCode), mID(id), mMessage(new std::string(std::move(message)))
: mCode(errorCode), mID(id), mMessage(EmplaceErrorString(std::move(message)))
{
}
......@@ -82,7 +92,7 @@ void Error::createMessageString() const
{
if (!mMessage)
{
mMessage.reset(new std::string);
mMessage.reset(new std::string(GetGenericErrorMessage(mCode)));
}
}
......
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