Commit 1395134c by Jamie Madill Committed by Commit Bot

Remove more uses of gl::ErrorOrResult.

Only gl::LinkResult remains. Bug: angleproject:2753 Change-Id: I5e9c68c11453e8ab9db4908451957d7b3db0b110 Reviewed-on: https://chromium-review.googlesource.com/c/1254044Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 4d422c29
......@@ -753,15 +753,16 @@ GLuint Context::createRenderbuffer()
return mState.mRenderbuffers->createRenderbuffer();
}
void Context::tryGenPaths(GLsizei range, GLuint *createdOut)
{
ANGLE_CONTEXT_TRY(mState.mPaths->createPaths(mImplementation.get(), range, createdOut));
}
GLuint Context::genPaths(GLsizei range)
{
auto resultOrError = mState.mPaths->createPaths(mImplementation.get(), range);
if (resultOrError.isError())
{
handleError(resultOrError.getError());
return 0;
}
return resultOrError.getResult();
GLuint created = 0;
tryGenPaths(range, &created);
return created;
}
// Returns an unused framebuffer name
......
......@@ -1656,6 +1656,9 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
void detachSampler(GLuint sampler);
void detachProgramPipeline(GLuint pipeline);
// A small helper method to facilitate using the ANGLE_CONTEXT_TRY macro.
void tryGenPaths(GLsizei range, GLuint *createdOut);
void initRendererString();
void initVersionStrings();
void initExtensionStrings();
......
......@@ -345,8 +345,10 @@ PathManager::PathManager()
{
}
ErrorOrResult<GLuint> PathManager::createPaths(rx::GLImplFactory *factory, GLsizei range)
Error PathManager::createPaths(rx::GLImplFactory *factory, GLsizei range, GLuint *createdOut)
{
*createdOut = 0;
// Allocate client side handles.
const GLuint client = mHandleAllocator.allocateRange(static_cast<GLuint>(range));
if (client == HandleRangeAllocator::kInvalidHandle)
......@@ -365,7 +367,8 @@ ErrorOrResult<GLuint> PathManager::createPaths(rx::GLImplFactory *factory, GLsiz
const auto id = client + i;
mPaths.assign(id, new Path(impl));
}
return client;
*createdOut = client;
return NoError();
}
void PathManager::deletePaths(GLuint first, GLsizei range)
......
......@@ -243,7 +243,7 @@ class PathManager : public ResourceManagerBase<HandleRangeAllocator>
public:
PathManager();
ErrorOrResult<GLuint> createPaths(rx::GLImplFactory *factory, GLsizei range);
Error createPaths(rx::GLImplFactory *factory, GLsizei range, GLuint *numCreated);
void deletePaths(GLuint first, GLsizei range);
Path *getPath(GLuint handle) const;
bool hasPath(GLuint handle) const;
......
......@@ -468,22 +468,23 @@ gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
return gl::NoError();
}
gl::ErrorOrResult<bool> BlitGL::copySubTexture(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destComponentType,
const gl::Extents &sourceSize,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool needsLumaWorkaround,
GLenum lumaFormat,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha)
gl::Error BlitGL::copySubTexture(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destComponentType,
const gl::Extents &sourceSize,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool needsLumaWorkaround,
GLenum lumaFormat,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
bool *copySucceededOut)
{
ASSERT(source->getType() == gl::TextureType::_2D);
ANGLE_TRY(initializeResources());
......@@ -496,7 +497,8 @@ gl::ErrorOrResult<bool> BlitGL::copySubTexture(const gl::Context *context,
GLenum status = mFunctions->checkFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
return false;
*copySucceededOut = false;
return gl::NoError();
}
BlitProgramType blitProgramType = getBlitProgramType(sourceComponentType, destComponentType);
......@@ -566,7 +568,8 @@ gl::ErrorOrResult<bool> BlitGL::copySubTexture(const gl::Context *context,
mStateManager->bindVertexArray(mVAO, 0);
mFunctions->drawArrays(GL_TRIANGLES, 0, 3);
return true;
*copySucceededOut = true;
return gl::NoError();
}
gl::Error BlitGL::copySubTextureCPUReadback(const gl::Context *context,
......@@ -653,13 +656,14 @@ gl::Error BlitGL::copySubTextureCPUReadback(const gl::Context *context,
return gl::NoError();
}
gl::ErrorOrResult<bool> BlitGL::copyTexSubImage(TextureGL *source,
size_t sourceLevel,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset)
gl::Error BlitGL::copyTexSubImage(TextureGL *source,
size_t sourceLevel,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool *copySucceededOut)
{
ANGLE_TRY(initializeResources());
......@@ -670,7 +674,8 @@ gl::ErrorOrResult<bool> BlitGL::copyTexSubImage(TextureGL *source,
GLenum status = mFunctions->checkFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
return false;
*copySucceededOut = false;
return gl::NoError();
}
mStateManager->bindTexture(dest->getType(), dest->getTextureID());
......@@ -679,13 +684,15 @@ gl::ErrorOrResult<bool> BlitGL::copyTexSubImage(TextureGL *source,
destOffset.y, sourceArea.x, sourceArea.y, sourceArea.width,
sourceArea.height);
return true;
*copySucceededOut = true;
return gl::NoError();
}
gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex)
gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut)
{
ANGLE_TRY(initializeResources());
......@@ -713,7 +720,8 @@ gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
else
{
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
return false;
*clearSucceededOut = false;
return gl::NoError();
}
}
else
......@@ -737,7 +745,8 @@ gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
else
{
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
return false;
*clearSucceededOut = false;
return gl::NoError();
}
}
else
......@@ -767,14 +776,16 @@ gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
else
{
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
return false;
*clearSucceededOut = false;
return gl::NoError();
}
}
}
}
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
return true;
*clearSucceededOut = true;
return gl::NoError();
}
gl::Error BlitGL::clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat)
......
......@@ -66,22 +66,23 @@ class BlitGL : angle::NonCopyable
const gl::Rectangle &destArea,
GLenum filter);
gl::ErrorOrResult<bool> copySubTexture(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destComponentType,
const gl::Extents &sourceSize,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool needsLumaWorkaround,
GLenum lumaFormat,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha);
gl::Error copySubTexture(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destComponentType,
const gl::Extents &sourceSize,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool needsLumaWorkaround,
GLenum lumaFormat,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
bool *copySucceededOut);
gl::Error copySubTextureCPUReadback(const gl::Context *context,
TextureGL *source,
......@@ -98,18 +99,20 @@ class BlitGL : angle::NonCopyable
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha);
gl::ErrorOrResult<bool> copyTexSubImage(TextureGL *source,
size_t sourceLevel,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset);
gl::ErrorOrResult<bool> clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex);
gl::Error copyTexSubImage(TextureGL *source,
size_t sourceLevel,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool *copySucceededOut);
gl::Error clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut);
gl::Error clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat);
......
......@@ -482,33 +482,21 @@ Error FramebufferGL::readPixels(const gl::Context *context,
bool cannotSetDesiredRowLength =
packState.rowLength && !GetImplAs<ContextGL>(context)->getNativeExtensions().packSubimage;
gl::Error retVal = gl::NoError();
if (cannotSetDesiredRowLength || useOverlappingRowsWorkaround)
{
retVal = readPixelsRowByRow(context, area, readFormat, readType, packState, pixels);
return readPixelsRowByRow(context, area, readFormat, readType, packState, pixels);
}
else
{
gl::ErrorOrResult<bool> useLastRowPaddingWorkaround = false;
if (workarounds.packLastRowSeparatelyForPaddingInclusion)
{
useLastRowPaddingWorkaround = ShouldApplyLastRowPaddingWorkaround(
gl::Extents(area.width, area.height, 1), packState, packBuffer, readFormat,
readType, false, pixels);
}
if (useLastRowPaddingWorkaround.isError())
{
retVal = useLastRowPaddingWorkaround.getError();
}
else
{
retVal = readPixelsAllAtOnce(context, area, readFormat, readType, packState, pixels,
useLastRowPaddingWorkaround.getResult());
}
bool useLastRowPaddingWorkaround = false;
if (workarounds.packLastRowSeparatelyForPaddingInclusion)
{
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(gl::Extents(area.width, area.height, 1),
packState, packBuffer, readFormat, readType,
false, pixels, &useLastRowPaddingWorkaround));
}
return retVal;
return readPixelsAllAtOnce(context, area, readFormat, readType, packState, pixels,
useLastRowPaddingWorkaround);
}
Error FramebufferGL::blit(const gl::Context *context,
......
......@@ -169,11 +169,10 @@ gl::Error TextureGL::setImage(const gl::Context *context,
if (workarounds.unpackLastRowSeparatelyForPaddingInclusion)
{
bool apply;
ANGLE_TRY_RESULT(
ShouldApplyLastRowPaddingWorkaround(size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels),
apply);
bool apply = false;
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels,
&apply));
// The driver will think the pixel buffer doesn't have enough data, work around this bug
// by uploading the last row (and last level if 3D) separately.
......@@ -288,11 +287,10 @@ gl::Error TextureGL::setSubImage(const gl::Context *context,
{
gl::Extents size(area.width, area.height, area.depth);
bool apply;
ANGLE_TRY_RESULT(
ShouldApplyLastRowPaddingWorkaround(size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels),
apply);
bool apply = false;
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels,
&apply));
// The driver will think the pixel buffer doesn't have enough data, work around this bug
// by uploading the last row (and last level if 3D) separately.
......@@ -812,11 +810,10 @@ gl::Error TextureGL::copySubTextureHelper(const gl::Context *context,
sourceFormatContainSupersetOfDestFormat && sourceComponentType == destComponentType &&
!destSRGB)
{
bool copySucceded = false;
ANGLE_TRY_RESULT(blitter->copyTexSubImage(sourceGL, sourceLevel, this, target, level,
sourceArea, destOffset),
copySucceded);
if (copySucceded)
bool copySucceeded = false;
ANGLE_TRY(blitter->copyTexSubImage(sourceGL, sourceLevel, this, target, level, sourceArea,
destOffset, &copySucceeded));
if (copySucceeded)
{
return gl::NoError();
}
......@@ -827,14 +824,13 @@ gl::Error TextureGL::copySubTextureHelper(const gl::Context *context,
if (!destSRGB &&
nativegl::SupportsNativeRendering(functions, getType(), destLevelInfo.nativeInternalFormat))
{
bool copySucceded = false;
ANGLE_TRY_RESULT(blitter->copySubTexture(
context, sourceGL, sourceLevel, sourceComponentType, this, target,
level, destComponentType, sourceImageDesc.size, sourceArea, destOffset,
needsLumaWorkaround, sourceLevelInfo.sourceFormat, unpackFlipY,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha),
copySucceded);
if (copySucceded)
bool copySucceeded = false;
ANGLE_TRY(blitter->copySubTexture(
context, sourceGL, sourceLevel, sourceComponentType, this, target, level,
destComponentType, sourceImageDesc.size, sourceArea, destOffset, needsLumaWorkaround,
sourceLevelInfo.sourceFormat, unpackFlipY, unpackPremultiplyAlpha,
unpackUnmultiplyAlpha, &copySucceeded));
if (copySucceeded)
{
return gl::NoError();
}
......@@ -1550,9 +1546,8 @@ gl::Error TextureGL::initializeContents(const gl::Context *context,
int levelDepth = mState.getImageDesc(imageIndex).size.depth;
bool clearSucceeded = false;
ANGLE_TRY_RESULT(
blitter->clearRenderableTexture(this, nativeInternalFormat, levelDepth, imageIndex),
clearSucceeded);
ANGLE_TRY(blitter->clearRenderableTexture(this, nativeInternalFormat, levelDepth,
imageIndex, &clearSucceeded));
if (clearSucceeded)
{
return gl::NoError();
......
......@@ -1390,17 +1390,19 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
}
}
gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels)
gl::Error ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels,
bool *shouldApplyOut)
{
if (pixelBuffer == nullptr)
{
return false;
*shouldApplyOut = false;
return gl::NoError();
}
// We are using an pack or unpack buffer, compute what the driver thinks is going to be the
......@@ -1428,7 +1430,8 @@ gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &s
ANGLE_TRY_CHECKED_MATH(checkedEndByte.IsValid());
return checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelBuffer->getSize());
*shouldApplyOut = checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelBuffer->getSize());
return gl::NoError();
}
std::vector<ContextCreationTry> GenerateContextCreationToTry(EGLint requestedType, bool isMesaGLX)
......
......@@ -42,7 +42,6 @@ enum class MultiviewImplementationTypeGL
};
VendorID GetVendorID(const FunctionsGL *functions);
std::string GetDriverVersion(const FunctionsGL *functions);
// Helpers for extracting the GL helper objects out of a context
const FunctionsGL *GetFunctionsGL(const gl::Context *context);
......@@ -84,13 +83,14 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
size_t length,
GLbitfield access);
gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels);
gl::Error ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels,
bool *shouldApplyOut);
struct ContextCreationTry
{
......
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