Move index range calculations into VertexArray.
This is in preparation for removing the entire DrawCallParams struct.
This struct was big enough to cause a performance hit on draw call perf
tests just by virtue of initializing the fields. Also dereferencing the
struct members is slower than reading function parameters since it adds
an indirection.
Also includes some error refactoring to enable moving code to a shared
location.
In total this patch series reduces overhead by up to 5%.
Bug: angleproject:2933
Change-Id: Ib663f2538c14ac30d4c31fd10d6350be469626e2
Reviewed-on: https://chromium-review.googlesource.com/c/1298380
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index ffad3b1..9455035 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -437,7 +437,15 @@
const gl::AttributesMask &clientAttribs = context->getStateCache().getActiveClientAttribsMask();
ASSERT(clientAttribs.any());
- ANGLE_TRY_HANDLE(context, drawCallParams.ensureIndexRangeResolved(context));
+
+ GLint startVertex;
+ size_t vertexCount;
+ GLsizei vertexOrIndexCount = drawCallParams.isDrawElements() ? drawCallParams.indexCount()
+ : drawCallParams.vertexCount();
+ GLenum indexTypeOrNone = drawCallParams.isDrawElements() ? drawCallParams.type() : GL_NONE;
+ ANGLE_TRY(GetVertexRangeInfo(context, drawCallParams.firstVertex(), vertexOrIndexCount,
+ indexTypeOrNone, drawCallParams.indices(),
+ drawCallParams.baseVertex(), &startVertex, &vertexCount));
mDynamicVertexData.releaseRetainedBuffers(contextVk->getRenderer());
@@ -453,12 +461,11 @@
ASSERT(attrib.enabled && binding.getBuffer().get() == nullptr);
const size_t bytesToAllocate =
- (drawCallParams.firstVertex() + drawCallParams.vertexCount()) *
- mCurrentArrayBufferStrides[attribIndex];
- const uint8_t *src = static_cast<const uint8_t *>(attrib.pointer) +
- drawCallParams.firstVertex() * binding.getStride();
+ (startVertex + vertexCount) * mCurrentArrayBufferStrides[attribIndex];
+ const uint8_t *src =
+ static_cast<const uint8_t *>(attrib.pointer) + startVertex * binding.getStride();
- size_t destOffset = drawCallParams.firstVertex() * mCurrentArrayBufferStrides[attribIndex];
+ size_t destOffset = startVertex * mCurrentArrayBufferStrides[attribIndex];
ASSERT(GetVertexInputAlignment(*mCurrentArrayBufferFormats[attribIndex]) <=
kMaxVertexFormatAlignment);
@@ -467,11 +474,10 @@
// don't start at zero all the indices will be off.
// TODO(fjhenigman): See if we can account for indices being off by adjusting the
// offset, thus avoiding wasted memory.
- ANGLE_TRY(StreamVertexData(contextVk, &mDynamicVertexData, src, bytesToAllocate, destOffset,
- drawCallParams.vertexCount(), binding.getStride(),
- mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction,
- &mCurrentArrayBufferHandles[attribIndex],
- &mCurrentArrayBufferOffsets[attribIndex]));
+ ANGLE_TRY(StreamVertexData(
+ contextVk, &mDynamicVertexData, src, bytesToAllocate, destOffset, vertexCount,
+ binding.getStride(), mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction,
+ &mCurrentArrayBufferHandles[attribIndex], &mCurrentArrayBufferOffsets[attribIndex]));
}
return angle::Result::Continue();