Revert "Revert "Change how vertex/instance attributes are handled in geometry processors.""

This reverts commit 5045e501d2aec23e5f1e4b46346033ac3202c6b0.

TBR=csmartdalton@google.com

Change-Id: Ifbf5f1d8f8ef340fdc69653e931b6d68d4bf0854
Reviewed-on: https://skia-review.googlesource.com/135862
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/glsl/GrGLSLVarying.cpp b/src/gpu/glsl/GrGLSLVarying.cpp
index f8ec1c2..0563406 100644
--- a/src/gpu/glsl/GrGLSLVarying.cpp
+++ b/src/gpu/glsl/GrGLSLVarying.cpp
@@ -9,14 +9,15 @@
 #include "glsl/GrGLSLVarying.h"
 #include "glsl/GrGLSLProgramBuilder.h"
 
-void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute* input,
+void GrGLSLVaryingHandler::addPassThroughAttribute(const GrGeometryProcessor::Attribute& input,
                                                    const char* output,
                                                    Interpolation interpolation) {
+    SkASSERT(input.isInitialized());
     SkASSERT(!fProgramBuilder->primitiveProcessor().willUseGeoShader());
-    GrSLType type = GrVertexAttribTypeToSLType(input->type());
+    GrSLType type = GrVertexAttribTypeToSLType(input.type());
     GrGLSLVarying v(type);
-    this->addVarying(input->name(), &v, interpolation);
-    fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input->name());
+    this->addVarying(input.name(), &v, interpolation);
+    fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input.name());
     fProgramBuilder->fFS.codeAppendf("%s = %s;", output, v.fsIn());
 }
 
@@ -67,10 +68,13 @@
 }
 
 void GrGLSLVaryingHandler::emitAttributes(const GrGeometryProcessor& gp) {
-    int vaCount = gp.numAttribs();
+    int vaCount = gp.numVertexAttributes();
     for (int i = 0; i < vaCount; i++) {
-        const GrGeometryProcessor::Attribute& attr = gp.getAttrib(i);
-        this->addAttribute(attr.asShaderVar());
+        this->addAttribute(gp.vertexAttribute(i).asShaderVar());
+    }
+    int iaCount = gp.numInstanceAttributes();
+    for (int i = 0; i < iaCount; i++) {
+        this->addAttribute(gp.instanceAttribute(i).asShaderVar());
     }
 }