Commit 4f6592fa by Jamie Madill Committed by Commit Bot

Remove gl::Error.

Removes several TODOs. Only egl::Error remains. Also slightly decreases binary size. Bug: angleproject:2491 Change-Id: I3a9d1c22eb0884ca9e37362463fddd0083faf826 Reviewed-on: https://chromium-review.googlesource.com/c/1337462 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent fdbdb2b2
......@@ -250,10 +250,6 @@ std::string ToString(const T &value)
#define GL_RGB10_A2_SSCALED_ANGLEX 0x6AEC
#define GL_RGB10_A2_USCALED_ANGLEX 0x6AED
// This internal enum is used to filter internal errors that are already handled.
// TODO(jmadill): Remove this when refactor is done. http://anglebug.com/2491
#define GL_INTERNAL_ERROR_ANGLEX 0x6AEE
#define ANGLE_CHECK_GL_ALLOC(context, result) \
ANGLE_CHECK(context, result, "Failed to allocate host memory", GL_OUT_OF_MEMORY)
......
......@@ -70,8 +70,6 @@ class ErrorSet : angle::NonCopyable
explicit ErrorSet(Context *context);
~ErrorSet();
// TODO(jmadill): Remove const. http://anglebug.com/2491
void handleError(const Error &error) const;
bool empty() const;
GLenum popError();
......@@ -85,9 +83,7 @@ class ErrorSet : angle::NonCopyable
private:
Context *mContext;
// TODO(jmadill): Remove mutable. http://anglebug.com/2491
mutable std::set<GLenum> mErrors;
std::set<GLenum> mErrors;
};
// Helper class for managing cache variables and state changes.
......@@ -1597,9 +1593,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
int getFragDataIndex(GLuint program, const char *name);
int getProgramResourceLocationIndex(GLuint program, GLenum programInterface, const char *name);
// Consumes the error.
// TODO(jmadill): Remove const. http://anglebug.com/2491
void handleError(const Error &error) const;
// Consumes an error.
void handleError(GLenum errorCode,
const char *message,
const char *file,
......
......@@ -24,54 +24,6 @@ std::unique_ptr<std::string> EmplaceErrorString(std::string &&message)
}
} // anonymous namespace
namespace gl
{
Error::Error(GLenum errorCode, std::string &&message)
: mCode(errorCode), mID(errorCode), mMessage(EmplaceErrorString(std::move(message)))
{}
Error::Error(GLenum errorCode, GLuint id, std::string &&message)
: mCode(errorCode), mID(id), mMessage(EmplaceErrorString(std::move(message)))
{}
void Error::createMessageString() const
{
if (!mMessage)
{
mMessage.reset(new std::string(GetGenericErrorMessage(mCode)));
}
}
const std::string &Error::getMessage() const
{
createMessageString();
return *mMessage;
}
bool Error::operator==(const Error &other) const
{
if (mCode != other.mCode)
return false;
// TODO(jmadill): Compare extended error codes instead of strings.
if ((!mMessage || !other.mMessage) && (!mMessage != !other.mMessage))
return false;
return (*mMessage == *other.mMessage);
}
bool Error::operator!=(const Error &other) const
{
return !(*this == other);
}
std::ostream &operator<<(std::ostream &os, const Error &err)
{
return gl::FmtHex(os, err.getCode());
}
} // namespace gl
namespace egl
{
......@@ -101,21 +53,15 @@ std::ostream &operator<<(std::ostream &os, const Error &err)
{
return gl::FmtHex(os, err.getCode());
}
} // namespace egl
// angle::Result Implementation.
namespace angle
{
Result::operator gl::Error() const
egl::Error angle::Result::toEGL() const
{
if (mValue == Value::Continue)
{
return gl::NoError();
}
else
{
return gl::Error(GL_INTERNAL_ERROR_ANGLEX);
}
return egl::NoError();
return egl::Error(EGL_BAD_ACCESS);
}
} // namespace angle
......@@ -48,62 +48,6 @@ namespace egl
class Error;
} // namespace egl
namespace gl
{
class ANGLE_NO_DISCARD Error final
{
public:
explicit inline Error(GLenum errorCode);
Error(GLenum errorCode, std::string &&message);
Error(GLenum errorCode, GLuint id, std::string &&message);
inline Error(const Error &other);
inline Error(Error &&other);
inline ~Error() = default;
// automatic error type conversion
inline Error(egl::Error eglErr);
inline Error &operator=(const Error &other);
inline Error &operator=(Error &&other);
inline GLenum getCode() const;
inline GLuint getID() const;
inline bool isError() const;
const std::string &getMessage() const;
// Useful for mocking and testing
bool operator==(const Error &other) const;
bool operator!=(const Error &other) const;
static inline Error NoError();
private:
void createMessageString() const;
friend std::ostream &operator<<(std::ostream &os, const Error &err);
friend class egl::Error;
GLenum mCode;
GLuint mID;
mutable std::unique_ptr<std::string> mMessage;
};
namespace priv
{
template <GLenum EnumT>
using ErrorStream = angle::ErrorStreamBase<Error, GLenum, GL_NO_ERROR, GLenum, EnumT>;
} // namespace priv
inline Error NoError()
{
return Error::NoError();
}
} // namespace gl
namespace egl
{
......@@ -117,10 +61,6 @@ class ANGLE_NO_DISCARD Error final
inline Error(Error &&other);
inline ~Error() = default;
// automatic error type conversion
inline Error(gl::Error &&glErr);
inline Error(const gl::Error &glErr);
inline Error &operator=(const Error &other);
inline Error &operator=(Error &&other);
......@@ -136,7 +76,6 @@ class ANGLE_NO_DISCARD Error final
void createMessageString() const;
friend std::ostream &operator<<(std::ostream &os, const Error &err);
friend class gl::Error;
EGLint mCode;
EGLint mID;
......@@ -232,13 +171,13 @@ class ANGLE_NO_DISCARD Result
static Result Continue() { return Result(Value::Continue); }
static Result Incomplete() { return Result(Value::Incomplete); }
// TODO(jmadill): Remove when refactor is complete. http://anglebug.com/2491
operator gl::Error() const;
bool operator==(Result other) const { return mValue == other.mValue; }
bool operator!=(Result other) const { return mValue != other.mValue; }
// TODO(jmadill): Remove when refactor is complete. http://anglebug.com/2491
egl::Error toEGL() const;
private:
enum class Value
{
......
......@@ -10,94 +10,6 @@
#include <cstdarg>
namespace gl
{
Error::Error(GLenum errorCode)
: mCode(errorCode),
mID(errorCode)
{
}
Error::Error(const Error &other)
: mCode(other.mCode),
mID(other.mID)
{
if (other.mMessage)
{
createMessageString();
*mMessage = *(other.mMessage);
}
}
Error::Error(Error &&other)
: mCode(other.mCode),
mID(other.mID),
mMessage(std::move(other.mMessage))
{
}
// automatic error type conversion
Error::Error(egl::Error eglErr)
: mCode(GL_INVALID_OPERATION),
mID(0),
mMessage(std::move(eglErr.mMessage))
{
}
Error &Error::operator=(const Error &other)
{
mCode = other.mCode;
mID = other.mID;
if (other.mMessage)
{
createMessageString();
*mMessage = *(other.mMessage);
}
else
{
mMessage.release();
}
return *this;
}
Error &Error::operator=(Error &&other)
{
if (this != &other)
{
mCode = other.mCode;
mID = other.mID;
mMessage = std::move(other.mMessage);
}
return *this;
}
GLenum Error::getCode() const
{
return mCode;
}
GLuint Error::getID() const
{
return mID;
}
bool Error::isError() const
{
return (mCode != GL_NO_ERROR);
}
// static
Error Error::NoError()
{
return Error(GL_NO_ERROR);
}
} // namespace gl
namespace egl
{
......@@ -125,21 +37,6 @@ Error::Error(Error &&other)
{
}
// automatic error type conversion
Error::Error(gl::Error &&glErr)
: mCode(EGL_BAD_ACCESS),
mID(0),
mMessage(std::move(glErr.mMessage))
{
}
Error::Error(const gl::Error &glErr)
: mCode(EGL_BAD_ACCESS),
mID(0),
mMessage(glErr.mMessage.get())
{
}
Error &Error::operator=(const Error &other)
{
mCode = other.mCode;
......
......@@ -34,7 +34,7 @@ void GLES1Renderer::onDestroy(Context *context, State *state)
{
if (mRendererProgramInitialized)
{
context->handleError(state->setProgram(context, 0));
(void)state->setProgram(context, 0);
mShaderPrograms->deleteProgram(context, mProgramState.program);
mShaderPrograms->release(context);
......
......@@ -31,17 +31,17 @@ Path::~Path()
delete mPath;
}
Error Path::setCommands(GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
const void *coords)
angle::Result Path::setCommands(GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
const void *coords)
{
ANGLE_TRY(mPath->setCommands(numCommands, commands, numCoords, coordType, coords));
mHasData = true;
return NoError();
return angle::Result::Continue();
}
void Path::setStrokeWidth(GLfloat width)
......
......@@ -29,11 +29,11 @@ class Path final : angle::NonCopyable
~Path();
Error setCommands(GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
const void *coords);
angle::Result setCommands(GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
const void *coords);
void setStrokeWidth(GLfloat width);
void setStrokeBound(GLfloat bound);
......
......@@ -53,7 +53,7 @@ class RefCountObject : angle::NonCopyable
mutable size_t mRefCount;
};
template <class ObjectType, typename ContextT, typename ErrorT>
template <class ObjectType, typename ContextT, typename ErrorT = angle::Result>
class BindingPointer
{
public:
......@@ -133,7 +133,7 @@ class Context;
template <class ObjectType>
class BindingPointer;
using RefCountObjectNoID = angle::RefCountObject<Context, Error>;
using RefCountObjectNoID = angle::RefCountObject<Context, angle::Result>;
class RefCountObject : public gl::RefCountObjectNoID
{
......@@ -150,16 +150,15 @@ class RefCountObject : public gl::RefCountObjectNoID
};
template <class ObjectType>
class BindingPointer : public angle::BindingPointer<ObjectType, Context, Error>
class BindingPointer : public angle::BindingPointer<ObjectType, Context>
{
public:
using ContextType = typename angle::BindingPointer<ObjectType, Context, Error>::ContextType;
using ErrorType = typename angle::BindingPointer<ObjectType, Context, Error>::ErrorType;
using ContextType = typename angle::BindingPointer<ObjectType, Context>::ContextType;
using ErrorType = typename angle::BindingPointer<ObjectType, Context>::ErrorType;
BindingPointer() {}
BindingPointer(ObjectType *object) : angle::BindingPointer<ObjectType, Context, Error>(object)
{}
BindingPointer(ObjectType *object) : angle::BindingPointer<ObjectType, Context>(object) {}
GLuint id() const
{
......
......@@ -203,8 +203,11 @@ Error Stream::consumerAcquire(const gl::Context *context)
{
if (mPlanes[i].texture != nullptr)
{
ANGLE_TRY(gl::Error(mPlanes[i].texture->acquireImageFromStream(
context, mProducerImplementation->getGLFrameDescription(i))));
ANGLE_TRY(mPlanes[i]
.texture
->acquireImageFromStream(
context, mProducerImplementation->getGLFrameDescription(i))
.toEGL());
}
}
......@@ -224,7 +227,7 @@ Error Stream::consumerRelease(const gl::Context *context)
{
if (mPlanes[i].texture != nullptr)
{
ANGLE_TRY(gl::Error(mPlanes[i].texture->releaseImageFromStream(context)));
ANGLE_TRY(mPlanes[i].texture->releaseImageFromStream(context).toEGL());
}
}
......
......@@ -397,13 +397,12 @@ EGLint Surface::getHeight() const
return mFixedSize ? static_cast<EGLint>(mFixedHeight) : mImplementation->getHeight();
}
Error Surface::bindTexImage(const gl::Context *context, gl::Texture *texture, EGLint buffer)
Error Surface::bindTexImage(gl::Context *context, gl::Texture *texture, EGLint buffer)
{
ASSERT(!mTexture);
ANGLE_TRY(mImplementation->bindTexImage(context, texture, buffer));
auto glErr = texture->bindTexImageFromSurface(context, this);
if (glErr.isError())
if (texture->bindTexImageFromSurface(context, this) == angle::Result::Stop())
{
return Error(EGL_BAD_SURFACE);
}
......
......@@ -76,7 +76,7 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
EGLint height);
Error setPresentationTime(EGLnsecsANDROID time);
Error querySurfacePointerANGLE(EGLint attribute, void **value);
Error bindTexImage(const gl::Context *context, gl::Texture *texture, EGLint buffer);
Error bindTexImage(gl::Context *context, gl::Texture *texture, EGLint buffer);
Error releaseTexImage(const gl::Context *context, EGLint buffer);
Error getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc);
......
......@@ -970,7 +970,7 @@ void Texture::signalDirty(const Context *context, InitState initState)
invalidateCompletenessCache();
}
angle::Result Texture::setImage(const Context *context,
angle::Result Texture::setImage(Context *context,
const PixelUnpackState &unpackState,
TextureTarget target,
GLint level,
......@@ -1001,7 +1001,7 @@ angle::Result Texture::setImage(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::setSubImage(const Context *context,
angle::Result Texture::setSubImage(Context *context,
const PixelUnpackState &unpackState,
Buffer *unpackBuffer,
TextureTarget target,
......@@ -1025,7 +1025,7 @@ angle::Result Texture::setSubImage(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::setCompressedImage(const Context *context,
angle::Result Texture::setCompressedImage(Context *context,
const PixelUnpackState &unpackState,
TextureTarget target,
GLint level,
......@@ -1071,7 +1071,7 @@ angle::Result Texture::setCompressedSubImage(const Context *context,
pixels);
}
angle::Result Texture::copyImage(const Context *context,
angle::Result Texture::copyImage(Context *context,
TextureTarget target,
GLint level,
const Rectangle &sourceArea,
......@@ -1110,7 +1110,7 @@ angle::Result Texture::copyImage(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::copySubImage(const Context *context,
angle::Result Texture::copySubImage(Context *context,
TextureTarget target,
GLint level,
const Offset &destOffset,
......@@ -1133,7 +1133,7 @@ angle::Result Texture::copySubImage(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::copyTexture(const Context *context,
angle::Result Texture::copyTexture(Context *context,
TextureTarget target,
GLint level,
GLenum internalFormat,
......@@ -1198,7 +1198,7 @@ angle::Result Texture::copySubTexture(const Context *context,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha, source);
}
angle::Result Texture::copyCompressedTexture(const Context *context, const Texture *source)
angle::Result Texture::copyCompressedTexture(Context *context, const Texture *source)
{
// Release from previous calls to eglBindTexImage, to avoid calling the Impl after
ANGLE_TRY(releaseTexImageInternal(context));
......@@ -1214,7 +1214,7 @@ angle::Result Texture::copyCompressedTexture(const Context *context, const Textu
return angle::Result::Continue();
}
angle::Result Texture::setStorage(const Context *context,
angle::Result Texture::setStorage(Context *context,
TextureType type,
GLsizei levels,
GLenum internalFormat,
......@@ -1246,7 +1246,7 @@ angle::Result Texture::setStorage(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::setStorageMultisample(const Context *context,
angle::Result Texture::setStorageMultisample(Context *context,
TextureType type,
GLsizei samples,
GLint internalFormat,
......@@ -1273,7 +1273,7 @@ angle::Result Texture::setStorageMultisample(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::generateMipmap(const Context *context)
angle::Result Texture::generateMipmap(Context *context)
{
// Release from previous calls to eglBindTexImage, to avoid calling the Impl after
ANGLE_TRY(releaseTexImageInternal(context));
......@@ -1329,7 +1329,7 @@ angle::Result Texture::generateMipmap(const Context *context)
return angle::Result::Continue();
}
angle::Result Texture::bindTexImageFromSurface(const Context *context, egl::Surface *surface)
angle::Result Texture::bindTexImageFromSurface(Context *context, egl::Surface *surface)
{
ASSERT(surface);
......@@ -1406,7 +1406,7 @@ angle::Result Texture::releaseImageFromStream(const Context *context)
return angle::Result::Continue();
}
angle::Result Texture::releaseTexImageInternal(const Context *context)
angle::Result Texture::releaseTexImageInternal(Context *context)
{
if (mBoundSurface)
{
......@@ -1415,7 +1415,8 @@ angle::Result Texture::releaseTexImageInternal(const Context *context)
// TODO(jmadill): Remove this once refactor is complete. http://anglebug.com/2491
if (eglErr.isError())
{
context->handleError(Error(eglErr));
context->handleError(GL_INVALID_OPERATION, "Error releasing tex image from texture",
__FILE__, ANGLE_FUNCTION, __LINE__);
}
// Then, call the same method as from the surface
......@@ -1424,7 +1425,7 @@ angle::Result Texture::releaseTexImageInternal(const Context *context)
return angle::Result::Continue();
}
angle::Result Texture::setEGLImageTarget(const Context *context,
angle::Result Texture::setEGLImageTarget(Context *context,
TextureType type,
egl::Image *imageTarget)
{
......@@ -1716,7 +1717,7 @@ angle::Result Texture::ensureSubImageInitialized(const Context *context,
return angle::Result::Continue();
}
angle::Result Texture::handleMipmapGenerationHint(const Context *context, int level)
angle::Result Texture::handleMipmapGenerationHint(Context *context, int level)
{
if (getGenerateMipmapHint() == GL_TRUE && level == 0)
......
......@@ -283,7 +283,7 @@ class Texture final : public RefCountObject,
bool isMipmapComplete() const;
angle::Result setImage(const Context *context,
angle::Result setImage(Context *context,
const PixelUnpackState &unpackState,
TextureTarget target,
GLint level,
......@@ -292,7 +292,7 @@ class Texture final : public RefCountObject,
GLenum format,
GLenum type,
const uint8_t *pixels);
angle::Result setSubImage(const Context *context,
angle::Result setSubImage(Context *context,
const PixelUnpackState &unpackState,
Buffer *unpackBuffer,
TextureTarget target,
......@@ -302,7 +302,7 @@ class Texture final : public RefCountObject,
GLenum type,
const uint8_t *pixels);
angle::Result setCompressedImage(const Context *context,
angle::Result setCompressedImage(Context *context,
const PixelUnpackState &unpackState,
TextureTarget target,
GLint level,
......@@ -319,20 +319,20 @@ class Texture final : public RefCountObject,
size_t imageSize,
const uint8_t *pixels);
angle::Result copyImage(const Context *context,
angle::Result copyImage(Context *context,
TextureTarget target,
GLint level,
const Rectangle &sourceArea,
GLenum internalFormat,
Framebuffer *source);
angle::Result copySubImage(const Context *context,
angle::Result copySubImage(Context *context,
TextureTarget target,
GLint level,
const Offset &destOffset,
const Rectangle &sourceArea,
Framebuffer *source);
angle::Result copyTexture(const Context *context,
angle::Result copyTexture(Context *context,
TextureTarget target,
GLint level,
GLenum internalFormat,
......@@ -352,26 +352,24 @@ class Texture final : public RefCountObject,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
Texture *source);
angle::Result copyCompressedTexture(const Context *context, const Texture *source);
angle::Result copyCompressedTexture(Context *context, const Texture *source);
angle::Result setStorage(const Context *context,
angle::Result setStorage(Context *context,
TextureType type,
GLsizei levels,
GLenum internalFormat,
const Extents &size);
angle::Result setStorageMultisample(const Context *context,
angle::Result setStorageMultisample(Context *context,
TextureType type,
GLsizei samples,
GLint internalformat,
const Extents &size,
bool fixedSampleLocations);
angle::Result setEGLImageTarget(const Context *context,
TextureType type,
egl::Image *imageTarget);
angle::Result setEGLImageTarget(Context *context, TextureType type, egl::Image *imageTarget);
angle::Result generateMipmap(const Context *context);
angle::Result generateMipmap(Context *context);
egl::Surface *getBoundSurface() const;
egl::Stream *getBoundStream() const;
......@@ -461,7 +459,7 @@ class Texture final : public RefCountObject,
// ANGLE-only method, used internally
friend class egl::Surface;
angle::Result bindTexImageFromSurface(const Context *context, egl::Surface *surface);
angle::Result bindTexImageFromSurface(Context *context, egl::Surface *surface);
angle::Result releaseTexImageFromSurface(const Context *context);
// ANGLE-only methods, used internally
......@@ -473,14 +471,14 @@ class Texture final : public RefCountObject,
angle::Result releaseImageFromStream(const Context *context);
void invalidateCompletenessCache() const;
angle::Result releaseTexImageInternal(const Context *context);
angle::Result releaseTexImageInternal(Context *context);
angle::Result ensureSubImageInitialized(const Context *context,
TextureTarget target,
size_t level,
const gl::Box &area);
angle::Result handleMipmapGenerationHint(const Context *context, int level);
angle::Result handleMipmapGenerationHint(Context *context, int level);
TextureState mState;
DirtyBits mDirtyBits;
......
......@@ -358,7 +358,7 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const
break;
case GL_TEXTURE_BASE_LEVEL:
{
context->handleError(texture->setBaseLevel(
(void)(texture->setBaseLevel(
context, clampCast<GLuint>(CastQueryValueTo<GLint>(pname, params[0]))));
break;
}
......@@ -1485,12 +1485,12 @@ void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, G
}
}
Error QuerySynciv(const Context *context,
const Sync *sync,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *values)
angle::Result QuerySynciv(const Context *context,
const Sync *sync,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *values)
{
ASSERT(sync);
......@@ -1501,7 +1501,7 @@ Error QuerySynciv(const Context *context,
{
*length = 0;
}
return NoError();
return angle::Result::Continue();
}
switch (pname)
......@@ -1529,7 +1529,7 @@ Error QuerySynciv(const Context *context,
*length = 1;
}
return NoError();
return angle::Result::Continue();
}
void SetTexParameterf(Context *context, Texture *texture, GLenum pname, GLfloat param)
......
......@@ -12,6 +12,7 @@
#include "angle_gl.h"
#include "common/PackedEnums.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include <EGL/egl.h>
......@@ -19,7 +20,6 @@ namespace gl
{
class Buffer;
class Context;
class Error;
class Sync;
class Framebuffer;
class GLES1State;
......@@ -104,12 +104,12 @@ void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufS
void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, GLint *params);
Error QuerySynciv(const Context *context,
const Sync *sync,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *values);
angle::Result QuerySynciv(const Context *context,
const Sync *sync,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *values);
void SetTexParameterf(Context *context, Texture *texture, GLenum pname, GLfloat param);
void SetTexParameterfv(Context *context, Texture *texture, GLenum pname, const GLfloat *params);
......
......@@ -127,9 +127,7 @@ void ContextImpl::handleError(GLenum errorCode,
unsigned int line)
{
std::stringstream errorStream;
errorStream << "Internal error: " << gl::FmtHex(errorCode) << ", in " << file << ", "
<< function << ":" << line << ". " << message;
mErrors->handleError(gl::Error(errorCode, errorCode, errorStream.str()));
errorStream << "Internal error: " << gl::FmtHex(errorCode) << ": " << message;
mErrors->handleError(errorCode, errorStream.str().c_str(), file, function, line);
}
} // namespace rx
......@@ -625,9 +625,8 @@ void Context11::handleResult(HRESULT hr,
GLenum glErrorCode = DefaultGLErrorCode(hr);
std::stringstream errorStream;
errorStream << "Internal D3D11 error: " << gl::FmtHR(hr) << ", in " << file << ", " << function
<< ":" << line << ". " << message;
errorStream << "Internal D3D11 error: " << gl::FmtHR(hr) << ": " << message;
mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str()));
mErrors->handleError(glErrorCode, errorStream.str().c_str(), file, function, line);
}
} // namespace rx
......@@ -349,9 +349,8 @@ void Context9::handleResult(HRESULT hr,
GLenum glErrorCode = DefaultGLErrorCode(hr);
std::stringstream errorStream;
errorStream << "Internal D3D9 error: " << gl::FmtHR(hr) << ", in " << file << ", " << function
<< ":" << line << ". " << message;
errorStream << "Internal D3D9 error: " << gl::FmtHR(hr) << ": " << message;
mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str()));
mErrors->handleError(glErrorCode, errorStream.str().c_str(), file, function, line);
}
} // namespace rx
......@@ -145,7 +145,7 @@ static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source,
ERR() << std::endl
<< "\tSource: " << sourceText << std::endl
<< "\tType: " << typeText << std::endl
<< "\tID: " << gl::Error(id) << std::endl
<< "\tID: " << gl::FmtHex(id) << std::endl
<< "\tSeverity: " << severityText << std::endl
<< "\tMessage: " << message;
}
......@@ -158,7 +158,7 @@ static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source,
WARN() << std::endl
<< "\tSource: " << sourceText << std::endl
<< "\tType: " << typeText << std::endl
<< "\tID: " << gl::Error(id) << std::endl
<< "\tID: " << gl::FmtHex(id) << std::endl
<< "\tSeverity: " << severityText << std::endl
<< "\tMessage: " << message;
}
......
......@@ -419,9 +419,7 @@ void ContextNULL::handleError(GLenum errorCode,
unsigned int line)
{
std::stringstream errorStream;
errorStream << "Internal OpenGL error: " << gl::FmtHex(errorCode) << ", in " << file << ", "
<< function << ":" << line << ". " << message;
mErrors->handleError(gl::Error(errorCode, errorCode, errorStream.str()));
errorStream << "Internal NULL back-end error: " << message << ".";
mErrors->handleError(errorCode, errorStream.str().c_str(), file, function, line);
}
} // namespace rx
......@@ -431,20 +431,24 @@ angle::Result IncompleteTextureSet::getIncompleteTexture(
gl::Texture *tex = new gl::Texture(implFactory, std::numeric_limits<GLuint>::max(), createType);
angle::UniqueObjectPointer<gl::Texture, gl::Context> t(tex, context);
// This is a bit of a kludge but is necessary to consume the error.
gl::Context *mutableContext = const_cast<gl::Context *>(context);
if (createType == gl::TextureType::_2DMultisample)
{
ANGLE_TRY(t->setStorageMultisample(context, createType, 1, GL_RGBA8, colorSize, true));
ANGLE_TRY(
t->setStorageMultisample(mutableContext, createType, 1, GL_RGBA8, colorSize, true));
}
else
{
ANGLE_TRY(t->setStorage(context, createType, 1, GL_RGBA8, colorSize));
ANGLE_TRY(t->setStorage(mutableContext, createType, 1, GL_RGBA8, colorSize));
}
if (type == gl::TextureType::CubeMap)
{
for (gl::TextureTarget face : gl::AllCubeFaceTextureTargets())
{
ANGLE_TRY(t->setSubImage(context, unpack, nullptr, face, 0, area, GL_RGBA,
ANGLE_TRY(t->setSubImage(mutableContext, unpack, nullptr, face, 0, area, GL_RGBA,
GL_UNSIGNED_BYTE, color));
}
}
......@@ -455,7 +459,7 @@ angle::Result IncompleteTextureSet::getIncompleteTexture(
}
else
{
ANGLE_TRY(t->setSubImage(context, unpack, nullptr,
ANGLE_TRY(t->setSubImage(mutableContext, unpack, nullptr,
gl::NonCubeTextureTypeToTarget(createType), 0, area, GL_RGBA,
GL_UNSIGNED_BYTE, color));
}
......
......@@ -1217,13 +1217,17 @@ angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
return angle::Result::Continue();
}
void ContextVk::handleError(VkResult errorCode, const char *file, unsigned int line)
void ContextVk::handleError(VkResult errorCode,
const char *file,
const char *function,
unsigned int line)
{
ASSERT(errorCode != VK_SUCCESS);
GLenum glErrorCode = DefaultGLErrorCode(errorCode);
std::stringstream errorStream;
errorStream << "Internal Vulkan error: " << VulkanResultString(errorCode) << ", in " << file
<< ", line " << line << ".";
errorStream << "Internal Vulkan error: " << VulkanResultString(errorCode) << ".";
if (errorCode == VK_ERROR_DEVICE_LOST)
{
......@@ -1231,7 +1235,7 @@ void ContextVk::handleError(VkResult errorCode, const char *file, unsigned int l
mRenderer->notifyDeviceLost();
}
mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str()));
mErrors->handleError(glErrorCode, errorStream.str().c_str(), file, function, line);
}
angle::Result ContextVk::updateActiveTextures(const gl::Context *context)
......
......@@ -179,7 +179,10 @@ class ContextVk : public ContextImpl, public vk::Context
gl::Texture **textureOut);
void updateColorMask(const gl::BlendState &blendState);
void handleError(VkResult errorCode, const char *file, unsigned int line) override;
void handleError(VkResult errorCode,
const char *file,
const char *function,
unsigned int line) override;
const gl::ActiveTextureArray<TextureVk *> &getActiveTextures() const;
void setIndexBufferDirty() { mDirtyBits.set(DIRTY_BIT_INDEX_BUFFER); }
......
......@@ -186,11 +186,16 @@ bool DisplayVk::getScratchBuffer(size_t requstedSizeBytes,
return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut);
}
void DisplayVk::handleError(VkResult result, const char *file, unsigned int line)
void DisplayVk::handleError(VkResult result,
const char *file,
const char *function,
unsigned int line)
{
ASSERT(result != VK_SUCCESS);
std::stringstream errorStream;
errorStream << "Internal Vulkan error: " << VulkanResultString(result) << ", in " << file
<< ", line " << line << ".";
<< ", " << function << ":" << line << ".";
mStoredErrorString = errorStream.str();
if (result == VK_ERROR_DEVICE_LOST)
......
......@@ -79,7 +79,10 @@ class DisplayVk : public DisplayImpl, public vk::Context
angle::MemoryBuffer **scratchBufferOut) const;
angle::ScratchBuffer *getScratchBuffer() const { return &mScratchBuffer; }
void handleError(VkResult result, const char *file, unsigned int line) override;
void handleError(VkResult result,
const char *file,
const char *function,
unsigned int line) override;
// TODO(jmadill): Remove this once refactor is done. http://anglebug.com/2491
egl::Error getEGLError(EGLint errorCode);
......
......@@ -1118,7 +1118,7 @@ angle::Result MemoryProperties::findCompatibleMemoryIndex(
}
// TODO(jmadill): Add error message to error.
context->handleError(VK_ERROR_INCOMPATIBLE_DRIVER, __FILE__, __LINE__);
context->handleError(VK_ERROR_INCOMPATIBLE_DRIVER, __FILE__, ANGLE_FUNCTION, __LINE__);
return angle::Result::Stop();
}
......
......@@ -101,7 +101,10 @@ class Context : angle::NonCopyable
Context(RendererVk *renderer);
virtual ~Context();
virtual void handleError(VkResult result, const char *file, unsigned int line) = 0;
virtual void handleError(VkResult result,
const char *file,
const char *function,
unsigned int line) = 0;
VkDevice getDevice() const;
RendererVk *getRenderer() const { return mRenderer; }
......@@ -894,15 +897,15 @@ void GetScissor(const gl::State &glState,
} // namespace rx
#define ANGLE_VK_TRY(context, command) \
do \
{ \
auto ANGLE_LOCAL_VAR = command; \
if (ANGLE_UNLIKELY(ANGLE_LOCAL_VAR != VK_SUCCESS)) \
{ \
context->handleError(ANGLE_LOCAL_VAR, __FILE__, __LINE__); \
return angle::Result::Stop(); \
} \
#define ANGLE_VK_TRY(context, command) \
do \
{ \
auto ANGLE_LOCAL_VAR = command; \
if (ANGLE_UNLIKELY(ANGLE_LOCAL_VAR != VK_SUCCESS)) \
{ \
context->handleError(ANGLE_LOCAL_VAR, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop(); \
} \
} while (0)
#define ANGLE_VK_CHECK(context, test, error) ANGLE_VK_TRY(context, test ? VK_SUCCESS : error)
......
......@@ -592,7 +592,7 @@ bool ValidateES3TexStorage3DParameters(Context *context,
// Utility macro for handling implementation methods inside Validation.
#define ANGLE_HANDLE_VALIDATION_ERR(X) \
context->handleError(X); \
(void)(X); \
return false;
#define ANGLE_VALIDATION_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_VALIDATION_ERR);
......
......@@ -25,20 +25,20 @@ class ResultPerfTest : public ANGLEPerfTest
ResultPerfTest::ResultPerfTest() : ANGLEPerfTest("ResultPerf", "_run", kIterationsPerStep) {}
ANGLE_NOINLINE gl::Error ExternalCall()
ANGLE_NOINLINE angle::Result ExternalCall()
{
if (gThing != 0)
{
printf("Something very slow");
return gl::Error(GL_INVALID_OPERATION);
return angle::Result::Stop();
}
else
{
return gl::NoError();
return angle::Result::Continue();
}
}
gl::Error CallReturningResult(int depth)
angle::Result CallReturningResult(int depth)
{
ANGLE_TRY(ExternalCall());
ANGLE_TRY(ExternalCall());
......
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