Use std::vector for TranslatedAttribs.
This allows us to cache a std::vector between calls, and avoids us
calling allocation/constructors for locals, which saves us some
time. It also allows us to use the vector's size to limit the range
of attribs we look at.
BUG=angleproject:959
Change-Id: I799ed6c92fa8fca96e92e235b125a11d2d551aab
Reviewed-on: https://chromium-review.googlesource.com/277286
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index bf49c20..517e236 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -119,8 +119,11 @@
}
}
-gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint start, GLsizei count,
- TranslatedAttribute *translated, GLsizei instances)
+gl::Error VertexDataManager::prepareVertexData(const gl::State &state,
+ GLint start,
+ GLsizei count,
+ std::vector<TranslatedAttribute> *translatedAttribs,
+ GLsizei instances)
{
if (!mStreamingBuffer)
{
@@ -135,20 +138,26 @@
mActiveEnabledAttributes.clear();
mActiveDisabledAttributes.clear();
+ translatedAttribs->clear();
for (size_t attribIndex = 0; attribIndex < vertexAttributes.size(); ++attribIndex)
{
- translated[attribIndex].active = (semanticIndexes[attribIndex] != -1);
- if (translated[attribIndex].active)
+ if (semanticIndexes[attribIndex] != -1)
{
+ // Resize automatically puts in empty attribs
+ translatedAttribs->resize(attribIndex + 1);
+
+ TranslatedAttribute *translated = &(*translatedAttribs)[attribIndex];
+
// Record the attribute now
- translated[attribIndex].attribute = &vertexAttributes[attribIndex];
- translated[attribIndex].currentValueType = state.getVertexAttribCurrentValue(attribIndex).Type;
- translated[attribIndex].divisor = vertexAttributes[attribIndex].divisor;
+ translated->active = true;
+ translated->attribute = &vertexAttributes[attribIndex];
+ translated->currentValueType = state.getVertexAttribCurrentValue(attribIndex).Type;
+ translated->divisor = vertexAttributes[attribIndex].divisor;
if (vertexAttributes[attribIndex].enabled)
{
- mActiveEnabledAttributes.push_back(&translated[attribIndex]);
+ mActiveEnabledAttributes.push_back(translated);
// Also invalidate static buffers that don't contain matching attributes
invalidateMatchingStaticData(vertexAttributes[attribIndex],
@@ -191,7 +200,7 @@
}
gl::Error error = storeCurrentValue(state.getVertexAttribCurrentValue(attribIndex),
- &translated[attribIndex],
+ &(*translatedAttribs)[attribIndex],
&mCurrentValueCache[attribIndex]);
if (error.isError())
{