Commit 87718a87 by Jamie Madill Committed by Commit Bot

Use more gl::Error in IndexDataManager.

BUG=angleproject:2229 Change-Id: I19f7c1600300298e7bc2a1f7dc4215a67053767c Reviewed-on: https://chromium-review.googlesource.com/764674 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 8b920b21
......@@ -146,20 +146,12 @@ gl::Error StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, G
unsigned int writePos = getWritePosition();
if (size > curBufferSize)
{
gl::Error error = setBufferSize(std::max(size, 2 * curBufferSize), indexType);
if (error.isError())
{
return error;
}
ANGLE_TRY(setBufferSize(std::max(size, 2 * curBufferSize), indexType));
setWritePosition(0);
}
else if (writePos + size > curBufferSize || writePos + size < writePos)
{
gl::Error error = discard();
if (error.isError())
{
return error;
}
ANGLE_TRY(discard());
setWritePosition(0);
}
......@@ -194,4 +186,4 @@ gl::Error StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLen
}
}
}
} // namespace rx
......@@ -99,27 +99,14 @@ gl::Error StreamInIndexBuffer(IndexBufferInterface *buffer,
}
unsigned int bufferSizeRequired = count << dstTypeInfo.bytesShift;
gl::Error error = buffer->reserveBufferSpace(bufferSizeRequired, dstType);
if (error.isError())
{
return error;
}
ANGLE_TRY(buffer->reserveBufferSpace(bufferSizeRequired, dstType));
void *output = nullptr;
error = buffer->mapBuffer(bufferSizeRequired, &output, offset);
if (error.isError())
{
return error;
}
ANGLE_TRY(buffer->mapBuffer(bufferSizeRequired, &output, offset));
ConvertIndices(srcType, dstType, data, count, output, usePrimitiveRestartFixedIndex);
error = buffer->unmapBuffer();
if (error.isError())
{
return error;
}
ANGLE_TRY(buffer->unmapBuffer());
return gl::NoError();
}
......@@ -302,19 +289,11 @@ gl::Error IndexDataManager::prepareIndexData(const gl::Context *context,
if (staticBuffer == nullptr || !offsetAligned)
{
const uint8_t *bufferData = nullptr;
gl::Error error = buffer->getData(context, &bufferData);
if (error.isError())
{
return error;
}
ANGLE_TRY(buffer->getData(context, &bufferData));
ASSERT(bufferData != nullptr);
error = streamIndexData(bufferData + offset, count, srcType, dstType,
primitiveRestartFixedIndexEnabled, translated);
if (error.isError())
{
return error;
}
ANGLE_TRY(streamIndexData(bufferData + offset, count, srcType, dstType,
primitiveRestartFixedIndexEnabled, translated));
buffer->promoteStaticUsage(context, count << srcTypeInfo.bytesShift);
}
else
......@@ -322,21 +301,13 @@ gl::Error IndexDataManager::prepareIndexData(const gl::Context *context,
if (!staticBufferInitialized)
{
const uint8_t *bufferData = nullptr;
gl::Error error = buffer->getData(context, &bufferData);
if (error.isError())
{
return error;
}
ANGLE_TRY(buffer->getData(context, &bufferData));
ASSERT(bufferData != nullptr);
unsigned int convertCount =
static_cast<unsigned int>(buffer->getSize()) >> srcTypeInfo.bytesShift;
error = StreamInIndexBuffer(staticBuffer, bufferData, convertCount, srcType, dstType,
primitiveRestartFixedIndexEnabled, nullptr);
if (error.isError())
{
return error;
}
ANGLE_TRY(StreamInIndexBuffer(staticBuffer, bufferData, convertCount, srcType, dstType,
primitiveRestartFixedIndexEnabled, nullptr));
}
ASSERT(offsetAligned && staticBuffer->getIndexType() == dstType);
......@@ -359,11 +330,7 @@ gl::Error IndexDataManager::streamIndexData(const void *data,
const gl::Type &dstTypeInfo = gl::GetTypeInfo(dstType);
IndexBufferInterface *indexBuffer = nullptr;
gl::Error error = getStreamingIndexBuffer(dstType, &indexBuffer);
if (error.isError())
{
return error;
}
ANGLE_TRY(getStreamingIndexBuffer(dstType, &indexBuffer));
ASSERT(indexBuffer != nullptr);
unsigned int offset;
......
......@@ -1342,12 +1342,8 @@ gl::Error Renderer9::applyIndexBuffer(const gl::Context *context,
{
gl::VertexArray *vao = context->getGLState().getVertexArray();
gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get();
gl::Error error = mIndexDataManager->prepareIndexData(context, type, count, elementArrayBuffer,
indices, indexInfo, false);
if (error.isError())
{
return error;
}
ANGLE_TRY(mIndexDataManager->prepareIndexData(context, type, count, elementArrayBuffer, indices,
indexInfo, false));
// Directly binding the storage buffer is not supported for d3d9
ASSERT(indexInfo->storage == nullptr);
......
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