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)
......
......@@ -53,7 +53,7 @@ namespace
{
#define ANGLE_HANDLE_ERR(X) \
handleError(X); \
(void)(X); \
return;
#define ANGLE_CONTEXT_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_ERR);
......@@ -519,7 +519,7 @@ void Context::initialize()
mImplementation->setErrorSet(&mErrors);
handleError(mImplementation->initialize());
ANGLE_CONTEXT_TRY(mImplementation->initialize());
}
egl::Error Context::onDestroy(const egl::Display *display)
......@@ -664,9 +664,7 @@ egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface)
}
// Notify the renderer of a context switch.
// TODO(jmadill): Fix this error handling. http://anglebug.com/2491
(void)(mImplementation->onMakeCurrent(this));
return egl::NoError();
return mImplementation->onMakeCurrent(this).toEGL();
}
egl::Error Context::releaseSurface(const egl::Display *display)
......@@ -855,7 +853,7 @@ void Context::pathCommands(GLuint path,
{
auto *pathObject = mState.mPaths->getPath(path);
handleError(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords));
ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords));
}
void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value)
......@@ -1197,7 +1195,8 @@ void Context::endQuery(QueryType target)
Query *queryObject = mGLState.getActiveQuery(target);
ASSERT(queryObject);
handleError(queryObject->end(this));
// Intentionally don't call try here. We don't want an early return.
(void)(queryObject->end(this));
// Always unbind the query, even if there was an error. This may delete the query object.
mGLState.setActiveQuery(this, target, nullptr);
......@@ -1211,7 +1210,7 @@ void Context::queryCounter(GLuint id, QueryType target)
Query *queryObject = getQuery(id, true, target);
ASSERT(queryObject);
handleError(queryObject->queryCounter(this));
ANGLE_CONTEXT_TRY(queryObject->queryCounter(this));
}
void Context::getQueryiv(QueryType target, GLenum pname, GLint *params)
......@@ -1253,7 +1252,7 @@ void Context::getQueryivRobust(QueryType target,
void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params)
{
handleError(GetQueryObjectParameter(this, getQuery(id), pname, params));
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjectivRobust(GLuint id,
......@@ -1267,7 +1266,7 @@ void Context::getQueryObjectivRobust(GLuint id,
void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
{
handleError(GetQueryObjectParameter(this, getQuery(id), pname, params));
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjectuivRobust(GLuint id,
......@@ -1281,7 +1280,7 @@ void Context::getQueryObjectuivRobust(GLuint id,
void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params)
{
handleError(GetQueryObjectParameter(this, getQuery(id), pname, params));
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjecti64vRobust(GLuint id,
......@@ -1295,7 +1294,7 @@ void Context::getQueryObjecti64vRobust(GLuint id,
void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params)
{
handleError(GetQueryObjectParameter(this, getQuery(id), pname, params));
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjectui64vRobust(GLuint id,
......@@ -1841,7 +1840,7 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
break;
default:
handleError(mGLState.getIntegerv(this, pname, params));
ANGLE_CONTEXT_TRY(mGLState.getIntegerv(this, pname, params));
break;
}
}
......@@ -2304,12 +2303,12 @@ void Context::drawElementsIndirect(PrimitiveMode mode, GLenum type, const void *
void Context::flush()
{
handleError(mImplementation->flush(this));
ANGLE_CONTEXT_TRY(mImplementation->flush(this));
}
void Context::finish()
{
handleError(mImplementation->finish(this));
ANGLE_CONTEXT_TRY(mImplementation->finish(this));
}
void Context::insertEventMarker(GLsizei length, const char *marker)
......@@ -2614,11 +2613,6 @@ void Context::getProgramInterfaceivRobust(GLuint program,
UNIMPLEMENTED();
}
void Context::handleError(const Error &error) const
{
mErrors.handleError(error);
}
void Context::handleError(GLenum errorCode,
const char *message,
const char *file,
......@@ -3600,7 +3594,7 @@ void Context::blitFramebuffer(GLint srcX0,
ANGLE_CONTEXT_TRY(syncStateForBlit());
handleError(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter));
ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter));
}
void Context::clear(GLbitfield mask)
......@@ -3709,7 +3703,7 @@ void Context::readPixels(GLint x,
ASSERT(readFBO);
Rectangle area(x, y, width, height);
handleError(readFBO->readPixels(this, area, format, type, pixels));
ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels));
}
void Context::readPixelsRobust(GLint x,
......@@ -3758,7 +3752,8 @@ void Context::copyTexImage2D(TextureTarget target,
Framebuffer *framebuffer = mGLState.getReadFramebuffer();
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer));
ANGLE_CONTEXT_TRY(
texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer));
}
void Context::copyTexSubImage2D(TextureTarget target,
......@@ -3783,7 +3778,8 @@ void Context::copyTexSubImage2D(TextureTarget target,
Framebuffer *framebuffer = mGLState.getReadFramebuffer();
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer));
ANGLE_CONTEXT_TRY(
texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer));
}
void Context::copyTexSubImage3D(TextureType target,
......@@ -3809,8 +3805,8 @@ void Context::copyTexSubImage3D(TextureType target,
Framebuffer *framebuffer = mGLState.getReadFramebuffer();
Texture *texture = getTargetTexture(target);
handleError(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, destOffset,
sourceArea, framebuffer));
ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level,
destOffset, sourceArea, framebuffer));
}
void Context::framebufferTexture2D(GLenum target,
......@@ -3991,7 +3987,7 @@ void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GL
// The specification isn't clear what should be done when the framebuffer isn't complete.
// We leave it up to the framebuffer implementation to decide what to do.
handleError(framebuffer->discard(this, numAttachments, attachments));
ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments));
}
void Context::invalidateFramebuffer(GLenum target,
......@@ -4009,7 +4005,7 @@ void Context::invalidateFramebuffer(GLenum target,
return;
}
handleError(framebuffer->invalidate(this, numAttachments, attachments));
ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments));
}
void Context::invalidateSubFramebuffer(GLenum target,
......@@ -4032,7 +4028,7 @@ void Context::invalidateSubFramebuffer(GLenum target,
}
Rectangle area(x, y, width, height);
handleError(framebuffer->invalidateSub(this, numAttachments, attachments, area));
ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area));
}
void Context::texImage2D(TextureTarget target,
......@@ -4049,8 +4045,9 @@ void Context::texImage2D(TextureTarget target,
Extents size(width, height, 1);
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setImage(this, mGLState.getUnpackState(), target, level, internalformat,
size, format, type, static_cast<const uint8_t *>(pixels)));
ANGLE_CONTEXT_TRY(texture->setImage(this, mGLState.getUnpackState(), target, level,
internalformat, size, format, type,
static_cast<const uint8_t *>(pixels)));
}
void Context::texImage2DRobust(TextureTarget target,
......@@ -4082,9 +4079,9 @@ void Context::texImage3D(TextureType target,
Extents size(width, height, depth);
Texture *texture = getTargetTexture(target);
handleError(texture->setImage(this, mGLState.getUnpackState(),
NonCubeTextureTypeToTarget(target), level, internalformat, size,
format, type, static_cast<const uint8_t *>(pixels)));
ANGLE_CONTEXT_TRY(texture->setImage(this, mGLState.getUnpackState(),
NonCubeTextureTypeToTarget(target), level, internalformat,
size, format, type, static_cast<const uint8_t *>(pixels)));
}
void Context::texImage3DRobust(TextureType target,
......@@ -4125,8 +4122,9 @@ void Context::texSubImage2D(TextureTarget target,
gl::Buffer *unpackBuffer = mGLState.getTargetBuffer(gl::BufferBinding::PixelUnpack);
handleError(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer, target, level,
area, format, type, static_cast<const uint8_t *>(pixels)));
ANGLE_CONTEXT_TRY(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer, target,
level, area, format, type,
static_cast<const uint8_t *>(pixels)));
}
void Context::texSubImage2DRobust(TextureTarget target,
......@@ -4168,9 +4166,9 @@ void Context::texSubImage3D(TextureType target,
gl::Buffer *unpackBuffer = mGLState.getTargetBuffer(gl::BufferBinding::PixelUnpack);
handleError(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer,
NonCubeTextureTypeToTarget(target), level, area, format, type,
static_cast<const uint8_t *>(pixels)));
ANGLE_CONTEXT_TRY(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer,
NonCubeTextureTypeToTarget(target), level, area, format,
type, static_cast<const uint8_t *>(pixels)));
}
void Context::texSubImage3DRobust(TextureType target,
......@@ -4203,7 +4201,7 @@ void Context::compressedTexImage2D(TextureTarget target,
Extents size(width, height, 1);
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level,
ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level,
internalformat, size, imageSize,
static_cast<const uint8_t *>(data)));
}
......@@ -4235,7 +4233,7 @@ void Context::compressedTexImage3D(TextureType target,
Extents size(width, height, depth);
Texture *texture = getTargetTexture(target);
handleError(texture->setCompressedImage(
ANGLE_CONTEXT_TRY(texture->setCompressedImage(
this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat,
size, imageSize, static_cast<const uint8_t *>(data)));
}
......@@ -4269,8 +4267,8 @@ void Context::compressedTexSubImage2D(TextureTarget target,
Box area(xoffset, yoffset, 0, width, height, 1);
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level, area,
format, imageSize,
ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level,
area, format, imageSize,
static_cast<const uint8_t *>(data)));
}
......@@ -4311,7 +4309,7 @@ void Context::compressedTexSubImage3D(TextureType target,
Box area(xoffset, yoffset, zoffset, width, height, depth);
Texture *texture = getTargetTexture(target);
handleError(texture->setCompressedSubImage(
ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(
this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format,
imageSize, static_cast<const uint8_t *>(data)));
}
......@@ -4336,7 +4334,7 @@ void Context::compressedTexSubImage3DRobust(TextureType target,
void Context::generateMipmap(TextureType target)
{
Texture *texture = getTargetTexture(target);
handleError(texture->generateMipmap(this));
ANGLE_CONTEXT_TRY(texture->generateMipmap(this));
}
void Context::copyTexture(GLuint sourceId,
......@@ -4354,9 +4352,9 @@ void Context::copyTexture(GLuint sourceId,
gl::Texture *sourceTexture = getTexture(sourceId);
gl::Texture *destTexture = getTexture(destId);
handleError(destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType,
sourceLevel, ConvertToBool(unpackFlipY),
ConvertToBool(unpackPremultiplyAlpha),
ANGLE_CONTEXT_TRY(
destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel,
ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha),
ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
}
......@@ -4387,10 +4385,10 @@ void Context::copySubTexture(GLuint sourceId,
gl::Texture *destTexture = getTexture(destId);
Offset offset(xoffset, yoffset, 0);
Box box(x, y, 0, width, height, 1);
handleError(destTexture->copySubTexture(this, destTarget, destLevel, offset, sourceLevel, box,
ConvertToBool(unpackFlipY),
ConvertToBool(unpackPremultiplyAlpha),
ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
ANGLE_CONTEXT_TRY(destTexture->copySubTexture(
this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY),
ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha),
sourceTexture));
}
void Context::copyTexture3D(GLuint sourceId,
......@@ -4408,9 +4406,9 @@ void Context::copyTexture3D(GLuint sourceId,
Texture *sourceTexture = getTexture(sourceId);
Texture *destTexture = getTexture(destId);
handleError(destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType,
sourceLevel, ConvertToBool(unpackFlipY),
ConvertToBool(unpackPremultiplyAlpha),
ANGLE_CONTEXT_TRY(
destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel,
ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha),
ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
}
......@@ -4444,10 +4442,10 @@ void Context::copySubTexture3D(GLuint sourceId,
Texture *destTexture = getTexture(destId);
Offset offset(xoffset, yoffset, zoffset);
Box box(x, y, z, width, height, depth);
handleError(destTexture->copySubTexture(this, destTarget, destLevel, offset, sourceLevel, box,
ConvertToBool(unpackFlipY),
ConvertToBool(unpackPremultiplyAlpha),
ConvertToBool(unpackUnmultiplyAlpha), sourceTexture));
ANGLE_CONTEXT_TRY(destTexture->copySubTexture(
this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY),
ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha),
sourceTexture));
}
void Context::compressedCopyTexture(GLuint sourceId, GLuint destId)
......@@ -4456,7 +4454,7 @@ void Context::compressedCopyTexture(GLuint sourceId, GLuint destId)
gl::Texture *sourceTexture = getTexture(sourceId);
gl::Texture *destTexture = getTexture(destId);
handleError(destTexture->copyCompressedTexture(this, sourceTexture));
ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture));
}
void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params)
......@@ -4481,10 +4479,8 @@ void *Context::mapBuffer(BufferBinding target, GLenum access)
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
Error error = buffer->map(this, access);
if (error.isError())
if (buffer->map(this, access) == angle::Result::Stop())
{
handleError(error);
return nullptr;
}
......@@ -4497,10 +4493,8 @@ GLboolean Context::unmapBuffer(BufferBinding target)
ASSERT(buffer);
GLboolean result;
Error error = buffer->unmap(this, &result);
if (error.isError())
if (buffer->unmap(this, &result) == angle::Result::Stop())
{
handleError(error);
return GL_FALSE;
}
......@@ -4515,10 +4509,8 @@ void *Context::mapBufferRange(BufferBinding target,
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
Error error = buffer->mapRange(this, offset, length, access);
if (error.isError())
if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop())
{
handleError(error);
return nullptr;
}
......@@ -5102,7 +5094,7 @@ void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data
{
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
handleError(buffer->bufferData(this, target, data, size, usage));
ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage));
}
void Context::bufferSubData(BufferBinding target,
......@@ -5117,7 +5109,7 @@ void Context::bufferSubData(BufferBinding target,
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
handleError(buffer->bufferSubData(this, target, data, size, offset));
ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset));
}
void Context::attachShader(GLuint program, GLuint shader)
......@@ -5149,7 +5141,8 @@ void Context::copyBufferSubData(BufferBinding readTarget,
Buffer *readBuffer = mGLState.getTargetBuffer(readTarget);
Buffer *writeBuffer = mGLState.getTargetBuffer(writeTarget);
handleError(writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size));
ANGLE_CONTEXT_TRY(
writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size));
}
void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name)
......@@ -5221,7 +5214,7 @@ void Context::texStorage2DMultisample(TextureType target,
{
Extents size(width, height, 1);
Texture *texture = getTargetTexture(target);
handleError(texture->setStorageMultisample(this, target, samples, internalformat, size,
ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size,
ConvertToBool(fixedsamplelocations)));
}
......@@ -5235,7 +5228,7 @@ void Context::texStorage3DMultisample(TextureType target,
{
Extents size(width, height, depth);
Texture *texture = getTargetTexture(target);
handleError(texture->setStorageMultisample(this, target, samples, internalformat, size,
ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size,
ConvertToBool(fixedsamplelocations)));
}
......@@ -5249,7 +5242,7 @@ void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val)
switch (pname)
{
case GL_SAMPLE_POSITION:
handleError(framebuffer->getSamplePosition(this, index, val));
ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val));
break;
default:
UNREACHABLE();
......@@ -5274,7 +5267,7 @@ void Context::renderbufferStorage(GLenum target,
GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat);
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
handleError(renderbuffer->setStorage(this, convertedInternalFormat, width, height));
ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height));
}
void Context::renderbufferStorageMultisample(GLenum target,
......@@ -5287,14 +5280,14 @@ void Context::renderbufferStorageMultisample(GLenum target,
GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat);
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
handleError(
ANGLE_CONTEXT_TRY(
renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height));
}
void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values)
{
const Sync *syncObject = getSync(sync);
handleError(QuerySynciv(this, syncObject, pname, bufSize, length, values));
ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values));
}
void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
......@@ -5350,13 +5343,13 @@ void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGr
}
ANGLE_CONTEXT_TRY(prepareForDispatch());
handleError(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ));
ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ));
}
void Context::dispatchComputeIndirect(GLintptr indirect)
{
ANGLE_CONTEXT_TRY(prepareForDispatch());
handleError(mImplementation->dispatchComputeIndirect(this, indirect));
ANGLE_CONTEXT_TRY(mImplementation->dispatchComputeIndirect(this, indirect));
}
void Context::texStorage2D(TextureType target,
......@@ -5367,7 +5360,7 @@ void Context::texStorage2D(TextureType target,
{
Extents size(width, height, 1);
Texture *texture = getTargetTexture(target);
handleError(texture->setStorage(this, target, levels, internalFormat, size));
ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size));
}
void Context::texStorage3D(TextureType target,
......@@ -5379,17 +5372,17 @@ void Context::texStorage3D(TextureType target,
{
Extents size(width, height, depth);
Texture *texture = getTargetTexture(target);
handleError(texture->setStorage(this, target, levels, internalFormat, size));
ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size));
}
void Context::memoryBarrier(GLbitfield barriers)
{
handleError(mImplementation->memoryBarrier(this, barriers));
ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers));
}
void Context::memoryBarrierByRegion(GLbitfield barriers)
{
handleError(mImplementation->memoryBarrierByRegion(this, barriers));
ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers));
}
void Context::multiDrawArrays(PrimitiveMode mode,
......@@ -5998,7 +5991,7 @@ void Context::linkProgram(GLuint program)
{
Program *programObject = getProgramNoResolveLink(program);
ASSERT(programObject);
handleError(programObject->link(this));
ANGLE_CONTEXT_TRY(programObject->link(this));
// Don't parallel link a program which is active in any GL contexts. With this assumption, we
// don't need to worry that:
......@@ -6245,7 +6238,7 @@ void Context::getProgramBinary(GLuint program,
Program *programObject = getProgramResolveLink(program);
ASSERT(programObject != nullptr);
handleError(programObject->saveBinary(this, binaryFormat, binary, bufSize, length));
ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length));
}
void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length)
......@@ -6253,7 +6246,7 @@ void Context::programBinary(GLuint program, GLenum binaryFormat, const void *bin
Program *programObject = getProgramResolveLink(program);
ASSERT(programObject != nullptr);
handleError(programObject->loadBinary(this, binaryFormat, binary, length));
ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length));
if (programObject->isInUse())
{
ANGLE_CONTEXT_TRY(mGLState.onProgramExecutableChange(this, programObject));
......@@ -6644,11 +6637,9 @@ GLsync Context::fenceSync(GLenum condition, GLbitfield flags)
GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle));
Sync *syncObject = getSync(syncHandle);
Error error = syncObject->set(this, condition, flags);
if (error.isError())
if (syncObject->set(this, condition, flags) == angle::Result::Stop())
{
deleteSync(syncHandle);
handleError(error);
return nullptr;
}
......@@ -6665,14 +6656,17 @@ GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
Sync *syncObject = getSync(sync);
GLenum result = GL_WAIT_FAILED;
handleError(syncObject->clientWait(this, flags, timeout, &result));
if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop())
{
return GL_WAIT_FAILED;
}
return result;
}
void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
{
Sync *syncObject = getSync(sync);
handleError(syncObject->serverWait(this, flags, timeout));
ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout));
}
void Context::getInteger64v(GLenum pname, GLint64 *params)
......@@ -7067,7 +7061,7 @@ void Context::finishFenceNV(GLuint fence)
FenceNV *fenceObject = getFenceNV(fence);
ASSERT(fenceObject && fenceObject->isSet());
handleError(fenceObject->finish(this));
ANGLE_CONTEXT_TRY(fenceObject->finish(this));
}
void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params)
......@@ -7190,7 +7184,7 @@ void Context::setFenceNV(GLuint fence, GLenum condition)
FenceNV *fenceObject = getFenceNV(fence);
ASSERT(fenceObject != nullptr);
handleError(fenceObject->set(this, condition));
ANGLE_CONTEXT_TRY(fenceObject->set(this, condition));
}
GLboolean Context::testFenceNV(GLuint fence)
......@@ -7201,10 +7195,8 @@ GLboolean Context::testFenceNV(GLuint fence)
ASSERT(fenceObject->isSet() == GL_TRUE);
GLboolean result = GL_TRUE;
Error error = fenceObject->test(this, &result);
if (error.isError())
if (fenceObject->test(this, &result) == angle::Result::Stop())
{
handleError(error);
return GL_TRUE;
}
......@@ -7215,14 +7207,14 @@ void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image)
{
Texture *texture = getTargetTexture(target);
egl::Image *imageObject = static_cast<egl::Image *>(image);
handleError(texture->setEGLImageTarget(this, target, imageObject));
ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject));
}
void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image)
{
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
egl::Image *imageObject = static_cast<egl::Image *>(image);
handleError(renderbuffer->setStorageEGLImageTarget(this, imageObject));
ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject));
}
void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width)
......@@ -8147,49 +8139,32 @@ ErrorSet::ErrorSet(Context *context) : mContext(context) {}
ErrorSet::~ErrorSet() = default;
void ErrorSet::handleError(const Error &error) const
{
// 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
if (error.getCode() == GL_INTERNAL_ERROR_ANGLEX)
{
return;
}
if (ANGLE_UNLIKELY(error.isError()))
{
GLenum code = error.getCode();
mErrors.insert(code);
if (code == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory)
{
mContext->markContextLost();
}
ASSERT(!error.getMessage().empty());
mContext->getGLState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR,
error.getID(), GL_DEBUG_SEVERITY_HIGH,
error.getMessage());
}
}
void ErrorSet::handleError(GLenum errorCode,
const char *message,
const char *file,
const char *function,
unsigned int line)
{
// TODO(jmadill): Handle error directly instead of creating object. http://anglebug.com/2491
if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory)
{
mContext->markContextLost();
}
std::stringstream errorStream;
errorStream << "Front-end Error: " << gl::FmtHex(errorCode) << ", in " << file << ", "
<< function << ":" << line << ". " << message;
errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":"
<< line << ". " << message;
handleError(gl::Error(errorCode, errorCode, errorStream.str()));
// validationError does the necessary work to process the error.
validationError(errorCode, errorStream.str().c_str());
}
void ErrorSet::validationError(GLenum errorCode, const char *message)
{
handleError(gl::Error(errorCode, message));
ASSERT(errorCode != GL_NO_ERROR);
mErrors.insert(errorCode);
mContext->getGLState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR,
errorCode, GL_DEBUG_SEVERITY_HIGH, message);
}
bool ErrorSet::empty() const
......
......@@ -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,7 +31,7 @@ Path::~Path()
delete mPath;
}
Error Path::setCommands(GLsizei numCommands,
angle::Result Path::setCommands(GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
......@@ -41,7 +41,7 @@ Error Path::setCommands(GLsizei numCommands,
mHasData = true;
return NoError();
return angle::Result::Continue();
}
void Path::setStrokeWidth(GLfloat width)
......
......@@ -29,7 +29,7 @@ class Path final : angle::NonCopyable
~Path();
Error setCommands(GLsizei numCommands,
angle::Result setCommands(GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
......
......@@ -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,7 +1485,7 @@ void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, G
}
}
Error QuerySynciv(const Context *context,
angle::Result QuerySynciv(const Context *context,
const Sync *sync,
GLenum pname,
GLsizei bufSize,
......@@ -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,7 +104,7 @@ void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufS
void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, GLint *params);
Error QuerySynciv(const Context *context,
angle::Result QuerySynciv(const Context *context,
const Sync *sync,
GLenum pname,
GLsizei bufSize,
......
......@@ -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; }
......@@ -900,7 +903,7 @@ void GetScissor(const gl::State &glState,
auto ANGLE_LOCAL_VAR = command; \
if (ANGLE_UNLIKELY(ANGLE_LOCAL_VAR != VK_SUCCESS)) \
{ \
context->handleError(ANGLE_LOCAL_VAR, __FILE__, __LINE__); \
context->handleError(ANGLE_LOCAL_VAR, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop(); \
} \
} while (0)
......
......@@ -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