Commit da123308 by Jamie Madill Committed by Commit Bot

Add ANGLE_TRY macros to reduce boilerplate with gl/egl Errors.

The macros don't need to disambiguate between GL/EGL. Also make helpers to deal with ErrorOrResult. BUG=angleproject:1310 BUG=angleproject:1327 Change-Id: I8041c4b17a859fe1f236bca3ad266453d67a8fd4 Reviewed-on: https://chromium-review.googlesource.com/335826Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e2fcf5c3
......@@ -363,7 +363,7 @@ Error Display::initialize()
if (isInitialized())
{
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error error = mImplementation->initialize(this);
......@@ -421,7 +421,7 @@ Error Display::initialize()
mInitialized = true;
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
void Display::terminate()
......@@ -548,7 +548,7 @@ Error Display::createWindowSurface(const Config *configuration, EGLNativeWindowT
ASSERT(outSurface != nullptr);
*outSurface = surface;
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error Display::createPbufferSurface(const Config *configuration, const AttributeMap &attribs, Surface **outSurface)
......@@ -579,7 +579,7 @@ Error Display::createPbufferSurface(const Config *configuration, const Attribute
ASSERT(outSurface != nullptr);
*outSurface = surface;
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error Display::createPbufferFromClientBuffer(const Config *configuration, EGLClientBuffer shareHandle,
......@@ -611,7 +611,7 @@ Error Display::createPbufferFromClientBuffer(const Config *configuration, EGLCli
ASSERT(outSurface != nullptr);
*outSurface = surface;
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error Display::createPixmapSurface(const Config *configuration, NativePixmapType nativePixmap, const AttributeMap &attribs,
......@@ -643,7 +643,7 @@ Error Display::createPixmapSurface(const Config *configuration, NativePixmapType
ASSERT(outSurface != nullptr);
*outSurface = surface;
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error Display::createImage(gl::Context *context,
......@@ -696,7 +696,7 @@ Error Display::createImage(gl::Context *context,
image->addRef();
mImageSet.insert(image);
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error Display::createContext(const Config *configuration, gl::Context *shareContext, const AttributeMap &attribs,
......@@ -721,7 +721,7 @@ Error Display::createContext(const Config *configuration, gl::Context *shareCont
ASSERT(outContext != nullptr);
*outContext = context;
return Error(EGL_SUCCESS);
return egl::Error(EGL_SUCCESS);
}
Error Display::makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context)
......
......@@ -74,6 +74,11 @@ class ErrorOrResult
T mResult;
};
inline Error NoError()
{
return Error(GL_NO_ERROR);
}
} // namespace gl
namespace egl
......@@ -107,6 +112,35 @@ class Error final
} // namespace egl
#define ANGLE_CONCAT1(x, y) x##y
#define ANGLE_CONCAT2(x, y) ANGLE_CONCAT1(x, y)
#define ANGLE_LOCAL_VAR ANGLE_CONCAT2(_localVar, __LINE__)
#define ANGLE_TRY(EXPR) \
{ \
auto ANGLE_LOCAL_VAR = EXPR; \
if (ANGLE_LOCAL_VAR.isError()) \
{ \
return ANGLE_LOCAL_VAR; \
} \
} \
ANGLE_EMPTY_STATEMENT
#define ANGLE_TRY_RESULT(EXPR, RESULT) \
{ \
auto ANGLE_LOCAL_VAR = EXPR; \
if (ANGLE_LOCAL_VAR.isError()) \
{ \
return ANGLE_LOCAL_VAR.getError(); \
} \
RESULT = ANGLE_LOCAL_VAR.getResult(); \
} \
ANGLE_EMPTY_STATEMENT
#undef ANGLE_LOCAL_VAR
#undef ANGLE_CONCAT2
#undef ANGLE_CONCAT1
#include "Error.inl"
#endif // LIBANGLE_ERROR_H_
......@@ -137,31 +137,19 @@ gl::Error RendererD3D::genericDrawElements(const gl::Data &data,
programD3D->updateSamplerMapping();
gl::Error error = generateSwizzles(data);
if (error.isError())
{
return error;
}
ANGLE_TRY(generateSwizzles(data));
if (!applyPrimitiveType(mode, count, usesPointSize))
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
error = updateState(data, mode);
if (error.isError())
{
return error;
}
ANGLE_TRY(updateState(data, mode));
TranslatedIndexData indexInfo;
indexInfo.indexRange = indexRange;
error = applyIndexBuffer(data, indices, count, mode, type, &indexInfo);
if (error.isError())
{
return error;
}
ANGLE_TRY(applyIndexBuffer(data, indices, count, mode, type, &indexInfo));
applyTransformFeedbackBuffers(*data.state);
// Transform feedback is not allowed for DrawElements, this error should have been caught at the API validation
......@@ -169,41 +157,18 @@ gl::Error RendererD3D::genericDrawElements(const gl::Data &data,
ASSERT(!data.state->isTransformFeedbackActiveUnpaused());
size_t vertexCount = indexInfo.indexRange.vertexCount();
error = applyVertexBuffer(*data.state, mode, static_cast<GLsizei>(indexInfo.indexRange.start),
static_cast<GLsizei>(vertexCount), instances, &indexInfo);
if (error.isError())
{
return error;
}
error = applyTextures(data);
if (error.isError())
{
return error;
}
error = applyShaders(data, mode);
if (error.isError())
{
return error;
}
error = programD3D->applyUniformBuffers(data);
if (error.isError())
{
return error;
}
ANGLE_TRY(applyVertexBuffer(*data.state, mode, static_cast<GLsizei>(indexInfo.indexRange.start),
static_cast<GLsizei>(vertexCount), instances, &indexInfo));
ANGLE_TRY(applyTextures(data));
ANGLE_TRY(applyShaders(data, mode));
ANGLE_TRY(programD3D->applyUniformBuffers(data));
if (!skipDraw(data, mode))
{
error = drawElementsImpl(data, indexInfo, mode, count, type, indices, instances);
if (error.isError())
{
return error;
}
ANGLE_TRY(drawElementsImpl(data, indexInfo, mode, count, type, indices, instances));
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error RendererD3D::genericDrawArrays(const gl::Data &data,
......@@ -219,68 +184,30 @@ gl::Error RendererD3D::genericDrawArrays(const gl::Data &data,
programD3D->updateSamplerMapping();
gl::Error error = generateSwizzles(data);
if (error.isError())
{
return error;
}
ANGLE_TRY(generateSwizzles(data));
if (!applyPrimitiveType(mode, count, usesPointSize))
{
return gl::Error(GL_NO_ERROR);
}
error = updateState(data, mode);
if (error.isError())
{
return error;
}
applyTransformFeedbackBuffers(*data.state);
error = applyVertexBuffer(*data.state, mode, first, count, instances, nullptr);
if (error.isError())
{
return error;
}
error = applyTextures(data);
if (error.isError())
{
return error;
return gl::NoError();
}
error = applyShaders(data, mode);
if (error.isError())
{
return error;
}
error = programD3D->applyUniformBuffers(data);
if (error.isError())
{
return error;
}
ANGLE_TRY(updateState(data, mode));
ANGLE_TRY(applyTransformFeedbackBuffers(*data.state));
ANGLE_TRY(applyVertexBuffer(*data.state, mode, first, count, instances, nullptr));
ANGLE_TRY(applyTextures(data));
ANGLE_TRY(applyShaders(data, mode));
ANGLE_TRY(programD3D->applyUniformBuffers(data));
if (!skipDraw(data, mode))
{
error = drawArraysImpl(data, mode, count, instances);
if (error.isError())
{
return error;
}
ANGLE_TRY(drawArraysImpl(data, mode, count, instances));
if (data.state->isTransformFeedbackActiveUnpaused())
{
error = markTransformFeedbackUsage(data);
if (error.isError())
{
return error;
}
ANGLE_TRY(markTransformFeedbackUsage(data));
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType type)
......@@ -299,33 +226,19 @@ gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType ty
ASSERT(texture);
if (texture->getTextureState().swizzleRequired())
{
gl::Error error = generateSwizzle(texture);
if (error.isError())
{
return error;
}
ANGLE_TRY(generateSwizzle(texture));
}
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error RendererD3D::generateSwizzles(const gl::Data &data)
{
gl::Error error = generateSwizzles(data, gl::SAMPLER_VERTEX);
if (error.isError())
{
return error;
}
error = generateSwizzles(data, gl::SAMPLER_PIXEL);
if (error.isError())
{
return error;
}
return gl::Error(GL_NO_ERROR);
ANGLE_TRY(generateSwizzles(data, gl::SAMPLER_VERTEX));
ANGLE_TRY(generateSwizzles(data, gl::SAMPLER_PIXEL));
return gl::NoError();
}
unsigned int RendererD3D::GetBlendSampleMask(const gl::Data &data, int samples)
......@@ -371,11 +284,7 @@ gl::Error RendererD3D::applyShaders(const gl::Data &data, GLenum drawMode)
ProgramD3D *programD3D = GetImplAs<ProgramD3D>(program);
programD3D->updateCachedInputLayout(*data.state);
gl::Error error = applyShadersImpl(data, drawMode);
if (error.isError())
{
return error;
}
ANGLE_TRY(applyShadersImpl(data, drawMode));
return programD3D->applyUniforms(drawMode);
}
......@@ -411,45 +320,23 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shade
!std::binary_search(framebufferTextures.begin(),
framebufferTextures.begin() + framebufferTextureCount, texture))
{
gl::Error error = setSamplerState(shaderType, samplerIndex, texture, samplerState);
if (error.isError())
{
return error;
}
error = setTexture(shaderType, samplerIndex, texture);
if (error.isError())
{
return error;
}
ANGLE_TRY(setSamplerState(shaderType, samplerIndex, texture, samplerState));
ANGLE_TRY(setTexture(shaderType, samplerIndex, texture));
}
else
{
// Texture is not sampler complete or it is in use by the framebuffer. Bind the incomplete texture.
gl::Texture *incompleteTexture = getIncompleteTexture(textureType);
gl::Error error = setSamplerState(shaderType, samplerIndex, incompleteTexture,
incompleteTexture->getSamplerState());
if (error.isError())
{
return error;
}
error = setTexture(shaderType, samplerIndex, incompleteTexture);
if (error.isError())
{
return error;
}
ANGLE_TRY(setSamplerState(shaderType, samplerIndex, incompleteTexture,
incompleteTexture->getSamplerState()));
ANGLE_TRY(setTexture(shaderType, samplerIndex, incompleteTexture));
}
}
else
{
// No texture bound to this slot even though it is used by the shader, bind a NULL texture
gl::Error error = setTexture(shaderType, samplerIndex, NULL);
if (error.isError())
{
return error;
}
ANGLE_TRY(setTexture(shaderType, samplerIndex, nullptr));
}
}
......@@ -458,7 +345,7 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shade
: data.caps->maxVertexTextureImageUnits;
clearTextures(shaderType, samplerRange, samplerCount);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error RendererD3D::applyTextures(const gl::Data &data)
......@@ -466,19 +353,9 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data)
FramebufferTextureArray framebufferTextures;
size_t framebufferSerialCount = getBoundFramebufferTextures(data, &framebufferTextures);
gl::Error error = applyTextures(data, gl::SAMPLER_VERTEX, framebufferTextures, framebufferSerialCount);
if (error.isError())
{
return error;
}
error = applyTextures(data, gl::SAMPLER_PIXEL, framebufferTextures, framebufferSerialCount);
if (error.isError())
{
return error;
}
return gl::Error(GL_NO_ERROR);
ANGLE_TRY(applyTextures(data, gl::SAMPLER_VERTEX, framebufferTextures, framebufferSerialCount));
ANGLE_TRY(applyTextures(data, gl::SAMPLER_PIXEL, framebufferTextures, framebufferSerialCount));
return gl::NoError();
}
bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode)
......@@ -522,15 +399,11 @@ gl::Error RendererD3D::markTransformFeedbackUsage(const gl::Data &data)
if (binding.get() != nullptr)
{
BufferD3D *bufferD3D = GetImplAs<BufferD3D>(binding.get());
auto error = bufferD3D->markTransformFeedbackUsage();
if (error.isError())
{
return error;
}
ANGLE_TRY(bufferD3D->markTransformFeedbackUsage());
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray)
......@@ -711,4 +584,4 @@ gl::DebugAnnotator *RendererD3D::getAnnotator()
ASSERT(mAnnotator);
return mAnnotator;
}
}
} // namespace rx
......@@ -94,13 +94,8 @@ gl::ErrorOrResult<unsigned int> VertexBufferInterface::getSpaceRequired(
GLsizei count,
GLsizei instances) const
{
auto errorOrSpaceRequired = mFactory->getVertexSpaceRequired(attrib, count, instances);
if (errorOrSpaceRequired.isError())
{
return errorOrSpaceRequired.getError();
}
unsigned int spaceRequired = errorOrSpaceRequired.getResult();
unsigned int spaceRequired = 0;
ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(attrib, count, instances), spaceRequired);
// Align to 16-byte boundary
unsigned int alignedSpaceRequired = roundUp(spaceRequired, 16u);
......@@ -141,24 +136,16 @@ gl::Error StreamingVertexBufferInterface::reserveSpace(unsigned int size)
unsigned int curBufferSize = getBufferSize();
if (size > curBufferSize)
{
gl::Error error = setBufferSize(std::max(size, 3 * curBufferSize / 2));
if (error.isError())
{
return error;
}
ANGLE_TRY(setBufferSize(std::max(size, 3 * curBufferSize / 2)));
mWritePosition = 0;
}
else if (mWritePosition + size > curBufferSize)
{
gl::Error error = discard();
if (error.isError())
{
return error;
}
ANGLE_TRY(discard());
mWritePosition = 0;
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error StreamingVertexBufferInterface::storeDynamicAttribute(const gl::VertexAttribute &attrib,
......@@ -169,55 +156,37 @@ gl::Error StreamingVertexBufferInterface::storeDynamicAttribute(const gl::Vertex
unsigned int *outStreamOffset,
const uint8_t *sourceData)
{
auto spaceRequiredOrError = getSpaceRequired(attrib, count, instances);
if (spaceRequiredOrError.isError())
{
return spaceRequiredOrError.getError();
}
unsigned int alignedSpaceRequired = spaceRequiredOrError.getResult();
unsigned int spaceRequired = 0;
ANGLE_TRY_RESULT(getSpaceRequired(attrib, count, instances), spaceRequired);
// Protect against integer overflow
if (!IsUnsignedAdditionSafe(mWritePosition, alignedSpaceRequired))
if (!IsUnsignedAdditionSafe(mWritePosition, spaceRequired))
{
return gl::Error(GL_OUT_OF_MEMORY, "Internal error, new vertex buffer write position would overflow.");
}
gl::Error error = reserveSpace(mReservedSpace);
if (error.isError())
{
return error;
}
ANGLE_TRY(reserveSpace(mReservedSpace));
mReservedSpace = 0;
error = mVertexBuffer->storeVertexAttributes(attrib, currentValueType, start, count, instances,
mWritePosition, sourceData);
if (error.isError())
{
return error;
}
ANGLE_TRY(mVertexBuffer->storeVertexAttributes(attrib, currentValueType, start, count,
instances, mWritePosition, sourceData));
if (outStreamOffset)
{
*outStreamOffset = mWritePosition;
}
mWritePosition += alignedSpaceRequired;
mWritePosition += spaceRequired;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error StreamingVertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib,
GLsizei count,
GLsizei instances)
{
auto errorOrRequiredSpace = mFactory->getVertexSpaceRequired(attrib, count, instances);
if (errorOrRequiredSpace.isError())
{
return errorOrRequiredSpace.getError();
}
unsigned int requiredSpace = errorOrRequiredSpace.getResult();
unsigned int requiredSpace = 0;
ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(attrib, count, instances), requiredSpace);
// Align to 16-byte boundary
unsigned int alignedRequiredSpace = roundUp(requiredSpace, 16u);
......@@ -234,7 +203,7 @@ gl::Error StreamingVertexBufferInterface::reserveVertexSpace(const gl::VertexAtt
mReservedSpace += alignedRequiredSpace;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
// StaticVertexBufferInterface Implementation
......@@ -293,24 +262,17 @@ gl::Error StaticVertexBufferInterface::storeStaticAttribute(const gl::VertexAttr
GLsizei instances,
const uint8_t *sourceData)
{
auto spaceRequiredOrError = getSpaceRequired(attrib, count, instances);
if (spaceRequiredOrError.isError())
{
return spaceRequiredOrError.getError();
}
setBufferSize(spaceRequiredOrError.getResult());
unsigned int spaceRequired = 0;
ANGLE_TRY_RESULT(getSpaceRequired(attrib, count, instances), spaceRequired);
setBufferSize(spaceRequired);
ASSERT(attrib.enabled);
gl::Error error = mVertexBuffer->storeVertexAttributes(attrib, GL_NONE, start, count, instances,
0, sourceData);
if (!error.isError())
{
mSignature.set(attrib);
mVertexBuffer->hintUnmapResource();
}
ANGLE_TRY(mVertexBuffer->storeVertexAttributes(attrib, GL_NONE, start, count, instances, 0,
sourceData));
return error;
mSignature.set(attrib);
mVertexBuffer->hintUnmapResource();
return gl::NoError();
}
} // namespace rx
......@@ -290,45 +290,28 @@ Buffer11::~Buffer11()
gl::Error Buffer11::setData(const void *data, size_t size, GLenum usage)
{
updateD3DBufferUsage(usage);
gl::Error error = setSubData(data, size, 0);
if (error.isError())
{
return error;
}
return error;
ANGLE_TRY(setSubData(data, size, 0));
return gl::NoError();
}
gl::Error Buffer11::getData(const uint8_t **outData)
{
auto systemOrError = getSystemMemoryStorage();
if (systemOrError.isError())
{
*outData = nullptr;
return systemOrError.getError();
}
SystemMemoryStorage *systemMemoryStorage = systemOrError.getResult();
SystemMemoryStorage *systemMemoryStorage = nullptr;
ANGLE_TRY_RESULT(getSystemMemoryStorage(), systemMemoryStorage);
mReadUsageCount = 0;
ASSERT(systemMemoryStorage->getSize() >= mSize);
*outData = systemMemoryStorage->getSystemCopy()->data();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::ErrorOrResult<Buffer11::SystemMemoryStorage *> Buffer11::getSystemMemoryStorage()
{
auto systemOrError = getBufferStorage(BUFFER_USAGE_SYSTEM_MEMORY);
if (systemOrError.isError())
{
return systemOrError.getError();
}
auto resultT = GetAs<SystemMemoryStorage>(systemOrError.getResult());
return resultT;
BufferStorage *storage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_SYSTEM_MEMORY), storage);
return GetAs<SystemMemoryStorage>(storage);
}
gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
......@@ -342,23 +325,11 @@ gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
BufferStorage *writeBuffer = nullptr;
if (supportsDirectBinding())
{
auto stagingOrError = getStagingStorage();
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
writeBuffer = stagingOrError.getResult();
ANGLE_TRY_RESULT(getStagingStorage(), writeBuffer);
}
else
{
auto systemOrError = getSystemMemoryStorage();
if (systemOrError.isError())
{
return systemOrError.getError();
}
writeBuffer = systemOrError.getResult();
ANGLE_TRY_RESULT(getSystemMemoryStorage(), writeBuffer);
}
ASSERT(writeBuffer);
......@@ -368,11 +339,7 @@ gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
if (writeBuffer->getSize() < requiredSize)
{
bool preserveData = (offset > 0);
gl::Error error = writeBuffer->resize(requiredSize, preserveData);
if (error.isError())
{
return error;
}
ANGLE_TRY(writeBuffer->resize(requiredSize, preserveData));
}
writeBuffer->setData(static_cast<const uint8_t *>(data), offset, size);
......@@ -382,7 +349,7 @@ gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
mSize = std::max(mSize, requiredSize);
invalidateStaticData();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::copySubData(BufferImpl *source,
......@@ -393,29 +360,16 @@ gl::Error Buffer11::copySubData(BufferImpl *source,
Buffer11 *sourceBuffer = GetAs<Buffer11>(source);
ASSERT(sourceBuffer != nullptr);
auto latestOrError = getLatestBufferStorage();
if (latestOrError.isError())
{
return latestOrError.getError();
}
BufferStorage *copyDest = nullptr;
ANGLE_TRY_RESULT(getLatestBufferStorage(), copyDest);
BufferStorage *copyDest = latestOrError.getResult();
if (!copyDest)
{
auto stagingOrError = getStagingStorage();
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
copyDest = stagingOrError.getResult();
ANGLE_TRY_RESULT(getStagingStorage(), copyDest);
}
auto sourceLatestOrError = sourceBuffer->getLatestBufferStorage();
if (sourceLatestOrError.isError())
{
return sourceLatestOrError.getError();
}
BufferStorage *copySource = sourceLatestOrError.getResult();
BufferStorage *copySource = nullptr;
ANGLE_TRY_RESULT(sourceBuffer->getLatestBufferStorage(), copySource);
if (!copySource || !copyDest)
{
......@@ -426,21 +380,11 @@ gl::Error Buffer11::copySubData(BufferImpl *source,
// pack buffer partner, because other native buffers can't be mapped
if (copyDest->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copySource->isMappable())
{
auto sourceStagingOrError = sourceBuffer->getStagingStorage();
if (sourceStagingOrError.isError())
{
return sourceStagingOrError.getError();
}
copySource = sourceStagingOrError.getResult();
ANGLE_TRY_RESULT(sourceBuffer->getStagingStorage(), copySource);
}
else if (copySource->getUsage() == BUFFER_USAGE_PIXEL_PACK && !copyDest->isMappable())
{
auto stagingOrError = getStagingStorage();
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
copyDest = stagingOrError.getResult();
ANGLE_TRY_RESULT(getStagingStorage(), copyDest);
}
// D3D11 does not allow overlapped copies until 11.1, and only if the
......@@ -450,35 +394,24 @@ gl::Error Buffer11::copySubData(BufferImpl *source,
{
if (copySource->getUsage() == BUFFER_USAGE_STAGING)
{
auto vertexOrError = getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
if (vertexOrError.isError())
{
return vertexOrError.getError();
}
copySource = vertexOrError.getResult();
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK),
copySource);
}
else
{
auto stagingOrError = getStagingStorage();
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
copySource = stagingOrError.getResult();
ANGLE_TRY_RESULT(getStagingStorage(), copySource);
}
}
auto resultOrError = copyDest->copyFromStorage(copySource, sourceOffset, size, destOffset);
if (resultOrError.isError())
{
return resultOrError.getError();
}
CopyResult copyResult = CopyResult::NOT_RECREATED;
ANGLE_TRY_RESULT(copyDest->copyFromStorage(copySource, sourceOffset, size, destOffset),
copyResult);
copyDest->setDataRevision(copyDest->getDataRevision() + 1);
mSize = std::max<size_t>(mSize, destOffset + size);
invalidateStaticData();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::map(GLenum access, GLvoid **mapPtr)
......@@ -493,12 +426,9 @@ gl::Error Buffer11::mapRange(size_t offset, size_t length, GLbitfield access, GL
{
ASSERT(!mMappedStorage);
auto latestOrError = getLatestBufferStorage();
if (latestOrError.isError())
{
return latestOrError.getError();
}
BufferStorage *latestStorage = latestOrError.getResult();
BufferStorage *latestStorage = nullptr;
ANGLE_TRY_RESULT(getLatestBufferStorage(), latestStorage);
if (latestStorage && (latestStorage->getUsage() == BUFFER_USAGE_PIXEL_PACK ||
latestStorage->getUsage() == BUFFER_USAGE_STAGING))
{
......@@ -507,14 +437,9 @@ gl::Error Buffer11::mapRange(size_t offset, size_t length, GLbitfield access, GL
}
else
{
// Fall back to using the staging buffer if the latest storage does
// not exist or is not CPU-accessible.
auto stagingOrError = getStagingStorage();
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
mMappedStorage = stagingOrError.getResult();
// Fall back to using the staging buffer if the latest storage does not exist or is not
// CPU-accessible.
ANGLE_TRY_RESULT(getStagingStorage(), mMappedStorage);
}
if (!mMappedStorage)
......@@ -530,15 +455,11 @@ gl::Error Buffer11::mapRange(size_t offset, size_t length, GLbitfield access, GL
}
uint8_t *mappedBuffer = nullptr;
auto error = mMappedStorage->map(offset, length, access, &mappedBuffer);
if (error.isError())
{
return error;
}
ANGLE_TRY(mMappedStorage->map(offset, length, access, &mappedBuffer));
ASSERT(mappedBuffer);
*mapPtr = static_cast<GLvoid *>(mappedBuffer);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::unmap(GLboolean *result)
......@@ -550,25 +471,22 @@ gl::Error Buffer11::unmap(GLboolean *result)
// TODO: detect if we had corruption. if so, return false.
*result = GL_TRUE;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::markTransformFeedbackUsage()
{
auto tfOrError = getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
if (tfOrError.isError())
{
return tfOrError.getError();
}
BufferStorage *transformFeedbackStorage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK),
transformFeedbackStorage);
BufferStorage *transformFeedbackStorage = tfOrError.getResult();
if (transformFeedbackStorage)
{
transformFeedbackStorage->setDataRevision(transformFeedbackStorage->getDataRevision() + 1);
}
invalidateStaticData();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::markBufferUsage()
......@@ -581,93 +499,58 @@ gl::Error Buffer11::markBufferUsage()
BufferStorage *&sysMemUsage = mBufferStorages[BUFFER_USAGE_SYSTEM_MEMORY];
if (mReadUsageCount > usageLimit && sysMemUsage != nullptr)
{
auto latestOrError = getLatestBufferStorage();
if (latestOrError.isError())
{
return latestOrError.getError();
}
if (latestOrError.getResult() != sysMemUsage)
BufferStorage *latestStorage = nullptr;
ANGLE_TRY_RESULT(getLatestBufferStorage(), latestStorage);
if (latestStorage != sysMemUsage)
{
SafeDelete(sysMemUsage);
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getBuffer(BufferUsage usage)
{
gl::Error error = markBufferUsage();
if (error.isError())
{
return error;
}
ANGLE_TRY(markBufferUsage());
auto bufferOrError = getBufferStorage(usage);
if (bufferOrError.isError())
{
return bufferOrError.getError();
}
return GetAs<NativeStorage>(bufferOrError.getResult())->getNativeStorage();
BufferStorage *storage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(usage), storage);
return GetAs<NativeStorage>(storage)->getNativeStorage();
}
gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getEmulatedIndexedBuffer(
SourceIndexData *indexInfo,
const TranslatedAttribute &attribute)
{
gl::Error error = markBufferUsage();
if (error.isError())
{
return error;
}
ASSERT(indexInfo);
auto emulatedOrError = getBufferStorage(BUFFER_USAGE_EMULATED_INDEXED_VERTEX);
if (emulatedOrError.isError())
{
return emulatedOrError.getError();
}
ANGLE_TRY(markBufferUsage());
EmulatedIndexedStorage *emulatedStorage =
GetAs<EmulatedIndexedStorage>(emulatedOrError.getResult());
auto errorOrResult = emulatedStorage->getNativeStorage(indexInfo, attribute);
BufferStorage *untypedStorage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_EMULATED_INDEXED_VERTEX), untypedStorage);
if (errorOrResult.isError())
{
return errorOrResult.getError();
}
EmulatedIndexedStorage *emulatedStorage = GetAs<EmulatedIndexedStorage>(untypedStorage);
return errorOrResult.getResult();
ID3D11Buffer *nativeStorage = nullptr;
ANGLE_TRY_RESULT(emulatedStorage->getNativeStorage(indexInfo, attribute), nativeStorage);
return nativeStorage;
}
gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getConstantBufferRange(GLintptr offset, GLsizeiptr size)
{
gl::Error error = markBufferUsage();
if (error.isError())
{
return error;
}
ANGLE_TRY(markBufferUsage());
BufferStorage *bufferStorage;
BufferStorage *bufferStorage = nullptr;
if (offset == 0)
{
auto uniformOrError = getBufferStorage(BUFFER_USAGE_UNIFORM);
if (uniformOrError.isError())
{
return uniformOrError.getError();
}
bufferStorage = uniformOrError.getResult();
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_UNIFORM), bufferStorage);
}
else
{
auto constantOrError = getConstantBufferRangeStorage(offset, size);
if (constantOrError.isError())
{
return constantOrError.getError();
}
bufferStorage = constantOrError.getResult();
ANGLE_TRY_RESULT(getConstantBufferRangeStorage(offset, size), bufferStorage);
}
return GetAs<NativeStorage>(bufferStorage)->getNativeStorage();
......@@ -675,12 +558,8 @@ gl::ErrorOrResult<ID3D11Buffer *> Buffer11::getConstantBufferRange(GLintptr offs
gl::ErrorOrResult<ID3D11ShaderResourceView *> Buffer11::getSRV(DXGI_FORMAT srvFormat)
{
auto unpackOrError = getBufferStorage(BUFFER_USAGE_PIXEL_UNPACK);
if (unpackOrError.isError())
{
return unpackOrError.getError();
}
BufferStorage *storage = unpackOrError.getResult();
BufferStorage *storage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_PIXEL_UNPACK), storage);
ID3D11Buffer *buffer = GetAs<NativeStorage>(storage)->getNativeStorage();
auto bufferSRVIt = mBufferResourceViews.find(srvFormat);
......@@ -722,29 +601,17 @@ gl::ErrorOrResult<ID3D11ShaderResourceView *> Buffer11::getSRV(DXGI_FORMAT srvFo
gl::Error Buffer11::packPixels(const gl::FramebufferAttachment &readAttachment,
const PackPixelsParams &params)
{
auto packOrError = getPackStorage();
if (packOrError.isError())
{
return packOrError.getError();
}
PackStorage *packStorage = packOrError.getResult();
PackStorage *packStorage = nullptr;
ANGLE_TRY_RESULT(getPackStorage(), packStorage);
auto latestOrError = getLatestBufferStorage();
if (latestOrError.isError())
{
return latestOrError.getError();
}
BufferStorage *latestStorage = latestOrError.getResult();
BufferStorage *latestStorage = nullptr;
ANGLE_TRY_RESULT(getLatestBufferStorage(), latestStorage);
ASSERT(packStorage);
gl::Error error = packStorage->packPixels(readAttachment, params);
if (error.isError())
{
return error;
}
ANGLE_TRY(packStorage->packPixels(readAttachment, params));
packStorage->setDataRevision(latestStorage ? latestStorage->getDataRevision() + 1 : 1);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
size_t Buffer11::getTotalCPUBufferMemoryBytes() const
......@@ -789,18 +656,10 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getBufferStorage(BufferUs
// resize buffer
if (newStorage->getSize() < mSize)
{
auto error = newStorage->resize(mSize, true);
if (error.isError())
{
return error;
}
ANGLE_TRY(newStorage->resize(mSize, true));
}
auto error = updateBufferStorage(newStorage, 0, mSize);
if (error.isError())
{
return error;
}
ANGLE_TRY(updateBufferStorage(newStorage, 0, mSize));
return newStorage;
}
......@@ -850,12 +709,7 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getConstantBufferRangeSto
mConstantBufferRangeStoragesCache.erase(iter);
}
auto error = newStorage->resize(size, false);
if (error.isError())
{
return error;
}
ANGLE_TRY(newStorage->resize(size, false));
mConstantBufferStorageAdditionalSize += sizeDelta;
// We don't copy the old data when resizing the constant buffer because the data may be
......@@ -864,12 +718,7 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getConstantBufferRangeSto
newStorage->setDataRevision(0);
}
auto error = updateBufferStorage(newStorage, offset, size);
if (error.isError())
{
return error;
}
ANGLE_TRY(updateBufferStorage(newStorage, offset, size));
return newStorage;
}
......@@ -877,13 +726,9 @@ gl::Error Buffer11::updateBufferStorage(BufferStorage *storage,
size_t sourceOffset,
size_t storageSize)
{
auto latestOrError = getLatestBufferStorage();
if (latestOrError.isError())
{
return latestOrError.getError();
}
BufferStorage *latestBuffer = nullptr;
ANGLE_TRY_RESULT(getLatestBufferStorage(), latestBuffer);
BufferStorage *latestBuffer = latestOrError.getResult();
if (latestBuffer && latestBuffer->getDataRevision() > storage->getDataRevision())
{
// Copy through a staging buffer if we're copying from or to a non-staging, mappable
......@@ -893,38 +738,30 @@ gl::Error Buffer11::updateBufferStorage(BufferStorage *storage,
storage->getUsage() != BUFFER_USAGE_STAGING &&
(!latestBuffer->isMappable() || !storage->isMappable()))
{
auto stagingOrError = getStagingStorage();
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
NativeStorage *stagingBuffer = stagingOrError.getResult();
NativeStorage *stagingBuffer = nullptr;
ANGLE_TRY_RESULT(getStagingStorage(), stagingBuffer);
auto resultOrError =
stagingBuffer->copyFromStorage(latestBuffer, 0, latestBuffer->getSize(), 0);
if (resultOrError.isError())
{
return resultOrError.getError();
}
CopyResult copyResult = CopyResult::NOT_RECREATED;
ANGLE_TRY_RESULT(
stagingBuffer->copyFromStorage(latestBuffer, 0, latestBuffer->getSize(), 0),
copyResult);
stagingBuffer->setDataRevision(latestBuffer->getDataRevision());
latestBuffer = stagingBuffer;
}
auto resultOrError = storage->copyFromStorage(latestBuffer, sourceOffset, storageSize, 0);
if (resultOrError.isError())
{
return resultOrError.getError();
}
CopyResult copyResult = CopyResult::NOT_RECREATED;
ANGLE_TRY_RESULT(storage->copyFromStorage(latestBuffer, sourceOffset, storageSize, 0),
copyResult);
// If the D3D buffer has been recreated, we should update our serial.
if (resultOrError.getResult() == CopyResult::RECREATED)
if (copyResult == CopyResult::RECREATED)
{
updateSerial();
}
storage->setDataRevision(latestBuffer->getDataRevision());
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getLatestBufferStorage() const
......@@ -945,11 +782,7 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getLatestBufferStorage()
// resize buffer
if (latestStorage && latestStorage->getSize() < mSize)
{
auto error = latestStorage->resize(mSize, true);
if (error.isError())
{
return error;
}
ANGLE_TRY(latestStorage->resize(mSize, true));
}
return latestStorage;
......@@ -957,24 +790,16 @@ gl::ErrorOrResult<Buffer11::BufferStorage *> Buffer11::getLatestBufferStorage()
gl::ErrorOrResult<Buffer11::NativeStorage *> Buffer11::getStagingStorage()
{
auto stagingOrError = getBufferStorage(BUFFER_USAGE_STAGING);
if (stagingOrError.isError())
{
return stagingOrError.getError();
}
return GetAs<NativeStorage>(stagingOrError.getResult());
BufferStorage *stagingStorage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_STAGING), stagingStorage);
return GetAs<NativeStorage>(stagingStorage);
}
gl::ErrorOrResult<Buffer11::PackStorage *> Buffer11::getPackStorage()
{
auto packOrError = getBufferStorage(BUFFER_USAGE_PIXEL_PACK);
if (packOrError.isError())
{
return packOrError.getError();
}
return GetAs<PackStorage>(packOrError.getResult());
BufferStorage *packStorage = nullptr;
ANGLE_TRY_RESULT(getBufferStorage(BUFFER_USAGE_PIXEL_PACK), packStorage);
return GetAs<PackStorage>(packStorage);
}
bool Buffer11::supportsDirectBinding() const
......@@ -995,17 +820,13 @@ gl::Error Buffer11::BufferStorage::setData(const uint8_t *data, size_t offset, s
ASSERT(isMappable());
uint8_t *writePointer = nullptr;
gl::Error error = map(offset, size, GL_MAP_WRITE_BIT, &writePointer);
if (error.isError())
{
return error;
}
ANGLE_TRY(map(offset, size, GL_MAP_WRITE_BIT, &writePointer));
memcpy(writePointer, data, size);
unmap();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
Buffer11::NativeStorage::NativeStorage(Renderer11 *renderer, BufferUsage usage)
......@@ -1042,11 +863,7 @@ gl::ErrorOrResult<CopyResult> Buffer11::NativeStorage::copyFromStorage(BufferSto
ASSERT(source->isMappable());
uint8_t *sourcePointer = nullptr;
gl::Error error = source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourcePointer);
if (error.isError())
{
return error;
}
ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourcePointer));
D3D11_MAPPED_SUBRESOURCE mappedResource;
HRESULT hr = context->Map(mNativeStorage, 0, D3D11_MAP_WRITE, 0, &mappedResource);
......@@ -1128,7 +945,7 @@ gl::Error Buffer11::NativeStorage::resize(size_t size, bool preserveData)
mBufferSize = bufferDesc.ByteWidth;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
void Buffer11::NativeStorage::fillBufferDesc(D3D11_BUFFER_DESC *bufferDesc,
......@@ -1353,11 +1170,7 @@ gl::ErrorOrResult<CopyResult> Buffer11::EmulatedIndexedStorage::copyFromStorage(
{
ASSERT(source->isMappable());
uint8_t *sourceData = nullptr;
gl::Error error = source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData);
if (error.isError())
{
return error;
}
ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
ASSERT(destOffset + size <= mMemoryBuffer.size());
memcpy(mMemoryBuffer.data() + destOffset, sourceData, size);
source->unmap();
......@@ -1438,11 +1251,7 @@ gl::Error Buffer11::PackStorage::map(size_t offset,
// and if D3D packs the staging texture memory identically to how we would fill
// the pack buffer according to the current pack state.
gl::Error error = flushQueuedPackCommand();
if (error.isError())
{
return error;
}
ANGLE_TRY(flushQueuedPackCommand());
mDataModified = (mDataModified || (access & GL_MAP_WRITE_BIT) != 0);
......@@ -1458,18 +1267,10 @@ void Buffer11::PackStorage::unmap()
gl::Error Buffer11::PackStorage::packPixels(const gl::FramebufferAttachment &readAttachment,
const PackPixelsParams &params)
{
gl::Error error = flushQueuedPackCommand();
if (error.isError())
{
return error;
}
ANGLE_TRY(flushQueuedPackCommand());
RenderTarget11 *renderTarget = nullptr;
error = readAttachment.getRenderTarget(&renderTarget);
if (error.isError())
{
return error;
}
ANGLE_TRY(readAttachment.getRenderTarget(&renderTarget));
ID3D11Resource *renderTargetResource = renderTarget->getTexture();
ASSERT(renderTargetResource);
......@@ -1484,14 +1285,10 @@ gl::Error Buffer11::PackStorage::packPixels(const gl::FramebufferAttachment &rea
if (!mStagingTexture.getResource() || mStagingTexture.getFormat() != srcTexture.getFormat() ||
mStagingTexture.getExtents() != srcTextureSize)
{
auto textureOrError = CreateStagingTexture(
srcTexture.getTextureType(), srcTexture.getFormat(), srcTexture.getANGLEFormat(),
srcTextureSize, mRenderer->getDevice());
if (textureOrError.isError())
{
return textureOrError.getError();
}
mStagingTexture = std::move(textureOrError.getResult());
ANGLE_TRY_RESULT(CreateStagingTexture(srcTexture.getTextureType(), srcTexture.getFormat(),
srcTexture.getANGLEFormat(), srcTextureSize,
mRenderer->getDevice()),
mStagingTexture);
}
// ReadPixels from multisampled FBOs isn't supported in current GL
......@@ -1516,7 +1313,7 @@ gl::Error Buffer11::PackStorage::packPixels(const gl::FramebufferAttachment &rea
immediateContext->CopySubresourceRegion(mStagingTexture.getResource(), 0, 0, 0, 0,
srcTexture.getResource(), srcSubresource, &srcBox);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::PackStorage::flushQueuedPackCommand()
......@@ -1525,16 +1322,12 @@ gl::Error Buffer11::PackStorage::flushQueuedPackCommand()
if (mQueuedPackCommand)
{
gl::Error error =
mRenderer->packPixels(mStagingTexture, *mQueuedPackCommand, mMemoryBuffer.data());
ANGLE_TRY(
mRenderer->packPixels(mStagingTexture, *mQueuedPackCommand, mMemoryBuffer.data()));
mQueuedPackCommand.reset(nullptr);
if (error.isError())
{
return error;
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
Buffer11::SystemMemoryStorage::SystemMemoryStorage(Renderer11 *renderer)
......@@ -1549,11 +1342,7 @@ gl::ErrorOrResult<CopyResult> Buffer11::SystemMemoryStorage::copyFromStorage(Buf
{
ASSERT(source->isMappable());
uint8_t *sourceData = nullptr;
gl::Error error = source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData);
if (error.isError())
{
return error;
}
ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
ASSERT(destOffset + size <= mSystemCopy.size());
memcpy(mSystemCopy.data() + destOffset, sourceData, size);
source->unmap();
......@@ -1571,7 +1360,7 @@ gl::Error Buffer11::SystemMemoryStorage::resize(size_t size, bool preserveData)
mBufferSize = size;
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error Buffer11::SystemMemoryStorage::map(size_t offset,
......
......@@ -241,11 +241,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(
}
}
gl::Error error = updateInputLayout(state, mode, sortedSemanticIndices, numIndicesPerInstance);
if (error.isError())
{
return error;
}
ANGLE_TRY(updateInputLayout(state, mode, sortedSemanticIndices, numIndicesPerInstance));
bool dirtyBuffers = false;
size_t minDiff = gl::MAX_VERTEX_ATTRIBS;
......@@ -280,11 +276,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(
if (indexInfo->srcIndexData.srcBuffer != nullptr)
{
const uint8_t *bufferData = nullptr;
error = indexInfo->srcIndexData.srcBuffer->getData(&bufferData);
if (error.isError())
{
return error;
}
ANGLE_TRY(indexInfo->srcIndexData.srcBuffer->getData(&bufferData));
ASSERT(bufferData != nullptr);
ptrdiff_t offset =
......@@ -293,23 +285,14 @@ gl::Error InputLayoutCache::applyVertexBuffers(
indexInfo->srcIndexData.srcIndices = bufferData + offset;
}
auto bufferOrError =
bufferStorage->getEmulatedIndexedBuffer(&indexInfo->srcIndexData, attrib);
if (bufferOrError.isError())
{
return bufferOrError.getError();
}
buffer = bufferOrError.getResult();
ANGLE_TRY_RESULT(
bufferStorage->getEmulatedIndexedBuffer(&indexInfo->srcIndexData, attrib),
buffer);
}
else
{
auto bufferOrError =
bufferStorage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK);
if (bufferOrError.isError())
{
return bufferOrError.getError();
}
buffer = bufferOrError.getResult();
ANGLE_TRY_RESULT(
bufferStorage->getBuffer(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK), buffer);
}
vertexStride = attrib.stride;
......@@ -428,7 +411,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(
&mCurrentVertexOffsets[minDiff]);
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error InputLayoutCache::updateVertexOffsetsForPointSpritesEmulation(GLsizei emulatedInstanceId)
......@@ -449,7 +432,7 @@ gl::Error InputLayoutCache::updateVertexOffsetsForPointSpritesEmulation(GLsizei
mDeviceContext->IASetVertexBuffers(0, gl::MAX_VERTEX_ATTRIBS, mCurrentBuffers.data(),
mCurrentVertexStrides.data(), mCurrentVertexOffsets.data());
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error InputLayoutCache::updateInputLayout(const gl::State &state,
......@@ -509,12 +492,8 @@ gl::Error InputLayoutCache::updateInputLayout(const gl::State &state,
}
else
{
gl::Error error = createInputLayout(sortedSemanticIndices, mode, program,
numIndicesPerInstance, &inputLayout);
if (error.isError())
{
return error;
}
ANGLE_TRY(createInputLayout(sortedSemanticIndices, mode, program, numIndicesPerInstance,
&inputLayout));
if (mLayoutMap.size() >= mCacheSize)
{
TRACE("Overflowed the limit of %u input layouts, purging half the cache.",
......@@ -544,7 +523,7 @@ gl::Error InputLayoutCache::updateInputLayout(const gl::State &state,
mCurrentIL = inputLayout;
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error InputLayoutCache::createInputLayout(const AttribIndexArray &sortedSemanticIndices,
......@@ -636,12 +615,7 @@ gl::Error InputLayoutCache::createInputLayout(const AttribIndexArray &sortedSema
const gl::InputLayout &shaderInputLayout = GetInputLayout(mCurrentAttributes);
ShaderExecutableD3D *shader = nullptr;
gl::Error error =
programD3D->getVertexExecutableForInputLayout(shaderInputLayout, &shader, nullptr);
if (error.isError())
{
return error;
}
ANGLE_TRY(programD3D->getVertexExecutableForInputLayout(shaderInputLayout, &shader, nullptr));
ShaderExecutableD3D *shader11 = GetAs<ShaderExecutable11>(shader);
......@@ -654,7 +628,7 @@ gl::Error InputLayoutCache::createInputLayout(const AttribIndexArray &sortedSema
"Failed to create internal input layout, HRESULT: 0x%08x", result);
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
} // namespace rx
......@@ -64,7 +64,7 @@ gl::Error PixelTransfer11::loadResources()
{
if (mResourcesLoaded)
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
HRESULT result = S_OK;
......@@ -141,17 +141,13 @@ gl::Error PixelTransfer11::loadResources()
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal buffer to texture geometry shader.");
}
gl::Error error = buildShaderMap();
if (error.isError())
{
return error;
}
ANGLE_TRY(buildShaderMap());
StructZero(&mParamsData);
mResourcesLoaded = true;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
......@@ -180,11 +176,7 @@ void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, cons
gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTargetD3D *destRenderTarget,
GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
{
gl::Error error = loadResources();
if (error.isError())
{
return error;
}
ANGLE_TRY(loadResources());
gl::Extents destSize = destRenderTarget->getExtents();
......@@ -208,12 +200,8 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac
DXGI_FORMAT srvFormat = sourceFormatInfo.formatSet->srvFormat;
ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
Buffer11 *bufferStorage11 = GetAs<Buffer11>(sourceBuffer.getImplementation());
auto srvOrError = bufferStorage11->getSRV(srvFormat);
if (srvOrError.isError())
{
return srvOrError.getError();
}
ID3D11ShaderResourceView *bufferSRV = srvOrError.getResult();
ID3D11ShaderResourceView *bufferSRV = nullptr;
ANGLE_TRY_RESULT(bufferStorage11->getSRV(srvFormat), bufferSRV);
ASSERT(bufferSRV != nullptr);
ID3D11RenderTargetView *textureRTV = GetAs<RenderTarget11>(destRenderTarget)->getRenderTargetView();
......@@ -272,7 +260,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac
mRenderer->markAllStateDirty();
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error PixelTransfer11::buildShaderMap()
......@@ -292,7 +280,7 @@ gl::Error PixelTransfer11::buildShaderMap()
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
ID3D11PixelShader *PixelTransfer11::findBufferToTexturePS(GLenum internalFormat) const
......@@ -307,4 +295,4 @@ ID3D11PixelShader *PixelTransfer11::findBufferToTexturePS(GLenum internalFormat)
return (shaderMapIt == mBufferToTexturePSMap.end() ? NULL : shaderMapIt->second);
}
}
} // namespace rx
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