Bind native GL attributes to match the locations in gl::Program.

Simplifies a lot of logic when we don't have to maintain mappings between
the driver and gl-layer locations.

BUG=angleproject:882
BUG=angleproject:1123

Change-Id: Ia94257a322f768fdfa3167000a46a0715820ef4d
Reviewed-on: https://chromium-review.googlesource.com/295231
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index b7b72e4..95e28e0 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -74,6 +74,23 @@
     mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID());
     mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID());
 
+    // Bind attribute locations to match the GL layer.
+    for (const sh::Attribute &attribute : mData.getAttributes())
+    {
+        if (!attribute.staticUse)
+        {
+            continue;
+        }
+
+        mFunctions->bindAttribLocation(mProgramID, attribute.location, attribute.name.c_str());
+
+        int registerCount = gl::VariableRegisterCount(attribute.type);
+        for (int offset = 0; offset < registerCount; ++offset)
+        {
+            mActiveAttributesMask.set(attribute.location + offset);
+        }
+    }
+
     // Link and verify
     mFunctions->linkProgram(mProgramID);
 
@@ -169,37 +186,6 @@
         }
     }
 
-    for (const sh::Attribute &attribute : mData.getAttributes())
-    {
-        if (!attribute.staticUse)
-            continue;
-
-        GLint realLocation = mFunctions->getAttribLocation(mProgramID, attribute.name.c_str());
-
-        // Some drivers optimize attributes more aggressively.
-        if (realLocation == -1)
-        {
-            continue;
-        }
-
-        // TODO(jmadill): Fix this
-        ASSERT(attribute.location == realLocation);
-
-        int registerCount = gl::VariableRegisterCount(attribute.type);
-
-        if (static_cast<GLint>(mAttributeRealLocations.size()) <
-            attribute.location + registerCount + 1)
-        {
-            mAttributeRealLocations.resize(attribute.location + registerCount + 1, -1);
-        }
-
-        for (int offset = 0; offset < registerCount; ++offset)
-        {
-            mActiveAttributesMask.set(attribute.location + offset);
-            mAttributeRealLocations[attribute.location + offset] = realLocation + offset;
-        }
-    }
-
     return LinkResult(true, gl::Error(GL_NO_ERROR));
 }
 
@@ -209,11 +195,6 @@
     return true;
 }
 
-void ProgramGL::bindAttributeLocation(GLuint index, const std::string &name)
-{
-    mFunctions->bindAttribLocation(mProgramID, index, name.c_str());
-}
-
 void ProgramGL::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
 {
     mStateManager->useProgram(mProgramID);
@@ -378,7 +359,6 @@
     mSamplerUniformMap.clear();
     mSamplerBindings.clear();
     mActiveAttributesMask.reset();
-    mAttributeRealLocations.clear();
 }
 
 GLuint ProgramGL::getProgramID() const