Revert "Reland "Add ability to specify different GP textures for each mesh in a draw.""

This reverts commit 2d0a6a1f989dbe02e5eaff5b8ae9ed9dc216a3e6.

Revert "Add support for dynamic state GP textures in Vulkan backend."

This reverts commit 5e81a123f22c309ebe790904345d54de4cba2ab5.

Revert "Disable GrTextureOp Chaining"

This reverts commit fdec6f469a44b19e3d77ed313c5b79fb72982603.

Bug: chromium:877598
Bug: chromium:877602
Bug: chromium:877610
Change-Id: Iabf2971b27bcf7728785903f1d7f47d1148a2e63
Reviewed-on: https://skia-review.googlesource.com/150461
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index af53498..2ba3639 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -611,7 +611,7 @@
     }
 
     template <typename Pos, Domain D, GrAA AA>
-    void tess(void* v, const GrGeometryProcessor* gp) const {
+    void tess(void* v, const GrGeometryProcessor* gp) {
         using Vertex = TextureGeometryProcessor::Vertex<Pos, D, AA>;
         SkASSERT(gp->debugOnly_vertexStride() == sizeof(Vertex));
         auto vertices = static_cast<Vertex*>(v);
@@ -628,25 +628,16 @@
     }
 
     void onPrepareDraws(Target* target) override {
-        bool hasPerspective = false;
-        Domain domain = Domain::kNo;
-        int numOps = 0;
-        for (const auto& op : ChainRange<TextureOp>(this)) {
-            ++numOps;
-            hasPerspective |= op.fPerspective;
-            if (op.fDomain) {
-                domain = Domain::kYes;
-            }
-            if (!op.fProxy->instantiate(target->resourceProvider())) {
-                return;
-            }
+        if (!fProxy->instantiate(target->resourceProvider())) {
+            return;
         }
 
+        Domain domain = fDomain ? Domain::kYes : Domain::kNo;
         bool coverageAA = GrAAType::kCoverage == this->aaType();
         sk_sp<GrGeometryProcessor> gp = TextureGeometryProcessor::Make(
                 fProxy->textureType(), fProxy->config(), fFilter,
                 std::move(fTextureColorSpaceXform), std::move(fPaintColorSpaceXform), coverageAA,
-                hasPerspective, domain, *target->caps().shaderCaps());
+                fPerspective, domain, *target->caps().shaderCaps());
         GrPipeline::InitArgs args;
         args.fProxy = target->proxy();
         args.fCaps = &target->caps();
@@ -657,17 +648,8 @@
         }
 
         auto clip = target->detachAppliedClip();
-        // We'll use a dynamic state array for the GP textures when there are multiple ops.
-        // Otherwise, we use fixed dynamic state to specify the single op's proxy.
-        GrPipeline::DynamicStateArrays* dynamicStateArrays = nullptr;
-        GrPipeline::FixedDynamicState* fixedDynamicState;
-        if (numOps > 1) {
-            dynamicStateArrays = target->allocDynamicStateArrays(numOps, 1, false);
-            fixedDynamicState = target->allocFixedDynamicState(clip.scissorState().rect(), 0);
-        } else {
-            fixedDynamicState = target->allocFixedDynamicState(clip.scissorState().rect(), 1);
-            fixedDynamicState->fPrimitiveProcessorTextures[0] = fProxy;
-        }
+        auto* fixedDynamicState = target->allocFixedDynamicState(clip.scissorState().rect(), 1);
+        fixedDynamicState->fPrimitiveProcessorTextures[0] = fProxy;
         const auto* pipeline =
                 target->allocPipeline(args, GrProcessorSet::MakeEmptySet(), std::move(clip));
         using TessFn = decltype(&TextureOp::tess<SkPoint, Domain::kNo, GrAA::kNo>);
@@ -691,45 +673,42 @@
         };
 #undef TESS_FN_AND_VERTEX_SIZE
         int tessFnIdx = 0;
-        tessFnIdx |= coverageAA               ? 0x1 : 0x0;
-        tessFnIdx |= (domain == Domain::kYes) ? 0x2 : 0x0;
-        tessFnIdx |= hasPerspective           ? 0x4 : 0x0;
+        tessFnIdx |= coverageAA   ? 0x1 : 0x0;
+        tessFnIdx |= fDomain      ? 0x2 : 0x0;
+        tessFnIdx |= fPerspective ? 0x4 : 0x0;
 
         SkASSERT(kTessFnsAndVertexSizes[tessFnIdx].fVertexSize == gp->debugOnly_vertexStride());
 
