Commit 46565a42 by Jamie Madill

Small optimization to VertexDataManager.

Avoid calling a getter repeatedly in a loop, when we can instead store a local reference to an array. BUG=angleproject:959 Change-Id: I507ad1a6cf3bb6183dd3499df024dfec6950a6c8 Reviewed-on: https://chromium-review.googlesource.com/277285Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5a0edc62
...@@ -594,7 +594,7 @@ const int *Program::getSemanticIndexes() const ...@@ -594,7 +594,7 @@ const int *Program::getSemanticIndexes() const
return mProgram->getSemanticIndexes(); return mProgram->getSemanticIndexes();
} }
int Program::getSemanticIndex(int attributeIndex) int Program::getSemanticIndex(int attributeIndex) const
{ {
ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS); ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
......
...@@ -189,7 +189,7 @@ class Program : angle::NonCopyable ...@@ -189,7 +189,7 @@ class Program : angle::NonCopyable
void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders); void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
GLuint getAttributeLocation(const std::string &name); GLuint getAttributeLocation(const std::string &name);
int getSemanticIndex(int attributeIndex); int getSemanticIndex(int attributeIndex) const;
const int *getSemanticIndexes() const; const int *getSemanticIndexes() const;
void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
......
...@@ -130,6 +130,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta ...@@ -130,6 +130,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
// Compute active enabled and active disable attributes, for speed. // Compute active enabled and active disable attributes, for speed.
// TODO(jmadill): don't recompute if there was no state change // TODO(jmadill): don't recompute if there was no state change
const gl::VertexArray *vertexArray = state.getVertexArray(); const gl::VertexArray *vertexArray = state.getVertexArray();
const int *semanticIndexes = state.getProgram()->getSemanticIndexes();
const std::vector<gl::VertexAttribute> &vertexAttributes = vertexArray->getVertexAttributes(); const std::vector<gl::VertexAttribute> &vertexAttributes = vertexArray->getVertexAttributes();
mActiveEnabledAttributes.clear(); mActiveEnabledAttributes.clear();
...@@ -137,7 +138,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta ...@@ -137,7 +138,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
for (size_t attribIndex = 0; attribIndex < vertexAttributes.size(); ++attribIndex) for (size_t attribIndex = 0; attribIndex < vertexAttributes.size(); ++attribIndex)
{ {
translated[attribIndex].active = (state.getProgram()->getSemanticIndex(attribIndex) != -1); translated[attribIndex].active = (semanticIndexes[attribIndex] != -1);
if (translated[attribIndex].active) if (translated[attribIndex].active)
{ {
// Record the attribute now // Record the attribute now
......
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