Remove GrPrimitiveType from GrMesh

Change-Id: I9b5bdaa08f3a383ce24d33aca5448352d954d9c1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270001
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/bench/VertexColorSpaceBench.cpp b/bench/VertexColorSpaceBench.cpp
index 8b92600..70fb2b5 100644
--- a/bench/VertexColorSpaceBench.cpp
+++ b/bench/VertexColorSpaceBench.cpp
@@ -229,7 +229,7 @@
             }
         }
 
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangleStrip);
+        GrMesh* mesh = target->allocMesh();
         mesh->setNonIndexedNonInstanced(kVertexCount);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
         target->recordDraw(gp, mesh, 1, GrPrimitiveType::kTriangleStrip);
diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp
index d39db4b..07892ac 100644
--- a/gm/clockwise.cpp
+++ b/gm/clockwise.cpp
@@ -209,7 +209,7 @@
                                                           GrPrimitiveType::kTriangleStrip);
         }
 
-        GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+        GrMesh mesh;
         mesh.setNonIndexedNonInstanced(4);
         mesh.setVertexData(std::move(fVertexBuffer));
 
diff --git a/gm/fwidth_squircle.cpp b/gm/fwidth_squircle.cpp
index 3eae01f..76aa830 100644
--- a/gm/fwidth_squircle.cpp
+++ b/gm/fwidth_squircle.cpp
@@ -217,7 +217,7 @@
                                                           GrPrimitiveType::kTriangleStrip);
         }
 
-        GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+        GrMesh mesh;
         mesh.setNonIndexedNonInstanced(4);
         mesh.setVertexData(std::move(fVertexBuffer));
 
diff --git a/gm/samplelocations.cpp b/gm/samplelocations.cpp
index 94ec9a2..e131852 100644
--- a/gm/samplelocations.cpp
+++ b/gm/samplelocations.cpp
@@ -282,7 +282,7 @@
                                                           &gStencilWrite);
         }
 
-        GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+        GrMesh mesh;
         mesh.setInstanced(nullptr, 200*200, 0, 4);
 
         flushState->opsRenderPass()->draw(*fProgramInfo, &mesh, 1, SkRect::MakeIWH(200, 200));
diff --git a/gm/tessellation.cpp b/gm/tessellation.cpp
index 852d7e4..0eec638 100644
--- a/gm/tessellation.cpp
+++ b/gm/tessellation.cpp
@@ -313,20 +313,21 @@
                             state->drawOpArgs().outputSwizzle());
         GrPipeline::FixedDynamicState fixedDynamicState;
 
-        GrMesh mesh(GrPrimitiveType::kPatches);
+        GrMesh mesh;
+        int tessellationPatchVertexCount;
         std::unique_ptr<GrGeometryProcessor> shader;
         if (fTriPositions) {
             if (!fVertexBuffer) {
                 return;
             }
-            mesh.setTessellationPatchVertexCount(3);
+            tessellationPatchVertexCount = 3;
             mesh.setNonIndexedNonInstanced(3);
             mesh.setVertexData(fVertexBuffer, fBaseVertex);
             shader = std::make_unique<TessellationTestTriShader>(fViewMatrix);
         } else {
             // Use a mismatched number of vertices in the input patch vs output.
             // (The tessellation control shader will output one vertex per patch.)
-            mesh.setTessellationPatchVertexCount(5);
+            tessellationPatchVertexCount = 5;
             mesh.setNonIndexedNonInstanced(5);
             shader = std::make_unique<TessellationTestRectShader>(fViewMatrix);
         }
@@ -334,7 +335,7 @@
         GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
                                   state->proxy()->backendFormat(), state->view()->origin(),
                                   &pipeline, shader.get(), &fixedDynamicState, nullptr, 0,
-                                  GrPrimitiveType::kPatches, mesh.tessellationPatchVertexCount());
+                                  GrPrimitiveType::kPatches, tessellationPatchVertexCount);
 
         state->opsRenderPass()->draw(programInfo, &mesh, 1, SkRect::MakeIWH(kWidth, kHeight));
     }
