Commit 02b5328b by Jamie Madill Committed by Commit Bot

D3D: Make computeOffset not use ErrorOrResult.

Unblocks further error refactoring. Also cleans up some checked math logic. Bug: angleproject:2738 Change-Id: I0c9fba9bb908dfc8424921d0db9871241b86e7de Reviewed-on: https://chromium-review.googlesource.com/1142954Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 20d6d48c
...@@ -128,18 +128,21 @@ TranslatedAttribute::TranslatedAttribute() ...@@ -128,18 +128,21 @@ TranslatedAttribute::TranslatedAttribute()
TranslatedAttribute::TranslatedAttribute(const TranslatedAttribute &other) = default; TranslatedAttribute::TranslatedAttribute(const TranslatedAttribute &other) = default;
gl::ErrorOrResult<unsigned int> TranslatedAttribute::computeOffset(GLint startVertex) const gl::Error TranslatedAttribute::computeOffset(GLint startVertex, unsigned int *offsetOut) const
{ {
if (!usesFirstVertexOffset) if (!usesFirstVertexOffset)
{ {
return baseOffset; *offsetOut = baseOffset;
return gl::NoError();
} }
CheckedNumeric<unsigned int> offset; CheckedNumeric<unsigned int> offset(baseOffset);
CheckedNumeric<unsigned int> checkedStride(stride);
offset = baseOffset + stride * static_cast<unsigned int>(startVertex); offset += checkedStride * static_cast<unsigned int>(startVertex);
ANGLE_TRY_CHECKED_MATH(offset.IsValid()); ANGLE_TRY_CHECKED_MATH(offset.IsValid());
return offset.ValueOrDie(); *offsetOut = offset.ValueOrDie();
return gl::NoError();
} }
// Warning: you should ensure binding really matches attrib.bindingIndex before using this function. // Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
......
...@@ -52,7 +52,7 @@ struct TranslatedAttribute ...@@ -52,7 +52,7 @@ struct TranslatedAttribute
// Computes the correct offset from baseOffset, usesFirstVertexOffset, stride and startVertex. // Computes the correct offset from baseOffset, usesFirstVertexOffset, stride and startVertex.
// Can throw an error on integer overflow. // Can throw an error on integer overflow.
gl::ErrorOrResult<unsigned int> computeOffset(GLint startVertex) const; gl::Error computeOffset(GLint startVertex, unsigned int *offsetOut) const;
bool active; bool active;
......
...@@ -1270,7 +1270,7 @@ gl::Error Buffer11::EmulatedIndexedStorage::getBuffer(SourceIndexData *indexInfo ...@@ -1270,7 +1270,7 @@ gl::Error Buffer11::EmulatedIndexedStorage::getBuffer(SourceIndexData *indexInfo
if (!mBuffer.valid()) if (!mBuffer.valid())
{ {
unsigned int offset = 0; unsigned int offset = 0;
ANGLE_TRY_RESULT(attribute.computeOffset(startVertex), offset); ANGLE_TRY(attribute.computeOffset(startVertex, &offset));
// Expand the memory storage upon request and cache the results. // Expand the memory storage upon request and cache the results.
unsigned int expandedDataSize = unsigned int expandedDataSize =
......
...@@ -2756,7 +2756,7 @@ gl::Error StateManager11::applyVertexBuffers(const gl::Context *context, ...@@ -2756,7 +2756,7 @@ gl::Error StateManager11::applyVertexBuffers(const gl::Context *context,
} }
vertexStride = attrib.stride; vertexStride = attrib.stride;
ANGLE_TRY_RESULT(attrib.computeOffset(drawCallParams.firstVertex()), vertexOffset); ANGLE_TRY(attrib.computeOffset(drawCallParams.firstVertex(), &vertexOffset));
} }
size_t bufferIndex = reservedBuffers + attribIndex; size_t bufferIndex = reservedBuffers + attribIndex;
...@@ -2921,7 +2921,7 @@ gl::Error StateManager11::updateVertexOffsetsForPointSpritesEmulation(GLint star ...@@ -2921,7 +2921,7 @@ gl::Error StateManager11::updateVertexOffsetsForPointSpritesEmulation(GLint star
if (attrib.divisor > 0) if (attrib.divisor > 0)
{ {
unsigned int offset = 0; unsigned int offset = 0;
ANGLE_TRY_RESULT(attrib.computeOffset(startVertex), offset); ANGLE_TRY(attrib.computeOffset(startVertex, &offset));
offset += (attrib.stride * (emulatedInstanceId / attrib.divisor)); offset += (attrib.stride * (emulatedInstanceId / attrib.divisor));
if (offset != mCurrentVertexOffsets[bufferIndex]) if (offset != mCurrentVertexOffsets[bufferIndex])
{ {
......
...@@ -152,7 +152,7 @@ gl::Error VertexDeclarationCache::applyDeclaration( ...@@ -152,7 +152,7 @@ gl::Error VertexDeclarationCache::applyDeclaration(
VertexBuffer9 *vertexBuffer = GetAs<VertexBuffer9>(attributes[i].vertexBuffer.get()); VertexBuffer9 *vertexBuffer = GetAs<VertexBuffer9>(attributes[i].vertexBuffer.get());
unsigned int offset = 0; unsigned int offset = 0;
ANGLE_TRY_RESULT(attributes[i].computeOffset(start), offset); ANGLE_TRY(attributes[i].computeOffset(start, &offset));
if (mAppliedVBs[stream].serial != attributes[i].serial || if (mAppliedVBs[stream].serial != attributes[i].serial ||
mAppliedVBs[stream].stride != attributes[i].stride || mAppliedVBs[stream].stride != attributes[i].stride ||
......
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