Commit 56c6e3cb by Jamie Madill

Micro-optimize ValidateDrawBase.

This speeds up our draw call benchmark. BUG=angleproject:959 Change-Id: I9a916a6c344493cc96873ae5f4ec337c181dc487 Reviewed-on: https://chromium-review.googlesource.com/266026Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent eea3a6e0
...@@ -614,6 +614,11 @@ GLuint Program::getAttributeLocation(const std::string &name) ...@@ -614,6 +614,11 @@ GLuint Program::getAttributeLocation(const std::string &name)
return static_cast<GLuint>(-1); return static_cast<GLuint>(-1);
} }
const int *Program::getSemanticIndexes() const
{
return mProgram->getSemanticIndexes();
}
int Program::getSemanticIndex(int attributeIndex) int Program::getSemanticIndex(int attributeIndex)
{ {
ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS); ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
......
...@@ -135,6 +135,7 @@ class Program : angle::NonCopyable ...@@ -135,6 +135,7 @@ class Program : angle::NonCopyable
GLuint getAttributeLocation(const std::string &name); GLuint getAttributeLocation(const std::string &name);
int getSemanticIndex(int attributeIndex); int getSemanticIndex(int attributeIndex);
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);
GLint getActiveAttributeCount(); GLint getActiveAttributeCount();
......
...@@ -1401,10 +1401,12 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1401,10 +1401,12 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
// Buffer validations // Buffer validations
const VertexArray *vao = state.getVertexArray(); const VertexArray *vao = state.getVertexArray();
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) const auto &vertexAttribs = vao->getVertexAttributes();
const int *semanticIndexes = program->getSemanticIndexes();
for (size_t attributeIndex = 0; attributeIndex < vertexAttribs.size(); ++attributeIndex)
{ {
const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex); const VertexAttribute &attrib = vertexAttribs[attributeIndex];
bool attribActive = (program->getSemanticIndex(attributeIndex) != -1); bool attribActive = (semanticIndexes[attributeIndex] != -1);
if (attribActive && attrib.enabled) if (attribActive && attrib.enabled)
{ {
gl::Buffer *buffer = attrib.buffer.get(); gl::Buffer *buffer = attrib.buffer.get();
......
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