diff --git a/src/gpu/GrMesh.h b/src/gpu/GrMesh.h
index c3da80b..979ec0a 100644
--- a/src/gpu/GrMesh.h
+++ b/src/gpu/GrMesh.h
@@ -21,19 +21,10 @@
  */
 class GrMesh {
 public:
-    GrMesh(GrPrimitiveType primitiveType = GrPrimitiveType::kTriangles,
-           uint8_t tessellationPatchVertexCount = 0)
-            : fPrimitiveType(primitiveType)
-            , fTessellationPatchVertexCount(tessellationPatchVertexCount) {
+    GrMesh() {
         SkDEBUGCODE(fNonIndexNonInstanceData.fVertexCount = -1;)
     }
 
-    void setPrimitiveType(GrPrimitiveType type) { fPrimitiveType = type; }
-    GrPrimitiveType primitiveType() const { return fPrimitiveType; }
-
-    void setTessellationPatchVertexCount(uint8_t count) { fTessellationPatchVertexCount = count; }
-    uint8_t tessellationPatchVertexCount() const { return fTessellationPatchVertexCount; }
-
     bool isIndexed() const { return SkToBool(fIndexBuffer.get()); }
     const GrBuffer* indexBuffer() const {
         SkASSERT(this->isIndexed());
@@ -68,19 +59,21 @@
 
     class SendToGpuImpl {
     public:
-        virtual void sendArrayMeshToGpu(const GrMesh&, int vertexCount, int baseVertex) = 0;
-        virtual void sendIndexedMeshToGpu(const GrMesh&, int indexCount, int baseIndex,
-                                          uint16_t minIndexValue, uint16_t maxIndexValue,
-                                          int baseVertex) = 0;
-        virtual void sendInstancedMeshToGpu(const GrMesh&, int vertexCount, int baseVertex,
-                                            int instanceCount, int baseInstance) = 0;
-        virtual void sendIndexedInstancedMeshToGpu(const GrMesh&, int indexCount, int baseIndex,
-                                                   int baseVertex, int instanceCount,
+        virtual void sendArrayMeshToGpu(GrPrimitiveType, const GrMesh&, int vertexCount,
+                                        int baseVertex) = 0;
+        virtual void sendIndexedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount,
+                                          int baseIndex, uint16_t minIndexValue,
+                                          uint16_t maxIndexValue, int baseVertex) = 0;
+        virtual void sendInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int vertexCount,
+                                            int baseVertex, int instanceCount,
+                                            int baseInstance) = 0;
+        virtual void sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount,
+                                                   int baseIndex, int baseVertex, int instanceCount,
                                                    int baseInstance) = 0;
         virtual ~SendToGpuImpl() {}
     };
 
-    void sendToGpu(SendToGpuImpl*) const;
+    void sendToGpu(GrPrimitiveType, SendToGpuImpl*) const;
 
 private:
     enum class Flags : uint8_t {
@@ -97,8 +90,6 @@
     sk_sp<const GrBuffer> fInstanceBuffer;
     sk_sp<const GrBuffer> fVertexBuffer;
     int fBaseVertex = 0;
-    GrPrimitiveType fPrimitiveType;
-    uint8_t fTessellationPatchVertexCount;  // When fPrimitiveType == kPatches.
     Flags fFlags = Flags::kNone;
 
     union {
@@ -221,27 +212,30 @@
     fBaseVertex = baseVertex;
 }
 
-inline void GrMesh::sendToGpu(SendToGpuImpl* impl) const {
+inline void GrMesh::sendToGpu(GrPrimitiveType primitiveType, SendToGpuImpl* impl) const {
     if (this->isInstanced()) {
         if (!this->isIndexed()) {
-            impl->sendInstancedMeshToGpu(*this, fInstanceNonIndexData.fVertexCount, fBaseVertex,
-                                         fInstanceData.fInstanceCount, fInstanceData.fBaseInstance);
+            impl->sendInstancedMeshToGpu(primitiveType, *this, fInstanceNonIndexData.fVertexCount,
+                                         fBaseVertex, fInstanceData.fInstanceCount,
+                                         fInstanceData.fBaseInstance);
         } else {
-            impl->sendIndexedInstancedMeshToGpu(*this, fInstanceIndexData.fIndexCount, 0,
-                                                fBaseVertex, fInstanceData.fInstanceCount,
-                                                fInstanceData.fBaseInstance);
+            impl->sendIndexedInstancedMeshToGpu(
+                    primitiveType, *this, fInstanceIndexData.fIndexCount, 0, fBaseVertex,
+                    fInstanceData.fInstanceCount, fInstanceData.fBaseInstance);
         }
         return;
     }
 
     if (!this->isIndexed()) {
         SkASSERT(fNonIndexNonInstanceData.fVertexCount > 0);
-        impl->sendArrayMeshToGpu(*this, fNonIndexNonInstanceData.fVertexCount, fBaseVertex);
+        impl->sendArrayMeshToGpu(primitiveType, *this, fNonIndexNonInstanceData.fVertexCount,
+                                 fBaseVertex);
         return;
     }
 
     if (0 == fIndexData.fPatternRepeatCount) {
-        impl->sendIndexedMeshToGpu(*this, fIndexData.fIndexCount, fNonPatternIndexData.fBaseIndex,
+        impl->sendIndexedMeshToGpu(primitiveType, *this, fIndexData.fIndexCount,
+                                   fNonPatternIndexData.fBaseIndex,
                                    fNonPatternIndexData.fMinIndexValue,
                                    fNonPatternIndexData.fMaxIndexValue, fBaseVertex);
         return;
@@ -257,7 +251,8 @@
         int minIndexValue = 0;
         int maxIndexValue = fPatternData.fVertexCount * repeatCount - 1;
         SkASSERT(!(fFlags & Flags::kUsePrimitiveRestart));
-        impl->sendIndexedMeshToGpu(*this, indexCount, 0, minIndexValue, maxIndexValue,
+        impl->sendIndexedMeshToGpu(primitiveType, *this, indexCount, 0, minIndexValue,
+                                   maxIndexValue,
                                    fBaseVertex + fPatternData.fVertexCount * baseRepetition);
         baseRepetition += repeatCount;
     } while (baseRepetition < fIndexData.fPatternRepeatCount);
diff --git a/src/gpu/GrOpsRenderPass.cpp b/src/gpu/GrOpsRenderPass.cpp
index db536e2..8626ada 100644
--- a/src/gpu/GrOpsRenderPass.cpp
+++ b/src/gpu/GrOpsRenderPass.cpp
@@ -42,6 +42,8 @@
     }
 
 #ifdef SK_DEBUG
+    SkASSERT(GrPrimitiveType::kPatches != programInfo.primitiveType() ||
+             this->gpu()->caps()->shaderCaps()->tessellationSupport());
     SkASSERT(!programInfo.primProc().hasInstanceAttributes() ||
              this->gpu()->caps()->instanceAttribSupport());
     SkASSERT(!programInfo.pipeline().usesConservativeRaster() ||
diff --git a/src/gpu/GrProgramInfo.cpp b/src/gpu/GrProgramInfo.cpp
index 4079b15..152ee19 100644
--- a/src/gpu/GrProgramInfo.cpp
+++ b/src/gpu/GrProgramInfo.cpp
@@ -123,20 +123,14 @@
     SkASSERT(!fNumDynamicStateArrays || meshCount == fNumDynamicStateArrays);
 
     for (int i = 0; i < meshCount; ++i) {
-        SkASSERT(fPrimitiveType == meshes[i].primitiveType());
-        if (GrPrimitiveType::kPatches == fPrimitiveType) {
-            SkASSERT(fTessellationPatchVertexCount == meshes[i].tessellationPatchVertexCount());
-        }
         SkASSERT(fPrimProc->hasVertexAttributes() == SkToBool(meshes[i].vertexBuffer()));
         SkASSERT(fPrimProc->hasInstanceAttributes() == SkToBool(meshes[i].instanceBuffer()));
         if (fPipeline->usesConservativeRaster()) {
             // Conservative raster, by default, only supports triangles. Implementations can
             // optionally indicate that they also support points and lines, but we don't currently
             // query or track that info.
-            SkASSERT(GrIsPrimTypeTris(meshes[i].primitiveType()));
+            SkASSERT(GrIsPrimTypeTris(fPrimitiveType));
         }
-        SkASSERT(GrPrimitiveType::kPatches != meshes[i].primitiveType() ||
-                 caps.shaderCaps()->tessellationSupport());
         SkASSERT(GrPrimitiveRestart::kNo == meshes[i].primitiveRestart() ||
                  caps.usePrimitiveRestart());
     }
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index 7ecccd0..ed9d4eb 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -133,9 +133,9 @@
     int numIndicesPerInstance = caps.usePrimitiveRestart()
                                         ? SK_ARRAY_COUNT(kOctoIndicesAsStrips)
                                         : SK_ARRAY_COUNT(kOctoIndicesAsTris);
-    GrMesh mesh(primitiveType);
     auto enablePrimitiveRestart = GrPrimitiveRestart(flushState->caps().usePrimitiveRestart());
 
+    GrMesh mesh;
     mesh.setIndexedInstanced(resources.refIndexBuffer(), numIndicesPerInstance,
                              resources.refInstanceBuffer(), endInstance - baseInstance,
                              baseInstance, enablePrimitiveRestart);
diff --git a/src/gpu/ccpr/GrCCStroker.cpp b/src/gpu/ccpr/GrCCStroker.cpp
index 540e9b0..171bc55 100644
--- a/src/gpu/ccpr/GrCCStroker.cpp
+++ b/src/gpu/ccpr/GrCCStroker.cpp
@@ -748,7 +748,7 @@
     int endIdx = batch.fNonScissorEndInstances->fStrokes[numSegmentsLog2];
     SkASSERT(endIdx >= startIdx);
     if (int instanceCount = endIdx - startIdx) {
-        GrMesh& mesh = fMeshesBuffer.emplace_back(GrPrimitiveType::kTriangleStrip);
+        GrMesh& mesh = fMeshesBuffer.push_back();
         mesh.setInstanced(fInstanceBuffer, instanceCount, baseInstance + startIdx,
                           numStripVertices);
         fScissorsBuffer.push_back(drawBounds);
@@ -762,7 +762,7 @@
         endIdx = subBatch.fEndInstances->fStrokes[numSegmentsLog2];
         SkASSERT(endIdx >= startIdx);
         if (int instanceCount = endIdx - startIdx) {
-            GrMesh& mesh = fMeshesBuffer.emplace_back(GrPrimitiveType::kTriangleStrip);
+            GrMesh& mesh = fMeshesBuffer.push_back();
             mesh.setInstanced(fInstanceBuffer, instanceCount, baseInstance + startIdx,
                               numStripVertices);
             fScissorsBuffer.push_back(subBatch.fScissor);
diff --git a/src/gpu/ccpr/GrGSCoverageProcessor.cpp b/src/gpu/ccpr/GrGSCoverageProcessor.cpp
index 2a9b917..f6a69ea 100644
--- a/src/gpu/ccpr/GrGSCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrGSCoverageProcessor.cpp
@@ -435,7 +435,7 @@
     // the GPU in a regular vertex array and draw kLines (see initGS). Then, each vertex invocation
     // receives either the shape's x or y values as inputs, which it forwards to the geometry
     // shader.
-    GrMesh& mesh = out->emplace_back(GrPrimitiveType::kLines);
+    GrMesh& mesh = out->push_back();
     mesh.setNonIndexedNonInstanced(instanceCount * 2);
     mesh.setVertexData(std::move(instanceBuffer), baseInstance * 2);
 }
diff --git a/src/gpu/ccpr/GrSampleMaskProcessor.cpp b/src/gpu/ccpr/GrSampleMaskProcessor.cpp
index d40fd77..6bbe692 100644
--- a/src/gpu/ccpr/GrSampleMaskProcessor.cpp
+++ b/src/gpu/ccpr/GrSampleMaskProcessor.cpp
@@ -97,7 +97,7 @@
     switch (fPrimitiveType) {
         case PrimitiveType::kTriangles:
         case PrimitiveType::kWeightedTriangles: {
-            GrMesh& mesh = out->emplace_back(GrPrimitiveType::kTriangles);
+            GrMesh& mesh = out->push_back();
             mesh.setNonIndexedNonInstanced(instanceCount * 3);
             mesh.setVertexData(std::move(instanceBuffer), baseInstance * 3);
             break;
@@ -105,7 +105,7 @@
         case PrimitiveType::kQuadratics:
         case PrimitiveType::kCubics:
         case PrimitiveType::kConics: {
-            GrMesh& mesh = out->emplace_back(GrPrimitiveType::kTriangleStrip);
+            GrMesh& mesh = out->push_back();
             mesh.setInstanced(std::move(instanceBuffer), instanceCount, baseInstance, 4);
             break;
         }
diff --git a/src/gpu/ccpr/GrStencilAtlasOp.cpp b/src/gpu/ccpr/GrStencilAtlasOp.cpp
index b5caf85..0f5ba47 100644
--- a/src/gpu/ccpr/GrStencilAtlasOp.cpp
+++ b/src/gpu/ccpr/GrStencilAtlasOp.cpp
@@ -147,7 +147,7 @@
                                stencilResolveSettings);
     GrPipeline::FixedDynamicState scissorRectState(drawBoundsRect);
 
-    GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+    GrMesh mesh;
     mesh.setInstanced(fResources->refStencilResolveBuffer(),
                       fEndStencilResolveInstance - fBaseStencilResolveInstance,
                       fBaseStencilResolveInstance, 4);
diff --git a/src/gpu/ccpr/GrVSCoverageProcessor.cpp b/src/gpu/ccpr/GrVSCoverageProcessor.cpp
index 849f8ba..0f40a12 100644
--- a/src/gpu/ccpr/GrVSCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrVSCoverageProcessor.cpp
@@ -535,7 +535,7 @@
     SkASSERT(fTriangleType == GrPrimitiveType::kTriangles ||
              fTriangleType == GrPrimitiveType::kTriangleStrip);
 
-    GrMesh& mesh = out->emplace_back(fTriangleType);
+    GrMesh& mesh = out->push_back();
     auto primitiveRestart = GrPrimitiveRestart(GrPrimitiveType::kTriangleStrip == fTriangleType);
     mesh.setIndexedInstanced(fIndexBuffer, fNumIndicesPerInstance, std::move(instanceBuffer),
                              instanceCount, baseInstance, primitiveRestart);
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 2cf0032..fb438aa 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2368,6 +2368,10 @@
         return;
     }
 
+    if (GrPrimitiveType::kPatches == programInfo.primitiveType()) {
+        this->flushPatchVertexCount(programInfo.tessellationPatchVertexCount());
+    }
+
     bool hasDynamicScissors = programInfo.hasDynamicScissors();
     bool hasDynamicPrimProcTextures = programInfo.hasDynamicPrimProcTextures();
 
@@ -2388,13 +2392,13 @@
                                                                 texProxyArray);
         }
         if (this->glCaps().requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() &&
-            GrIsPrimTypeLines(meshes[m].primitiveType()) &&
+            GrIsPrimTypeLines(programInfo.primitiveType()) &&
             !GrIsPrimTypeLines(fLastPrimitiveType)) {
             GL_CALL(Enable(GR_GL_CULL_FACE));
             GL_CALL(Disable(GR_GL_CULL_FACE));
         }
-        meshes[m].sendToGpu(this);
-        fLastPrimitiveType = meshes[m].primitiveType();
+        meshes[m].sendToGpu(programInfo.primitiveType(), this);
+        fLastPrimitiveType = programInfo.primitiveType();
     }
 
 #if SWAP_PER_DRAW
@@ -2432,11 +2436,9 @@
     SK_ABORT("invalid GrPrimitiveType");
 }
 
-void GrGLGpu::sendArrayMeshToGpu(const GrMesh& mesh, int vertexCount, int baseVertex) {
-    const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(mesh.primitiveType());
-    if (GR_GL_PATCHES == glPrimType) {
-        this->flushPatchVertexCount(mesh.tessellationPatchVertexCount());
-    }
+void GrGLGpu::sendArrayMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh, int vertexCount,
+                                 int baseVertex) {
+    const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType);
     if (this->glCaps().drawArraysBaseVertexIsBroken()) {
         this->setupGeometry(nullptr, mesh.vertexBuffer(), baseVertex, nullptr, 0,
                             GrPrimitiveRestart::kNo);
@@ -2457,13 +2459,10 @@
     }
 }
 
-void GrGLGpu::sendIndexedMeshToGpu(const GrMesh& mesh, int indexCount, int baseIndex,
-                                   uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex) {
-    const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(mesh.primitiveType());
-    if (GR_GL_PATCHES == glPrimType) {
-        this->flushPatchVertexCount(mesh.tessellationPatchVertexCount());
-    }
-
+void GrGLGpu::sendIndexedMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh,
+                                   int indexCount, int baseIndex, uint16_t minIndexValue,
+                                   uint16_t maxIndexValue, int baseVertex) {
+    const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType);
     const GrGLvoid* elementPtr = element_ptr(mesh.indexBuffer(), baseIndex);
 
     this->setupGeometry(mesh.indexBuffer(), mesh.vertexBuffer(), baseVertex, nullptr, 0,
@@ -2478,12 +2477,10 @@
     fStats.incNumDraws();
 }
 
-void GrGLGpu::sendInstancedMeshToGpu(const GrMesh& mesh, int vertexCount, int baseVertex,
-                                     int instanceCount, int baseInstance) {
-    GrGLenum glPrimType = gr_primitive_type_to_gl_mode(mesh.primitiveType());
-    if (GR_GL_PATCHES == glPrimType) {
-        this->flushPatchVertexCount(mesh.tessellationPatchVertexCount());
-    }
+void GrGLGpu::sendInstancedMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh,
+                                     int vertexCount, int baseVertex, int instanceCount,
+                                     int baseInstance) {
+    GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType);
     int maxInstances = this->glCaps().maxInstancesPerDrawWithoutCrashing(instanceCount);
     for (int i = 0; i < instanceCount; i += maxInstances) {
         this->setupGeometry(nullptr, mesh.vertexBuffer(), 0, mesh.instanceBuffer(),
@@ -2494,12 +2491,10 @@
     }
 }
 
-void GrGLGpu::sendIndexedInstancedMeshToGpu(const GrMesh& mesh, int indexCount, int baseIndex,
-                                            int baseVertex, int instanceCount, int baseInstance) {
-    const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(mesh.primitiveType());
-    if (GR_GL_PATCHES == glPrimType) {
-        this->flushPatchVertexCount(mesh.tessellationPatchVertexCount());
-    }
+void GrGLGpu::sendIndexedInstancedMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh,
+                                            int indexCount, int baseIndex, int baseVertex,
+                                            int instanceCount, int baseInstance) {
+    const GrGLenum glPrimType = gr_primitive_type_to_gl_mode(primitiveType);
     const GrGLvoid* elementPtr = element_ptr(mesh.indexBuffer(), baseIndex);
     int maxInstances = this->glCaps().maxInstancesPerDrawWithoutCrashing(instanceCount);
     for (int i = 0; i < instanceCount; i += maxInstances) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 8668363..41cf507 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -80,13 +80,15 @@
 
     // GrMesh::SendToGpuImpl methods. These issue the actual GL draw calls.
     // Marked final as a hint to the compiler to not use virtual dispatch.
-    void sendArrayMeshToGpu(const GrMesh&, int vertexCount, int baseVertex) final;
-    void sendIndexedMeshToGpu(const GrMesh&, int indexCount, int baseIndex, uint16_t minIndexValue,
-                              uint16_t maxIndexValue, int baseVertex) final;
-    void sendInstancedMeshToGpu(const GrMesh&, int vertexCount, int baseVertex, int instanceCount,
-                                int baseInstance) final;
-    void sendIndexedInstancedMeshToGpu(const GrMesh&, int indexCount, int baseIndex, int baseVertex,
-                                       int instanceCount, int baseInstance) final;
+    void sendArrayMeshToGpu(GrPrimitiveType primitiveType, const GrMesh&, int vertexCount,
+                            int baseVertex) final;
+    void sendIndexedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount, int baseIndex,
+                              uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex) final;
+    void sendInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int vertexCount, int baseVertex,
+                                int instanceCount, int baseInstance) final;
+    void sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount,
+                                       int baseIndex, int baseVertex, int instanceCount,
+                                       int baseInstance) final;
 
     // The GrGLOpsRenderPass does not buffer up draws before submitting them to the gpu.
     // Thus this is the implementation of the clear call for the corresponding passthrough function
