I've been reading this question and the accepted answer here: Explicit vs Automatic attribute location binding for OpenGL shaders
I've stored a hard-coded array of strings to represent available attributes for vertex shaders to use. During the loading of a shader I specify attribute locations like this:
for ( int i = 0; i < Attribute::eCount; ++i )
{
const char* name = attributeTable.Find( i );
glBindAttribLocation( program, i, (const GLchar*)name );
}
I'm wondering if it's appropriate to call glBindAttribLocation when the provided name parameter does not exist anywhere in the shader.
If we read here: https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindAttribLocation.xml, it states "It is also permissible to bind a generic attribute index to an attribute variable name that is never used in a vertex shader."
It sounds like it's okay to call glBindAttribLocation if an attribute is defined in the shader but not used. I want to know if it's okay if the attribute doesn't exist at all. My hunch is that it's fine since the glsl compiler aggressively removes unused code, but I can't seem to verify this.