Create ProgramImpls for child FPs.

These are not very useful yet, since the only allowed FPs are null.

Bug: b/40045302
Change-Id: I08a1b58cb5b0da6849b411dcd61c5a9ea4eb9f6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/761656
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ganesh/ops/DrawMeshOp.cpp b/src/gpu/ganesh/ops/DrawMeshOp.cpp
index 89a58d9..8445b4c 100644
--- a/src/gpu/ganesh/ops/DrawMeshOp.cpp
+++ b/src/gpu/ganesh/ops/DrawMeshOp.cpp
@@ -21,6 +21,7 @@
 #include "src/gpu/ganesh/GrProgramInfo.h"
 #include "src/gpu/ganesh/glsl/GrGLSLColorSpaceXformHelper.h"
 #include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
+#include "src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h"
 #include "src/gpu/ganesh/glsl/GrGLSLVarying.h"
 #include "src/gpu/ganesh/glsl/GrGLSLVertexGeoBuilder.h"
 #include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h"
@@ -58,14 +59,16 @@
     using ChildPtr = SkRuntimeEffect::ChildPtr;
 
 public:
-    static GrGeometryProcessor* Make(SkArenaAlloc* arena,
-                                     sk_sp<SkMeshSpecification> spec,
-                                     sk_sp<GrColorSpaceXform> colorSpaceXform,
-                                     const SkMatrix& viewMatrix,
-                                     const std::optional<SkPMColor4f>& color,
-                                     bool needsLocalCoords,
-                                     sk_sp<const SkData> uniforms,
-                                     SkSpan<std::unique_ptr<GrFragmentProcessor>> children) {
+    static GrGeometryProcessor* Make(
+            SkArenaAlloc* arena,
+            sk_sp<SkMeshSpecification> spec,
+            sk_sp<GrColorSpaceXform> colorSpaceXform,
+            const SkMatrix& viewMatrix,
+            const std::optional<SkPMColor4f>& color,
+            bool needsLocalCoords,
+            sk_sp<const SkData> uniforms,
+            SkSpan<std::unique_ptr<GrFragmentProcessor>> children,
+            SkSpan<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> childImpls) {
         return arena->make([&](void* ptr) {
             return new (ptr) MeshGP(std::move(spec),
                                     std::move(colorSpaceXform),
@@ -73,7 +76,8 @@
                                     std::move(color),
                                     needsLocalCoords,
                                     std::move(uniforms),
-                                    children);
+                                    children,
+                                    childImpls);
         });
     }
 
@@ -453,20 +457,24 @@
         GrGLSLColorSpaceXformHelper fColorSpaceHelper;
     };
 
-    MeshGP(sk_sp<SkMeshSpecification>                   spec,
-           sk_sp<GrColorSpaceXform>                     colorSpaceXform,
-           const SkMatrix&                              viewMatrix,
-           const std::optional<SkPMColor4f>&            color,
-           bool                                         needsLocalCoords,
-           sk_sp<const SkData>                          uniforms,
-           SkSpan<std::unique_ptr<GrFragmentProcessor>> children)
+    MeshGP(sk_sp<SkMeshSpecification>                                spec,
+           sk_sp<GrColorSpaceXform>                                  colorSpaceXform,
+           const SkMatrix&                                           viewMatrix,
+           const std::optional<SkPMColor4f>&                         color,
+           bool                                                      needsLocalCoords,
+           sk_sp<const SkData>                                       uniforms,
+           SkSpan<std::unique_ptr<GrFragmentProcessor>>              children,
+           SkSpan<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> childImpls)
             : INHERITED(kVerticesGP_ClassID)
             , fSpec(std::move(spec))
             , fUniforms(std::move(uniforms))
             , fChildren(children)
+            , fChildImpls(childImpls)
             , fViewMatrix(viewMatrix)
             , fColorSpaceXform(std::move(colorSpaceXform))
             , fNeedsLocalCoords(needsLocalCoords) {
+        SkASSERT(fChildren.size() == fChildImpls.size());
+
         fColor = color.value_or(SK_PMColor4fILLEGAL);
         for (const auto& srcAttr : fSpec->attributes()) {
             fAttributes.emplace_back(srcAttr.name.c_str(),
@@ -477,14 +485,15 @@
         this->setVertexAttributes(fAttributes.data(), fAttributes.size(), fSpec->stride());
     }
 
-    sk_sp<SkMeshSpecification>                   fSpec;
-    sk_sp<const SkData>                          fUniforms;
-    SkSpan<std::unique_ptr<GrFragmentProcessor>> fChildren;  // backed by TArray in the MeshOp
-    std::vector<Attribute>                       fAttributes;
-    SkMatrix                                     fViewMatrix;
-    SkPMColor4f                                  fColor;
-    sk_sp<GrColorSpaceXform>                     fColorSpaceXform;
-    bool                                         fNeedsLocalCoords;
+    sk_sp<SkMeshSpecification> fSpec;
+    sk_sp<const SkData> fUniforms;
+    SkSpan<std::unique_ptr<GrFragmentProcessor>> fChildren;  // backed by a TArray in the MeshOp
+    SkSpan<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fChildImpls; //  "   "    "    "
+    std::vector<Attribute> fAttributes;
+    SkMatrix fViewMatrix;
+    SkPMColor4f fColor;
+    sk_sp<GrColorSpaceXform> fColorSpaceXform;
+    bool fNeedsLocalCoords;
 
     using INHERITED = GrGeometryProcessor;
 };
@@ -675,6 +684,7 @@
     GrSimpleMesh*              fMesh = nullptr;
     GrProgramInfo*             fProgramInfo = nullptr;
     TArray<std::unique_ptr<GrFragmentProcessor>> fChildren;
+    TArray<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fChildImpls;
 
     using INHERITED = GrMeshDrawOp;
 };
@@ -785,6 +795,11 @@
 
     fChildren = std::move(children);
 
+    fChildImpls.reserve_exact(fChildren.size());
+    for (const std::unique_ptr<GrFragmentProcessor>& fp : fChildren) {
+        fChildImpls.push_back(fp ? fp->makeProgramImpl() : nullptr);
+    }
+
     fVertexCount = fMeshes.back().vertexCount();
     fIndexCount  = fMeshes.back().indexCount();
 
@@ -940,7 +955,8 @@
                         color,
                         fHelper.usesLocalCoords(),
                         fUniforms,
-                        SkSpan(fChildren));
+                        SkSpan(fChildren),
+                        SkSpan(fChildImpls));
 }
 
 void MeshOp::onCreateProgramInfo(const GrCaps* caps,