Specify CPU (buffer) and GPU (shader) types explicitly in Attribute

The CPU type is still specified using GrVertexAttribType.
The GPU type is specified directly using GrSLType.

kHalfX_GrVertexAttribType now really means half-float buffer
data, rather than float. (Caveat: The GL enum is only correct
with ES3/GL3 - ES2+extension needs a different value. Sigh.)

Bug: skia:
Change-Id: Ife101db68a5d4ea1ddc2f6c60fbec0c66d725c16
Reviewed-on: https://skia-review.googlesource.com/154628
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 0f81897..1cbf5cf 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -653,9 +653,12 @@
     const Attribute& onVertexAttribute(int i) const override {
         return IthAttribute(i, kInPosition, kInColor, kInQuadEdge);
     }
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
-    static constexpr Attribute kInQuadEdge = {"inQuadEdge", kHalf4_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInColor =
+            {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+    static constexpr Attribute kInQuadEdge =
+            {"inQuadEdge", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
     SkMatrix fLocalMatrix;
     bool fUsesLocalCoords;
 
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index 075df70..cb3e772 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -863,9 +863,12 @@
     bool                fUsesLocalCoords;
     AAMode              fAAMode;
 
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInDashParams = {"inDashParams", kHalf3_GrVertexAttribType};
-    static constexpr Attribute kInCircleParams = {"inCircleParams", kHalf2_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInDashParams =
+            {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
+    static constexpr Attribute kInCircleParams =
+            {"inCircleParams", kFloat2_GrVertexAttribType, kHalf2_GrSLType};
 
     GR_DECLARE_GEOMETRY_PROCESSOR_TEST
 
@@ -1073,9 +1076,12 @@
     bool                fUsesLocalCoords;
     AAMode              fAAMode;
 
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInDashParams = {"inDashParams", kHalf3_GrVertexAttribType};
-    static constexpr Attribute kInRectParams = {"inRect", kHalf4_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInDashParams =
+            {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
+    static constexpr Attribute kInRectParams =
+            {"inRect", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
 
     GR_DECLARE_GEOMETRY_PROCESSOR_TEST
 
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 4832ee7..7c3d4bf 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -106,10 +106,14 @@
 
     const TextureSampler& onTextureSampler(int) const override { return fSampler; }
 
-    static constexpr Attribute kPositions = {"position", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kTextureDomain = {"textureDomain", kFloat4_GrVertexAttribType};
-    static constexpr Attribute kColors = {"color", kUByte4_norm_GrVertexAttribType};
+    static constexpr Attribute kPositions =
+            {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kTextureCoords =
+            {"textureCoords", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kTextureDomain =
+            {"textureDomain", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
+    static constexpr Attribute kColors =
+            {"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
 
     sk_sp<GrColorSpaceXform> fColorSpaceXform;
     TextureSampler fSampler;
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index c0158ba..c739374 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -77,21 +77,22 @@
             , fStroke(stroke) {
         int cnt = 3;
         if (clipPlane) {
-            fInClipPlane = {"inClipPlane", kHalf3_GrVertexAttribType};
+            fInClipPlane = {"inClipPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
             ++cnt;
         }
         if (isectPlane) {
-            fInIsectPlane = {"inIsectPlane", kHalf3_GrVertexAttribType};
+            fInIsectPlane = {"inIsectPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
             ++cnt;
         }
         if (unionPlane) {
-            fInUnionPlane = {"inUnionPlane", kHalf3_GrVertexAttribType};
+            fInUnionPlane = {"inUnionPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
             ++cnt;
         }
         if (roundCaps) {
             SkASSERT(stroke);
             SkASSERT(clipPlane);
-            fInRoundCapCenters = {"inRoundCapCenters", kFloat4_GrVertexAttribType};
+            fInRoundCapCenters =
+                    {"inRoundCapCenters", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
             ++cnt;
         }
         this->setVertexAttributeCnt(cnt);
@@ -237,9 +238,12 @@
 
     SkMatrix fLocalMatrix;
 
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
-    static constexpr Attribute kInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInColor =
+            {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+    static constexpr Attribute kInCircleEdge =
+            {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
 
     // Optional attributes.
     Attribute fInClipPlane;
@@ -489,10 +493,14 @@
     }
 
     SkMatrix fLocalMatrix;
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
-    static constexpr Attribute kInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType};
-    static constexpr Attribute kInDashParams = {"inDashParams", kFloat4_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInColor =
+            {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+    static constexpr Attribute kInCircleEdge =
+            {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
+    static constexpr Attribute kInDashParams =
+            {"inDashParams", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
 
     GR_DECLARE_GEOMETRY_PROCESSOR_TEST
 
@@ -635,10 +643,14 @@
         return IthAttribute(i, kInPosition, kInColor, kInEllipseOffset, kInEllipseRadii);
     }
 
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
-    static constexpr Attribute kInEllipseOffset = {"inEllipseOffset", kHalf2_GrVertexAttribType};
-    static constexpr Attribute kInEllipseRadii = {"inEllipseRadii", kHalf4_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInColor =
+            {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+    static constexpr Attribute kInEllipseOffset =
+            {"inEllipseOffset", kFloat2_GrVertexAttribType, kHalf2_GrSLType};
+    static constexpr Attribute kInEllipseRadii =
+            {"inEllipseRadii", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
 
     SkMatrix fLocalMatrix;
     bool fStroke;
@@ -807,12 +819,16 @@
         return IthAttribute(i, kInPosition, kInColor, kInEllipseOffsets0, kInEllipseOffsets1);
     }
 
-    static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
-    static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
+    static constexpr Attribute kInPosition =
+            {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    static constexpr Attribute kInColor =
+            {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
     static constexpr Attribute kInEllipseOffsets0 = {"inEllipseOffsets0",
-                                                     kHalf2_GrVertexAttribType};
+                                                     kFloat2_GrVertexAttribType,
+                                                     kHalf2_GrSLType};
     static constexpr Attribute kInEllipseOffsets1 = {"inEllipseOffsets1",
-                                                     kHalf2_GrVertexAttribType};
+                                                     kFloat2_GrVertexAttribType,
+                                                     kHalf2_GrSLType};
 
     SkMatrix fViewMatrix;
     DIEllipseStyle fStyle;
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 2ba3639..ba37048 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -95,7 +95,7 @@
         b->add32(GrColorSpaceXform::XformKey(fTextureColorSpaceXform.get()));
         b->add32(GrColorSpaceXform::XformKey(fPaintColorSpaceXform.get()));
         uint32_t x = this->usesCoverageEdgeAA() ? 0 : 1;
-        x |= kFloat3_GrVertexAttribType == fPositions.type() ? 0 : 2;
+        x |= kFloat3_GrVertexAttribType == fPositions.cpuType() ? 0 : 2;
         x |= fDomain.isInitialized() ? 4 : 0;
         b->add32(x);
     }
@@ -121,7 +121,7 @@
                 fPaintColorSpaceXformHelper.emitCode(
                         args.fUniformHandler, textureGP.fPaintColorSpaceXform.get(),
                         kVertex_GrShaderFlag);
-                if (kFloat2_GrVertexAttribType == textureGP.fPositions.type()) {
+                if (kFloat2_GrVertexAttribType == textureGP.fPositions.cpuType()) {
                     args.fVaryingHandler->setNoPerspective();
                 }
                 args.fVaryingHandler->emitAttributes(textureGP);
@@ -165,7 +165,7 @@
                     bool mulByFragCoordW = false;
                     GrGLSLVarying aaDistVarying(kFloat4_GrSLType,
                                                 GrGLSLVarying::Scope::kVertToFrag);
-                    if (kFloat3_GrVertexAttribType == textureGP.fPositions.type()) {
+                    if (kFloat3_GrVertexAttribType == textureGP.fPositions.cpuType()) {
                         args.fVaryingHandler->addVarying("aaDists", &aaDistVarying);
                         // The distance from edge equation e to homogenous point p=sk_Position
                         // is e.x*p.x/p.wx + e.y*p.y/p.w + e.z. However, we want screen space
@@ -224,23 +224,23 @@
         this->setTextureSamplerCnt(1);
 
         if (perspective) {
-            fPositions = {"position", kFloat3_GrVertexAttribType};
+            fPositions = {"position", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
         } else {
-            fPositions = {"position", kFloat2_GrVertexAttribType};
+            fPositions = {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
         }
-        fColors = {"color", kUByte4_norm_GrVertexAttribType};
-        fTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType};
+        fColors = {"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+        fTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
         int vertexAttributeCnt = 3;
 
         if (domain == Domain::kYes) {
-            fDomain = {"domain", kFloat4_GrVertexAttribType};
+            fDomain = {"domain", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
             ++vertexAttributeCnt;
         }
         if (coverageAA) {
-            fAAEdges[0] = {"aaEdge0", kFloat3_GrVertexAttribType};
-            fAAEdges[1] = {"aaEdge1", kFloat3_GrVertexAttribType};
-            fAAEdges[2] = {"aaEdge2", kFloat3_GrVertexAttribType};
-            fAAEdges[3] = {"aaEdge3", kFloat3_GrVertexAttribType};
+            fAAEdges[0] = {"aaEdge0", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
+            fAAEdges[1] = {"aaEdge1", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
+            fAAEdges[2] = {"aaEdge2", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
+            fAAEdges[3] = {"aaEdge3", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
             vertexAttributeCnt += 4;
         }
         this->setVertexAttributeCnt(vertexAttributeCnt);