Track all sampled textures in GrOpsTask and pass them to GrOpsRenderPass.

In Vulkan we use this list to set the layout for these surface to be
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL at GrOpsRenderPass creation
instead of at submit. This gets us closer to being able to run with
primary or secondary command buffers.

Change-Id: I6e307485987e2c024ed9ecba3e41f588047c5f07
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238444
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrOpsTask.h b/src/gpu/GrOpsTask.h
index b005671..e2f2682 100644
--- a/src/gpu/GrOpsTask.h
+++ b/src/gpu/GrOpsTask.h
@@ -57,6 +57,10 @@
     void onPrepare(GrOpFlushState* flushState) override;
     bool onExecute(GrOpFlushState* flushState) override;
 
+    void addSampledTexture(GrTextureProxy* proxy) {
+        fSampledProxies.push_back(proxy);
+    }
+
     void addOp(std::unique_ptr<GrOp> op, GrTextureResolveManager textureResolveManager,
                const GrCaps& caps) {
         auto addDependency = [ textureResolveManager, &caps, this ] (
@@ -80,12 +84,14 @@
                    GrTextureResolveManager textureResolveManager, const GrCaps& caps) {
         auto addDependency = [ textureResolveManager, &caps, this ] (
                 GrTextureProxy* p, GrMipMapped mipmapped) {
+            this->addSampledTexture(p);
             this->addDependency(p, mipmapped, textureResolveManager, caps);
         };
 
         op->visitProxies(addDependency);
         clip.visitProxies(addDependency);
         if (dstProxy.proxy()) {
+            this->addSampledTexture(dstProxy.proxy());
             addDependency(dstProxy.proxy(), GrMipMapped::kNo);
         }
 
@@ -261,6 +267,9 @@
     SkArenaAlloc fClipAllocator{4096};
     SkDEBUGCODE(int fNumClips;)
 
+    // TODO: We could look into this being a set if we find we're adding a lot of duplicates that is
+    // causing slow downs.
+    SkTArray<GrTextureProxy*, true> fSampledProxies;
 };
 
 #endif