diff --git a/src/gpu/mtl/GrMtlOpsRenderPass.h b/src/gpu/mtl/GrMtlOpsRenderPass.h
index 8184c82..28c953f 100644
--- a/src/gpu/mtl/GrMtlOpsRenderPass.h
+++ b/src/gpu/mtl/GrMtlOpsRenderPass.h
@@ -61,14 +61,15 @@
 
     // GrMesh::SendToGpuImpl methods. These issue the actual Metal draw commands.
     // Marked final as a hint to the compiler to not use virtual dispatch.
-    void sendArrayMeshToGpu(const GrMesh&, int vertexCount, int baseVertex) final;
-    void sendIndexedMeshToGpu(const GrMesh&, int indexCount, int baseIndex,
+    void sendArrayMeshToGpu(GrPrimitiveType, const GrMesh&, int vertexCount, int baseVertex) final;
+    void sendIndexedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount, int baseIndex,
                               uint16_t /*minIndexValue*/, uint16_t /*maxIndexValue*/,
                               int baseVertex) final;
-    void sendInstancedMeshToGpu(const GrMesh&, int vertexCount, int baseVertex, int instanceCount,
-                                int baseInstance) final;
-    void sendIndexedInstancedMeshToGpu(const GrMesh&, int indexCount, int baseIndex, int baseVertex,
-                                       int instanceCount, int baseInstance) final;
+    void sendInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int vertexCount, int baseVertex,
+                                int instanceCount, int baseInstance) final;
+    void sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount,
+                                       int baseIndex, int baseVertex, int instanceCount,
+                                       int baseInstance) final;
 
     void setVertexBuffer(id<MTLRenderCommandEncoder>, const GrMtlBuffer*, size_t offset,
                          size_t index);
