Re-land "Move shader attributes into Program shared data."

Re-land with a fix for a warning in 32-bit Windows.

Making the Program own the attribs, and the Impl only see a read-only
copy cleans up the Impl object. It also allows us to more cleanly
isolate certain coded into D3D.

BUG=angleproject:1123

Change-Id: I73bda4b6d9e675d87d087d44757c598437d607f2
Reviewed-on: https://chromium-review.googlesource.com/295191
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index 56fed09..b7b72e4 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -169,34 +169,34 @@
         }
     }
 
-    // Query the attribute information
-    GLint activeAttributeMaxLength = 0;
-    mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttributeMaxLength);
-
-    std::vector<GLchar> attributeNameBuffer(activeAttributeMaxLength);
-
-    GLint attributeCount = 0;
-    mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTES, &attributeCount);
-    for (GLint i = 0; i < attributeCount; i++)
+    for (const sh::Attribute &attribute : mData.getAttributes())
     {
-        GLsizei attributeNameLength = 0;
-        GLint attributeSize = 0;
-        GLenum attributeType = GL_NONE;
-        mFunctions->getActiveAttrib(mProgramID, i, static_cast<GLsizei>(attributeNameBuffer.size()),
-                                    &attributeNameLength, &attributeSize, &attributeType,
-                                    &attributeNameBuffer[0]);
+        if (!attribute.staticUse)
+            continue;
 
-        std::string attributeName(&attributeNameBuffer[0], attributeNameLength);
+        GLint realLocation = mFunctions->getAttribLocation(mProgramID, attribute.name.c_str());
 
-        GLint location = mFunctions->getAttribLocation(mProgramID, attributeName.c_str());
-
-        // TODO: determine attribute precision
-        setShaderAttribute(static_cast<size_t>(i), attributeType, GL_NONE, attributeName, attributeSize, location);
-
-        int attributeRegisterCount = gl::VariableRegisterCount(attributeType);
-        for (int offset = 0; offset < attributeRegisterCount; offset++)
+        // Some drivers optimize attributes more aggressively.
+        if (realLocation == -1)
         {
-            mActiveAttributesMask.set(location + offset);
+            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;
         }
     }
 
@@ -378,6 +378,7 @@
     mSamplerUniformMap.clear();
     mSamplerBindings.clear();
     mActiveAttributesMask.reset();
+    mAttributeRealLocations.clear();
 }
 
 GLuint ProgramGL::getProgramID() const