-        GrMesh* meshes = target->allocMeshes(numOps);
-        int i = 0;
-        for (const auto& op : ChainRange<TextureOp>(this)) {
-            int vstart;
-            const GrBuffer* vbuffer;
-            void* vdata = target->makeVertexSpace(kTessFnsAndVertexSizes[tessFnIdx].fVertexSize,
-                                                  4 * op.fDraws.count(), &vbuffer, &vstart);
-            if (!vdata) {
-                SkDebugf("Could not allocate vertices\n");
-                return;
-            }
+        int vstart;
+        const GrBuffer* vbuffer;
+        void* vdata = target->makeVertexSpace(kTessFnsAndVertexSizes[tessFnIdx].fVertexSize,
+                                              4 * fDraws.count(), &vbuffer, &vstart);
+        if (!vdata) {
+            SkDebugf("Could not allocate vertices\n");
+            return;
+        }
 
-            (op.*(kTessFnsAndVertexSizes[tessFnIdx].fTessFn))(vdata, gp.get());
+        (this->*(kTessFnsAndVertexSizes[tessFnIdx].fTessFn))(vdata, gp.get());
 
-            meshes[i].setPrimitiveType(GrPrimitiveType::kTriangles);
+        GrPrimitiveType primitiveType =
+                fDraws.count() > 1 ? GrPrimitiveType::kTriangles : GrPrimitiveType::kTriangleStrip;
+        GrMesh* mesh = target->allocMesh(primitiveType);
+        if (fDraws.count() > 1) {
             sk_sp<const GrBuffer> ibuffer = target->resourceProvider()->refQuadIndexBuffer();
             if (!ibuffer) {
                 SkDebugf("Could not allocate quad indices\n");
                 return;
             }
-            meshes[i].setIndexedPatterned(ibuffer.get(), 6, 4, op.fDraws.count(),
-                                          GrResourceProvider::QuadCountOfQuadBuffer());
-            meshes[i].setVertexData(vbuffer, vstart);
-            if (dynamicStateArrays) {
-                dynamicStateArrays->fPrimitiveProcessorTextures[i] = op.fProxy;
-            }
-            ++i;
+            mesh->setIndexedPatterned(ibuffer.get(), 6, 4, fDraws.count(),
+                                      GrResourceProvider::QuadCountOfQuadBuffer());
+        } else {
+            mesh->setNonIndexedNonInstanced(4);
         }
-        target->draw(std::move(gp), pipeline, fixedDynamicState, dynamicStateArrays, meshes,
-                     numOps);
+        mesh->setVertexData(vbuffer, vstart);
+        target->draw(std::move(gp), pipeline, fixedDynamicState, mesh);
     }
 
-    CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
+    CombineResult onCombineIfPossible(GrOp* t, const GrCaps&) override {
         const auto* that = t->cast<TextureOp>();
         if (!GrColorSpaceXform::Equals(fTextureColorSpaceXform.get(),
                                        that->fTextureColorSpaceXform.get())) {
@@ -742,20 +721,7 @@
         if (this->aaType() != that->aaType()) {
             return CombineResult::kCannotCombine;
         }
-        if (fFilter != that->fFilter) {
-            return CombineResult::kCannotCombine;
-        }
-        if (fProxy->uniqueID() != that->fProxy->uniqueID() || that->isChained()) {
-#if 0  // Disabled for crbug.com/877598 crbug.com/877610 and bad image-surface GM on S7 MaliT880
-       // bot.
-            // We can't merge across different proxies (and we're disallowed from merging when
-            // 'that' is chained. Check if we can be chained with 'that'.
-            if (fProxy->config() == that->fProxy->config() &&
-                fProxy->textureType() == that->fProxy->textureType() &&
-                caps.dynamicStateArrayGeometryProcessorTextureSupport()) {
-                return CombineResult::kMayChain;
-            }
-#endif
+        if (fProxy->uniqueID() != that->fProxy->uniqueID() || fFilter != that->fFilter) {
             return CombineResult::kCannotCombine;
         }
         fDraws.push_back_n(that->fDraws.count(), that->fDraws.begin());