Optimize ShaderVariable::isBuiltIn.
This makes the check a bit faster, by inlining the prefix check.
Also some cleanups to ValidateVertexShaderAttributeTypeMatch.
BUG=angleproject:2202
Change-Id: Ifeab4cd85a91a1639a461f44776a68ac98c5bd79
Reviewed-on: https://chromium-review.googlesource.com/761240
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/ShaderVars.cpp b/src/compiler/translator/ShaderVars.cpp
index b181184..ae8027e 100644
--- a/src/compiler/translator/ShaderVars.cpp
+++ b/src/compiler/translator/ShaderVars.cpp
@@ -164,6 +164,11 @@
}
}
+bool ShaderVariable::isBuiltIn() const
+{
+ return (name.size() >= 4 && name[0] == 'g' && name[1] == 'l' && name[2] == '_');
+}
+
bool ShaderVariable::isSameVariableAtLinkTime(const ShaderVariable &other,
bool matchPrecision,
bool matchName) const
@@ -465,6 +470,11 @@
return true;
}
+bool InterfaceBlock::isBuiltIn() const
+{
+ return (name.size() >= 4 && name[0] == 'g' && name[1] == 'l' && name[2] == '_');
+}
+
void WorkGroupSize::fill(int fillValue)
{
localSizeQualifiers[0] = fillValue;
diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp
index 1ceed3f..489bd72 100644
--- a/src/libANGLE/State.cpp
+++ b/src/libANGLE/State.cpp
@@ -1403,6 +1403,11 @@
return mVertexAttribCurrentValues[attribNum];
}
+const std::vector<VertexAttribCurrentValueData> &State::getVertexAttribCurrentValues() const
+{
+ return mVertexAttribCurrentValues;
+}
+
const void *State::getVertexAttribPointer(unsigned int attribNum) const
{
return getVertexArray()->getVertexAttribute(attribNum).pointer;
diff --git a/src/libANGLE/State.h b/src/libANGLE/State.h
index df4c25f..390602e 100644
--- a/src/libANGLE/State.h
+++ b/src/libANGLE/State.h
@@ -263,6 +263,7 @@
const void *pointer);
void setVertexAttribDivisor(const Context *context, GLuint index, GLuint divisor);
const VertexAttribCurrentValueData &getVertexAttribCurrentValue(size_t attribNum) const;
+ const std::vector<VertexAttribCurrentValueData> &getVertexAttribCurrentValues() const;
const void *getVertexAttribPointer(unsigned int attribNum) const;
void bindVertexBuffer(const Context *context,
GLuint bindingIndex,
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index a4e1a3a..5b9e41b 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -539,10 +539,13 @@
bool ValidateVertexShaderAttributeTypeMatch(ValidationContext *context)
{
+ const auto &glState = context->getGLState();
const Program *program = context->getGLState().getProgram();
const VertexArray *vao = context->getGLState().getVertexArray();
+ const auto &vertexAttribs = vao->getVertexAttributes();
+ const auto ¤tValues = glState.getVertexAttribCurrentValues();
- for (const auto &shaderAttribute : program->getAttributes())
+ for (const sh::Attribute &shaderAttribute : program->getAttributes())
{
// gl_VertexID and gl_InstanceID are active attributes but don't have a bound attribute.
if (shaderAttribute.isBuiltIn())
@@ -552,10 +555,9 @@
GLenum shaderInputType = VariableComponentType(shaderAttribute.type);
- const auto &attrib = vao->getVertexAttribute(shaderAttribute.location);
- const auto ¤tValue =
- context->getGLState().getVertexAttribCurrentValue(shaderAttribute.location);
- GLenum vertexType = attrib.enabled ? GetVertexAttributeBaseType(attrib) : currentValue.Type;
+ const auto &attrib = vertexAttribs[shaderAttribute.location];
+ GLenum vertexType = attrib.enabled ? GetVertexAttributeBaseType(attrib)
+ : currentValues[shaderAttribute.location].Type;
if (shaderInputType != GL_NONE && vertexType != GL_NONE && shaderInputType != vertexType)
{