diff --git a/src/gpu/mtl/GrMtlOpsRenderPass.mm b/src/gpu/mtl/GrMtlOpsRenderPass.mm
index ae3d9a2..5a30f6a 100644
--- a/src/gpu/mtl/GrMtlOpsRenderPass.mm
+++ b/src/gpu/mtl/GrMtlOpsRenderPass.mm
@@ -128,7 +128,7 @@
             pipelineState->bindTextures(fActiveRenderCmdEncoder);
         }
 
-        mesh.sendToGpu(this);
+        mesh.sendToGpu(programInfo.primitiveType(), this);
     }
 
     fActiveRenderCmdEncoder = nil;
@@ -280,15 +280,17 @@
     }
 }
 
-void GrMtlOpsRenderPass::sendArrayMeshToGpu(const GrMesh& mesh, int vertexCount, int baseVertex) {
+void GrMtlOpsRenderPass::sendArrayMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh,
+                                            int vertexCount, int baseVertex) {
     this->bindGeometry(mesh.vertexBuffer(), 0, nullptr);
 
-    [fActiveRenderCmdEncoder drawPrimitives:gr_to_mtl_primitive(mesh.primitiveType())
+    [fActiveRenderCmdEncoder drawPrimitives:gr_to_mtl_primitive(primitiveType)
                                 vertexStart:baseVertex
                                 vertexCount:vertexCount];
 }
 
-void GrMtlOpsRenderPass::sendIndexedMeshToGpu(const GrMesh& mesh, int indexCount, int baseIndex,
+void GrMtlOpsRenderPass::sendIndexedMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh,
+                                              int indexCount, int baseIndex,
                                               uint16_t /*minIndexValue*/,
                                               uint16_t /*maxIndexValue*/, int baseVertex) {
     this->bindGeometry(mesh.vertexBuffer(), fCurrentVertexStride*baseVertex, nullptr);
@@ -305,7 +307,7 @@
     SkASSERT(mesh.primitiveRestart() == GrPrimitiveRestart::kNo);
     size_t indexOffset = static_cast<const GrMtlBuffer*>(mesh.indexBuffer())->offset() +
                          sizeof(uint16_t) * baseIndex;
-    [fActiveRenderCmdEncoder drawIndexedPrimitives:gr_to_mtl_primitive(mesh.primitiveType())
+    [fActiveRenderCmdEncoder drawIndexedPrimitives:gr_to_mtl_primitive(primitiveType)
                                         indexCount:indexCount
                                          indexType:MTLIndexTypeUInt16
                                        indexBuffer:mtlIndexBuffer
@@ -313,12 +315,13 @@
     fGpu->stats()->incNumDraws();
 }
 
-void GrMtlOpsRenderPass::sendInstancedMeshToGpu(const GrMesh& mesh, int vertexCount, int baseVertex,
-                                                int instanceCount, int baseInstance) {
+void GrMtlOpsRenderPass::sendInstancedMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh,
+                                                int vertexCount, int baseVertex, int instanceCount,
+                                                int baseInstance) {
     this->bindGeometry(mesh.vertexBuffer(), 0, mesh.instanceBuffer());
 
     if (@available(macOS 10.11, iOS 9.0, *)) {
-        [fActiveRenderCmdEncoder drawPrimitives:gr_to_mtl_primitive(mesh.primitiveType())
+        [fActiveRenderCmdEncoder drawPrimitives:gr_to_mtl_primitive(primitiveType)
                                     vertexStart:baseVertex
                                     vertexCount:vertexCount
                                   instanceCount:instanceCount
@@ -328,7 +331,8 @@
     }
 }
 
-void GrMtlOpsRenderPass::sendIndexedInstancedMeshToGpu(const GrMesh& mesh, int indexCount,
+void GrMtlOpsRenderPass::sendIndexedInstancedMeshToGpu(GrPrimitiveType primitiveType,
+                                                       const GrMesh& mesh, int indexCount,
                                                        int baseIndex, int baseVertex,
                                                        int instanceCount, int baseInstance) {
     this->bindGeometry(mesh.vertexBuffer(), 0, mesh.instanceBuffer());
@@ -347,7 +351,7 @@
                          sizeof(uint16_t) * baseIndex;
 
     if (@available(macOS 10.11, iOS 9.0, *)) {
-        [fActiveRenderCmdEncoder drawIndexedPrimitives:gr_to_mtl_primitive(mesh.primitiveType())
+        [fActiveRenderCmdEncoder drawIndexedPrimitives:gr_to_mtl_primitive(primitiveType)
                                             indexCount:indexCount
                                              indexType:MTLIndexTypeUInt16
                                            indexBuffer:mtlIndexBuffer
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 54f0ecc..d68ce5f 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -809,7 +809,6 @@
             GrMesh* meshes = target->allocMeshes(draws.count());
             for (int j = 0; j < draws.count(); ++j) {
                 const Draw& draw = draws[j];
-                meshes[j].setPrimitiveType(GrPrimitiveType::kTriangles);
                 meshes[j].setIndexed(indexBuffer, draw.fIndexCnt, firstIndex, 0,
                                      draw.fVertexCnt - 1, GrPrimitiveRestart::kNo);
                 meshes[j].setVertexData(vertexBuffer, firstVertex);
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 9b4fad7..109309e 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -1084,7 +1084,7 @@
                                                            geometryProcessorViewM,
                                                            geometryProcessorLocalM);
 
-            GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+            GrMesh* mesh = target->allocMesh();
             mesh->setIndexedPatterned(quadsIndexBuffer, kIdxsPerQuad, kQuadNumVertices, quadCount,
                                       kQuadsNumInIdxBuffer);
             mesh->setVertexData(vertexBuffer, firstVertex);
@@ -1097,7 +1097,7 @@
                                                              geometryProcessorViewM,
                                                              geometryProcessorLocalM);
 
-            GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+            GrMesh* mesh = target->allocMesh();
             mesh->setIndexedPatterned(std::move(quadsIndexBuffer), kIdxsPerQuad, kQuadNumVertices,
                                       conicCount, kQuadsNumInIdxBuffer);
             mesh->setVertexData(std::move(vertexBuffer), firstVertex);
diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
index 706b8dc..0409b5f 100644
--- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
@@ -223,7 +223,7 @@
             return;
         }
         memcpy(idxs, indices, indexCount * sizeof(uint16_t));
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+        GrMesh* mesh = target->allocMesh();
         mesh->setIndexed(std::move(indexBuffer), indexCount, firstIndex, 0, vertexCount - 1,
                          GrPrimitiveRestart::kNo);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index 03667f6..594d68c 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -511,7 +511,7 @@
         }
     }
     int maxGlyphsPerDraw = static_cast<int>(flushInfo->fIndexBuffer->size() / sizeof(uint16_t) / 6);
-    GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+    GrMesh* mesh = target->allocMesh();
     mesh->setIndexedPatterned(flushInfo->fIndexBuffer, kIndicesPerGlyph, kVerticesPerGlyph,
                               flushInfo->fGlyphsToFlush, maxGlyphsPerDraw);
     mesh->setVertexData(flushInfo->fVertexBuffer, flushInfo->fVertexOffset);
diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp
index b7e3c1d..086583f 100644
--- a/src/gpu/ops/GrDefaultPathRenderer.cpp
+++ b/src/gpu/ops/GrDefaultPathRenderer.cpp
@@ -269,7 +269,7 @@
         SkASSERT(indexCount <= fIndicesInChunk);
 
         if (this->isIndexed() ? SkToBool(indexCount) : SkToBool(vertexCount)) {
-            GrMesh* mesh = fTarget->allocMesh(fPrimitiveType);
+            GrMesh* mesh = fTarget->allocMesh();
             if (!this->isIndexed()) {
                 mesh->setNonIndexedNonInstanced(vertexCount);
             } else {
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index 5080b57..9647abe 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -500,7 +500,7 @@
                                   int firstVertex,
                                   sk_sp<const GrBuffer> indexBuffer,
                                   int firstIndex) {
-    GrMesh* mesh = target->allocMesh(this->primitiveType());
+    GrMesh* mesh = target->allocMesh();
     if (this->isIndexed()) {
         mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertexCount - 1,
                          GrPrimitiveRestart::kNo);
diff --git a/src/gpu/ops/GrFillRRectOp.cpp b/src/gpu/ops/GrFillRRectOp.cpp
index 04d8a9b..368a83b 100644
--- a/src/gpu/ops/GrFillRRectOp.cpp
+++ b/src/gpu/ops/GrFillRRectOp.cpp
@@ -805,7 +805,7 @@
                                                flushState->dstProxyView());
     }
 
-    GrMesh* mesh = flushState->allocator()->make<GrMesh>(GrPrimitiveType::kTriangles);
+    GrMesh* mesh = flushState->allocator()->make<GrMesh>();
     mesh->setIndexedInstanced(std::move(fIndexBuffer), fIndexCount,
                               std::move(fInstanceBuffer), fInstanceCount,
                               fBaseInstance, GrPrimitiveRestart::kNo);
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index bfd052b..63d94e4 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -42,7 +42,7 @@
         return;
     }
     SkASSERT(vertexBuffer);
-    fMesh = target->allocMesh(primitiveType);
+    fMesh = target->allocMesh();
     fPrimitiveType = primitiveType;
 
     SkASSERT(maxRepetitions ==
diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h
index 1922266..27201d9 100644
--- a/src/gpu/ops/GrMeshDrawOp.h
+++ b/src/gpu/ops/GrMeshDrawOp.h
@@ -166,10 +166,7 @@
     virtual void putBackIndices(int indices) = 0;
     virtual void putBackVertices(int vertices, size_t vertexStride) = 0;
 
-    GrMesh* allocMesh(GrPrimitiveType primitiveType) {
-        return this->allocator()->make<GrMesh>(primitiveType);
-    }
-
+    GrMesh* allocMesh() { return this->allocator()->make<GrMesh>(); }
     GrMesh* allocMeshes(int n) { return this->allocator()->makeArray<GrMesh>(n); }
 
     static GrPipeline::DynamicStateArrays* AllocDynamicStateArrays(SkArenaAlloc*,
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 73e77e8..fea5171 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -1396,7 +1396,7 @@
             currStartVertex += circle_type_to_vert_count(circle.fStroked);
         }
 
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+        GrMesh* mesh = target->allocMesh();
         mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
                          GrPrimitiveRestart::kNo);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
@@ -1693,7 +1693,7 @@
             currStartVertex += circle_type_to_vert_count(true);
         }
 
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+        GrMesh* mesh = target->allocMesh();
         mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
                          GrPrimitiveRestart::kNo);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
@@ -2633,7 +2633,7 @@
             currStartVertex += rrect_type_to_vert_count(rrect.fType);
         }
 
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+        GrMesh* mesh = target->allocMesh();
         mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
                          GrPrimitiveRestart::kNo);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.cpp b/src/gpu/ops/GrQuadPerEdgeAA.cpp
index d4861aa..66b84a9 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.cpp
+++ b/src/gpu/ops/GrQuadPerEdgeAA.cpp
@@ -398,8 +398,6 @@
                    sk_sp<const GrBuffer> indexBuffer, int absVertBufferOffset) {
     SkASSERT(vertexBuffer);
 
-    mesh->setPrimitiveType(spec.primitiveType());
-
     if (spec.indexBufferOption() == IndexBufferOption::kTriStrips) {
         SkASSERT(!indexBuffer);
 
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index b1ef4e2..e1209ee 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -596,7 +596,7 @@
         auto fixedDynamicState = target->makeFixedDynamicState(1);
         fixedDynamicState->fPrimitiveProcessorTextures[0] = fFalloffView.proxy();
 
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+        GrMesh* mesh = target->allocMesh();
         mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
                          GrPrimitiveRestart::kNo);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 72b34d7..99172ec 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -796,7 +796,7 @@
         }
 
         if (flushInfo->fInstancesToFlush) {
-            GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+            GrMesh* mesh = target->allocMesh();
             mesh->setIndexedPatterned(flushInfo->fIndexBuffer,
                                       GrResourceProvider::NumIndicesPerNonAAQuad(),
                                       GrResourceProvider::NumVertsPerNonAAQuad(),
diff --git a/src/gpu/ops/GrStrokeRectOp.cpp b/src/gpu/ops/GrStrokeRectOp.cpp
index 7bcee08..a2d2a94 100644
--- a/src/gpu/ops/GrStrokeRectOp.cpp
+++ b/src/gpu/ops/GrStrokeRectOp.cpp
@@ -221,7 +221,7 @@
             vertex[4].set(fRect.fLeft, fRect.fTop);
         }
 
-        GrMesh* mesh = target->allocMesh(primType);
+        GrMesh* mesh = target->allocMesh();
         mesh->setNonIndexedNonInstanced(vertexCount);
         mesh->setVertexData(std::move(vertexBuffer), firstVertex);
         target->recordDraw(gp, mesh, 1, primType);
diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp
index 7817b05..55c194d 100644
--- a/src/gpu/ops/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp
@@ -364,7 +364,7 @@
         GrPrimitiveType primitiveType = TESSELLATOR_WIREFRAME ? GrPrimitiveType::kLines
                                                               : GrPrimitiveType::kTriangles;
 
-        GrMesh* mesh = target->allocMesh(primitiveType);
+        GrMesh* mesh = target->allocMesh();
         mesh->setNonIndexedNonInstanced(count);
         mesh->setVertexData(std::move(vb), firstVertex);
         target->recordDraw(gp, mesh, 1, primitiveType);
diff --git a/src/gpu/tessellate/GrDrawAtlasPathOp.cpp b/src/gpu/tessellate/GrDrawAtlasPathOp.cpp
index 1062263..5f6e88a 100644
--- a/src/gpu/tessellate/GrDrawAtlasPathOp.cpp
+++ b/src/gpu/tessellate/GrDrawAtlasPathOp.cpp
@@ -184,7 +184,7 @@
                               &shader, &fixedDynamicState, nullptr, 0,
                               GrPrimitiveType::kTriangleStrip);
 
