Commit 8234e7b3 by Jamie Madill Committed by Commit Bot

Refactor some errors into ANGLE_TRY macros.

BUG=None Change-Id: I00ff2523995cb49d1af60cae62c2bba0d020eed4 Reviewed-on: https://chromium-review.googlesource.com/395569 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ef300b15
......@@ -179,11 +179,7 @@ gl::Error BufferD3D::getIndexRange(GLenum type,
gl::IndexRange *outRange)
{
const uint8_t *data = nullptr;
gl::Error error = getData(&data);
if (error.isError())
{
return error;
}
ANGLE_TRY(getData(&data));
*outRange = gl::ComputeIndexRange(type, data + offset, count, primitiveRestartEnabled);
return gl::Error(GL_NO_ERROR);
......
......@@ -275,11 +275,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams,
drawBufferStates[colorAttachmentIndex] != GL_NONE)
{
RenderTarget11 *renderTarget = nullptr;
gl::Error error = attachment.getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
}
ANGLE_TRY(attachment.getRenderTarget(&renderTarget));
const gl::InternalFormat &formatInfo = *attachment.getFormat().info;
......@@ -385,11 +381,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams,
ASSERT(attachment != nullptr);
RenderTarget11 *renderTarget = nullptr;
gl::Error error = attachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
}
ANGLE_TRY(attachment->getRenderTarget(&renderTarget));
const auto &nativeFormat = renderTarget->getFormatSet().format;
......
......@@ -92,11 +92,7 @@ gl::Error FenceNV11::finish()
while (finished != GL_TRUE)
{
loopCount++;
gl::Error error = FenceTestHelper(this, true, &finished);
if (error.isError())
{
return error;
}
ANGLE_TRY(FenceTestHelper(this, true, &finished));
if (loopCount % kDeviceLostCheckPeriod == 0 && mRenderer->testDeviceLost())
{
......@@ -107,7 +103,7 @@ gl::Error FenceNV11::finish()
ScheduleYield();
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
//
......
......@@ -50,14 +50,10 @@ gl::Error Image11::generateMipmap(Image11 *dest,
ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight());
D3D11_MAPPED_SUBRESOURCE destMapped;
gl::Error error = dest->map(D3D11_MAP_WRITE, &destMapped);
if (error.isError())
{
return error;
}
ANGLE_TRY(dest->map(D3D11_MAP_WRITE, &destMapped));
D3D11_MAPPED_SUBRESOURCE srcMapped;
error = src->map(D3D11_MAP_READ, &srcMapped);
gl::Error error = src->map(D3D11_MAP_READ, &srcMapped);
if (error.isError())
{
dest->unmap();
......@@ -78,7 +74,7 @@ gl::Error Image11::generateMipmap(Image11 *dest,
dest->markDirty();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
bool Image11::isDirty() const
......@@ -113,26 +109,14 @@ gl::Error Image11::copyToStorage(TextureStorage *storage, const gl::ImageIndex &
if (attemptToReleaseStagingTexture)
{
// If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it.
gl::Error error = storage11->releaseAssociatedImage(index, this);
if (error.isError())
{
return error;
}
ANGLE_TRY(storage11->releaseAssociatedImage(index, this));
}
ID3D11Resource *stagingTexture = NULL;
unsigned int stagingSubresourceIndex = 0;
gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex);
if (error.isError())
{
return error;
}
error = storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region);
if (error.isError())
{
return error;
}
ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex));
ANGLE_TRY(
storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region));
// Once the image data has been copied into the Storage, we can release it locally.
if (attemptToReleaseStagingTexture)
......@@ -144,7 +128,7 @@ gl::Error Image11::copyToStorage(TextureStorage *storage, const gl::ImageIndex &
mAssociatedImageIndex = index;
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const
......@@ -156,11 +140,7 @@ gl::Error Image11::recoverFromAssociatedStorage()
{
if (mRecoverFromStorage)
{
gl::Error error = createStagingTexture();
if (error.isError())
{
return error;
}
ANGLE_TRY(createStagingTexture());
bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this);
......@@ -172,12 +152,8 @@ gl::Error Image11::recoverFromAssociatedStorage()
{
// CopySubResource from the Storage to the Staging texture
gl::Box region(0, 0, 0, mWidth, mHeight, mDepth);
error = mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region);
if (error.isError())
{
return error;
}
ANGLE_TRY(mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource,
mAssociatedImageIndex, region));
mRecoveredFromStorageCount += 1;
}
......@@ -185,7 +161,7 @@ gl::Error Image11::recoverFromAssociatedStorage()
disassociateStorage();
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
void Image11::disassociateStorage()
......@@ -272,11 +248,7 @@ gl::Error Image11::loadData(const gl::Box &area,
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(type).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
if (error.isError())
{
return error;
}
ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage));
uint8_t *offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (area.y * mappedImage.RowPitch + area.x * outputPixelSize + area.z * mappedImage.DepthPitch));
loadFunction(area.width, area.height, area.depth,
......@@ -285,7 +257,7 @@ gl::Error Image11::loadData(const gl::Box &area,
unmap();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
......@@ -309,11 +281,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(GL_UNSIGNED_BYTE).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
if (error.isError())
{
return error;
}
ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage));
uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((area.y / outputBlockHeight) * mappedImage.RowPitch +
(area.x / outputBlockWidth) * outputPixelSize +
......@@ -325,7 +293,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
unmap();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Image11::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureStorage *source)
......@@ -333,11 +301,7 @@ gl::Error Image11::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureS
TextureStorage11 *storage11 = GetAs<TextureStorage11>(source);
ID3D11Resource *resource = nullptr;
gl::Error error = storage11->getResource(&resource);
if (error.isError())
{
return error;
}
ANGLE_TRY(storage11->getResource(&resource));
UINT subresourceIndex = storage11->getSubresourceIndex(imageIndex);
TextureHelper11 textureHelper =
......@@ -361,11 +325,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
if (d3d11Format.texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat)
{
RenderTargetD3D *renderTarget = nullptr;
gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
}
ANGLE_TRY(srcAttachment->getRenderTarget(&renderTarget));
RenderTarget11 *rt11 = GetAs<RenderTarget11>(renderTarget);
ASSERT(rt11->getTexture());
......@@ -381,11 +341,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
// This format requires conversion, so we must copy the texture to staging and manually convert
// via readPixels
D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
if (error.isError())
{
return error;
}
ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage));
// determine the offset coordinate into the destination buffer
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
......@@ -400,6 +356,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
auto loadFunction = destD3D11Format.loadFunctions(destFormatInfo.type);
gl::Error error = gl::NoError();
if (loadFunction.requiresConversion)
{
size_t bufferSize = destFormatInfo.pixelBytes * sourceArea.width * sourceArea.height;
......@@ -436,11 +393,7 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset,
// No conversion needed-- use copyback fastpath
ID3D11Resource *stagingTexture = nullptr;
unsigned int stagingSubresourceIndex = 0;
gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex);
if (error.isError())
{
return error;
}
ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex));
ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
......@@ -505,20 +458,16 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset,
}
mDirty = true;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Image11::getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex)
{
gl::Error error = createStagingTexture();
if (error.isError())
{
return error;
}
ANGLE_TRY(createStagingTexture());
*outStagingTexture = mStagingTexture;
*outSubresourceIndex = mStagingSubresource;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
void Image11::releaseStagingTexture()
......@@ -639,19 +588,11 @@ gl::Error Image11::createStagingTexture()
gl::Error Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
{
// We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE.
gl::Error error = recoverFromAssociatedStorage();
if (error.isError())
{
return error;
}
ANGLE_TRY(recoverFromAssociatedStorage());
ID3D11Resource *stagingTexture = NULL;
unsigned int subresourceIndex = 0;
error = getStagingTexture(&stagingTexture, &subresourceIndex);
if (error.isError())
{
return error;
}
ANGLE_TRY(getStagingTexture(&stagingTexture, &subresourceIndex));
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
......
......@@ -96,17 +96,11 @@ template <typename T>
gl::Error Query11::getResultBase(T *params)
{
ASSERT(mActiveQuery->query == nullptr);
gl::Error error = flush(true);
if (error.isError())
{
return error;
}
ANGLE_TRY(flush(true));
ASSERT(mPendingQueries.empty());
*params = static_cast<T>(mResultSum);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Query11::getResult(GLint *params)
......@@ -131,14 +125,10 @@ gl::Error Query11::getResult(GLuint64 *params)
gl::Error Query11::isResultAvailable(bool *available)
{
gl::Error error = flush(false);
if (error.isError())
{
return error;
}
ANGLE_TRY(flush(false));
*available = mPendingQueries.empty();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Query11::pause()
......@@ -167,11 +157,7 @@ gl::Error Query11::resume()
{
if (mActiveQuery->query == nullptr)
{
gl::Error error = flush(false);
if (error.isError())
{
return error;
}
ANGLE_TRY(flush(false));
GLenum queryType = getType();
D3D11_QUERY d3dQueryType = gl_d3d11::ConvertQueryType(queryType);
......@@ -234,11 +220,7 @@ gl::Error Query11::flush(bool force)
do
{
gl::Error error = testQuery(query);
if (error.isError())
{
return error;
}
ANGLE_TRY(testQuery(query));
if (!query->finished && !force)
{
return gl::Error(GL_NO_ERROR);
......@@ -249,7 +231,7 @@ gl::Error Query11::flush(bool force)
mPendingQueries.pop_front();
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Query11::testQuery(QueryState *queryState)
......@@ -408,7 +390,7 @@ gl::Error Query11::testQuery(QueryState *queryState)
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
}
} // namespace rx
......@@ -182,12 +182,8 @@ gl::Error VertexArray11::updateDirtyAndDynamicAttribs(VertexDataManager *vertexD
break;
case VertexStorageType::STATIC:
{
auto error =
VertexDataManager::StoreStaticAttrib(translatedAttrib, count, instances);
if (error.isError())
{
return error;
}
ANGLE_TRY(
VertexDataManager::StoreStaticAttrib(translatedAttrib, count, instances));
break;
}
case VertexStorageType::CURRENT_VALUE:
......
......@@ -120,11 +120,7 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri
int inputStride = static_cast<int>(ComputeVertexAttributeStride(attrib));
// This will map the resource if it isn't already mapped.
gl::Error error = mapResource();
if (error.isError())
{
return error;
}
ANGLE_TRY(mapResource());
uint8_t *output = mMappedResourceData + offset;
......@@ -141,7 +137,7 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri
ASSERT(vertexFormatInfo.copyFunction != NULL);
vertexFormatInfo.copyFunction(input, inputStride, count, output);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
unsigned int VertexBuffer11::getBufferSize() const
......
......@@ -145,13 +145,7 @@ gl::Error Blit9::setShader(ShaderId source, const char *profile,
{
const BYTE* shaderCode = g_shaderCode[source];
size_t shaderSize = g_shaderSize[source];
gl::Error error = (mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader);
if (error.isError())
{
return error;
}
ANGLE_TRY((mRenderer->*createShader)(reinterpret_cast<const DWORD*>(shaderCode), shaderSize, &shader));
mCompiledShaders[source] = shader;
}
......@@ -190,18 +184,10 @@ RECT Blit9::getSurfaceRect(IDirect3DSurface9 *surface) const
gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
gl::Error error = initialize();
if (error.isError())
{
return error;
}
ANGLE_TRY(initialize());
IDirect3DTexture9 *texture = NULL;
error = copySurfaceToTexture(source, getSurfaceRect(source), &texture);
if (error.isError())
{
return error;
}
ANGLE_TRY(copySurfaceToTexture(source, getSurfaceRect(source), &texture));
IDirect3DDevice9 *device = mRenderer->getDevice();
......@@ -230,21 +216,13 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
gl::Error error = initialize();
if (error.isError())
{
return error;
}
ANGLE_TRY(initialize());
const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
ASSERT(colorbuffer);
RenderTarget9 *renderTarget9 = nullptr;
error = colorbuffer->getRenderTarget(&renderTarget9);
if (error.isError())
{
return error;
}
ANGLE_TRY(colorbuffer->getRenderTarget(&renderTarget9));
ASSERT(renderTarget9);
IDirect3DSurface9 *source = renderTarget9->getSurface();
......@@ -252,7 +230,7 @@ gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRe
IDirect3DSurface9 *destSurface = NULL;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, true, &destSurface);
gl::Error error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, true, &destSurface);
if (error.isError())
{
SafeRelease(source);
......
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