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/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index 0dedc2f..afaec55 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -2018,15 +2018,15 @@
std::sort(&mAttributesByLayout[0], &mAttributesByLayout[gl::MAX_VERTEX_ATTRIBS], AttributeSorter(mSemanticIndex));
}
-void ProgramD3D::sortAttributesByLayout(const rx::TranslatedAttribute unsortedAttributes[gl::MAX_VERTEX_ATTRIBS],
+void ProgramD3D::sortAttributesByLayout(const std::vector<TranslatedAttribute> &unsortedAttributes,
int sortedSemanticIndicesOut[gl::MAX_VERTEX_ATTRIBS],
const rx::TranslatedAttribute *sortedAttributesOut[gl::MAX_VERTEX_ATTRIBS]) const
{
- for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
+ for (size_t attribIndex = 0; attribIndex < unsortedAttributes.size(); ++attribIndex)
{
- int oldIndex = mAttributesByLayout[i];
- sortedSemanticIndicesOut[i] = mSemanticIndex[oldIndex];
- sortedAttributesOut[i] = &unsortedAttributes[oldIndex];
+ int oldIndex = mAttributesByLayout[attribIndex];
+ sortedSemanticIndicesOut[attribIndex] = mSemanticIndex[oldIndex];
+ sortedAttributesOut[attribIndex] = &unsortedAttributes[oldIndex];
}
}