-    GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+    GrMesh mesh;
     mesh.setInstanced(fInstanceBuffer, fInstanceCount, fBaseInstance, 4);
     state->opsRenderPass()->draw(programInfo, &mesh, 1, this->bounds());
 }
diff --git a/src/gpu/tessellate/GrPathShader.h b/src/gpu/tessellate/GrPathShader.h
index 1443c774..facb9aa 100644
--- a/src/gpu/tessellate/GrPathShader.h
+++ b/src/gpu/tessellate/GrPathShader.h
@@ -35,7 +35,7 @@
                    const GrPipeline::FixedDynamicState* fixedDynamicState,
                    sk_sp<const GrBuffer> vertexBuffer, int vertexCount, int baseVertex,
                    const SkRect& bounds) {
-        GrMesh mesh(fPrimitiveType, fTessellationPatchVertexCount);
+        GrMesh mesh;
         mesh.setNonIndexedNonInstanced(vertexCount);
         mesh.setVertexData(std::move(vertexBuffer), baseVertex);
         this->issueDraw(state, pipeline, fixedDynamicState, mesh, bounds);
@@ -44,8 +44,6 @@
     void issueDraw(GrOpFlushState* state, const GrPipeline* pipeline,
                    const GrPipeline::FixedDynamicState* fixedDynamicState, const GrMesh& mesh,
                    const SkRect& bounds) {
-        SkASSERT(mesh.primitiveType() == fPrimitiveType);
-        SkASSERT(mesh.tessellationPatchVertexCount() == fTessellationPatchVertexCount);
         GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
                                   state->proxy()->backendFormat(), state->view()->origin(),
                                   pipeline, this, fixedDynamicState, nullptr, 0,
diff --git a/src/gpu/tessellate/GrTessellatePathOp.cpp b/src/gpu/tessellate/GrTessellatePathOp.cpp
index db7a50f..ec484a5 100644
--- a/src/gpu/tessellate/GrTessellatePathOp.cpp
+++ b/src/gpu/tessellate/GrTessellatePathOp.cpp
@@ -148,7 +148,7 @@
 
     if (fCubicInstanceBuffer) {
         // Here we treat the cubic instance buffer as tessellation patches to stencil the curves.
-        GrMesh mesh(GrPrimitiveType::kPatches, 4);
+        GrMesh mesh;
         mesh.setNonIndexedNonInstanced(fCubicInstanceCount * 4);
         mesh.setVertexData(fCubicInstanceBuffer, fBaseCubicInstance * 4);
         GrStencilCubicShader(fViewMatrix).issueDraw(
@@ -244,7 +244,7 @@
             // At this point, every pixel is filled in except the ones touched by curves. Issue a
             // final cover pass over the curves by drawing their convex hulls. This will fill in any
             // remaining samples and reset the stencil buffer.
-            GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+            GrMesh mesh;
             mesh.setInstanced(fCubicInstanceBuffer, fCubicInstanceCount, fBaseCubicInstance, 4);
             pipeline.setUserStencil(&kTestAndResetStencil);
             GrFillCubicHullShader(fViewMatrix, fColor).issueDraw(
@@ -252,7 +252,7 @@
         }
     } else {
         // There is not a fill shader for the path. Just draw a bounding box.
-        GrMesh mesh(GrPrimitiveType::kTriangleStrip);
+        GrMesh mesh;
         mesh.setNonIndexedNonInstanced(4);
         pipeline.setUserStencil(&kTestAndResetStencil);
         GrFillBoundingBoxShader(fViewMatrix, fColor, fPath.getBounds()).issueDraw(
diff --git a/src/gpu/vk/GrVkOpsRenderPass.cpp b/src/gpu/vk/GrVkOpsRenderPass.cpp
index a8dfc3c..08cc282 100644
--- a/src/gpu/vk/GrVkOpsRenderPass.cpp
+++ b/src/gpu/vk/GrVkOpsRenderPass.cpp
@@ -627,14 +627,16 @@
             }
         }
         SkASSERT(pipelineState);
-        mesh.sendToGpu(this);
+        mesh.sendToGpu(programInfo.primitiveType(), this);
     }
 
     fCurrentCBIsEmpty = false;
 }
 
-void GrVkOpsRenderPass::sendInstancedMeshToGpu(const GrMesh& mesh, int vertexCount, int baseVertex,
-                                               int instanceCount, int baseInstance) {
+void GrVkOpsRenderPass::sendInstancedMeshToGpu(GrPrimitiveType, const GrMesh& mesh, int vertexCount,
+                                               int baseVertex, int instanceCount,
+                                               int baseInstance)
+{
     SkASSERT(!mesh.vertexBuffer() || !mesh.vertexBuffer()->isCpuBuffer());
     SkASSERT(!mesh.instanceBuffer() || !mesh.instanceBuffer()->isCpuBuffer());
     auto gpuVertexBuffer = static_cast<const GrGpuBuffer*>(mesh.vertexBuffer());
@@ -644,8 +646,8 @@
     fGpu->stats()->incNumDraws();
 }
 
-void GrVkOpsRenderPass::sendIndexedInstancedMeshToGpu(const GrMesh& mesh, int indexCount,
-                                                      int baseIndex, int baseVertex,
+void GrVkOpsRenderPass::sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrMesh& mesh,
+                                                      int indexCount, int baseIndex, int baseVertex,
                                                       int instanceCount, int baseInstance) {
     SkASSERT(mesh.primitiveRestart() == GrPrimitiveRestart::kNo);
     SkASSERT(!mesh.vertexBuffer() || !mesh.vertexBuffer()->isCpuBuffer());
diff --git a/src/gpu/vk/GrVkOpsRenderPass.h b/src/gpu/vk/GrVkOpsRenderPass.h
index b6020ee..64209d9 100644
--- a/src/gpu/vk/GrVkOpsRenderPass.h
+++ b/src/gpu/vk/GrVkOpsRenderPass.h
@@ -75,20 +75,23 @@
 
     // GrMesh::SendToGpuImpl methods. These issue the actual Vulkan draw commands.
     // Marked final as a hint to the compiler to not use virtual dispatch.
-    void sendArrayMeshToGpu(const GrMesh& mesh, int vertexCount, int baseVertex) final {
+    void sendArrayMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh, int vertexCount,
+                            int baseVertex) final {
         SkASSERT(!mesh.instanceBuffer());
-        this->sendInstancedMeshToGpu(mesh, vertexCount, baseVertex, 1, 0);
+        this->sendInstancedMeshToGpu(primitiveType, mesh, vertexCount, baseVertex, 1, 0);
     }
-    void sendIndexedMeshToGpu(const GrMesh& mesh, int indexCount, int baseIndex,
-                              uint16_t minIndexValue, uint16_t maxIndexValue,
+    void sendIndexedMeshToGpu(GrPrimitiveType primitiveType, const GrMesh& mesh, int indexCount,
+                              int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue,
                               int baseVertex) final {
         SkASSERT(!mesh.instanceBuffer());
-        this->sendIndexedInstancedMeshToGpu(mesh, indexCount, baseIndex, baseVertex, 1, 0);
+        this->sendIndexedInstancedMeshToGpu(primitiveType, mesh, indexCount, baseIndex, baseVertex,
+                                            1, 0);
     }
-    void sendInstancedMeshToGpu(const GrMesh&, int vertexCount, int baseVertex, int instanceCount,
-                                int baseInstance) final;
-    void sendIndexedInstancedMeshToGpu(const GrMesh&, int indexCount, int baseIndex, int baseVertex,
-                                       int instanceCount, int baseInstance) final;
+    void sendInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int vertexCount, int baseVertex,
+                                int instanceCount, int baseInstance) final;
+    void sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrMesh&, int indexCount,
+                                       int baseIndex, int baseVertex, int instanceCount,
+                                       int baseInstance) final;
 
     void onClear(const GrFixedClip&, const SkPMColor4f& color) override;
 
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index 9253ffc..8a505a8 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -160,7 +160,7 @@
              },
              [&](DrawMeshHelper* helper) {
                  for (int y = 0; y < kBoxCountY; ++y) {
-                     GrMesh mesh(GrPrimitiveType::kTriangles);
+                     GrMesh mesh;
                      mesh.setNonIndexedNonInstanced(kBoxCountX * 6);
                      mesh.setVertexData(helper->fVertBuffer, y * kBoxCountX * 6);
                      helper->drawMesh(mesh, GrPrimitiveType::kTriangles);
@@ -183,7 +183,7 @@
                     static_assert(kIndexPatternRepeatCount >= 3);
                     int repetitionCount = std::min(3 - baseRepetition, kBoxCount - i);
 
-                    GrMesh mesh(GrPrimitiveType::kTriangles);
+                    GrMesh mesh;
                     mesh.setIndexed(helper->fIndexBuffer, repetitionCount * 6, baseRepetition * 6,
                                     baseRepetition * 4, (baseRepetition + repetitionCount) * 4 - 1,
                                     GrPrimitiveRestart::kNo);
@@ -206,7 +206,7 @@
                 // Draw boxes one line at a time to exercise base vertex. setIndexedPatterned does
                 // not support a base index.
                 for (int y = 0; y < kBoxCountY; ++y) {
-                    GrMesh mesh(GrPrimitiveType::kTriangles);
+                    GrMesh mesh;
                     mesh.setIndexedPatterned(helper->fIndexBuffer, 6, 4, kBoxCountX,
                                              kIndexPatternRepeatCount);
                     mesh.setVertexData(helper->fVertBuffer, y * kBoxCountX * 4);
@@ -240,7 +240,7 @@
 
                          GrPrimitiveType primitiveType = indexed ? GrPrimitiveType::kTriangles
                                                                  : GrPrimitiveType::kTriangleStrip;
-                         GrMesh mesh(primitiveType);
+                         GrMesh mesh;
                          if (indexed) {
                              VALIDATE(helper->fIndexBuffer);
                              mesh.setIndexedInstanced(helper->fIndexBuffer, 6, helper->fInstBuffer,
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 1d8a42a..e62269b 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -151,7 +151,7 @@
                             flushState->drawOpArgs().outputSwizzle());
         SkSTArray<kNumMeshes, GrMesh> meshes;
         for (int i = 0; i < kNumMeshes; ++i) {
-            GrMesh& mesh = meshes.emplace_back(GrPrimitiveType::kTriangleStrip);
+            GrMesh& mesh = meshes.push_back();
             mesh.setNonIndexedNonInstanced(4);
             mesh.setVertexData(fVertexBuffer, 4 * i);
         }
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index e149b4d..bc0e8a1 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -158,7 +158,7 @@
             }
         }
 
-        GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles);
+        GrMesh* mesh = target->allocMesh();
         mesh->setIndexed(indexBuffer, 6, firstIndex, 0, 3, GrPrimitiveRestart::kNo);
         mesh->setVertexData(vertexBuffer, firstVertex);