Commit cac94a91 by Jamie Madill Committed by Commit Bot

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/761240Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 23cd4add
......@@ -90,7 +90,7 @@ struct ShaderVariable
const ShaderVariable **leafVar,
std::string* originalFullName) const;
bool isBuiltIn() const { return name.compare(0, 3, "gl_") == 0; }
bool isBuiltIn() const;
GLenum type;
GLenum precision;
......@@ -232,7 +232,7 @@ struct InterfaceBlock
// Decide whether two interface blocks are the same at shader link time.
bool isSameInterfaceBlockAtLinkTime(const InterfaceBlock &other) const;
bool isBuiltIn() const { return name.compare(0, 3, "gl_") == 0; }
bool isBuiltIn() const;
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
......
......@@ -164,6 +164,11 @@ bool ShaderVariable::findInfoByMappedName(const std::string &mappedFullName,
}
}
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 @@ bool InterfaceBlock::isSameInterfaceBlockAtLinkTime(const InterfaceBlock &other)
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;
......
......@@ -1403,6 +1403,11 @@ const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(size_t at
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;
......
......@@ -263,6 +263,7 @@ class State : public OnAttachmentDirtyReceiver, angle::NonCopyable
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,
......
......@@ -539,10 +539,13 @@ bool ValidateFragmentShaderColorBufferTypeMatch(ValidationContext *context)
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 &currentValues = 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 @@ bool ValidateVertexShaderAttributeTypeMatch(ValidationContext *context)
GLenum shaderInputType = VariableComponentType(shaderAttribute.type);
const auto &attrib = vao->getVertexAttribute(shaderAttribute.location);
const auto &currentValue =
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)
{
......
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