Update MakeChildFP to allow processor hierarchies to be created.
Previously, MakeChildFP avoided infinite recursion by rejecting any FP
that took inputs. MakeChildFP now generates random inputs up to a
user-supplied tree depth.
The ProcessorOptimizationValidationTest test has been updated to
test up to a tree depth of 3. The ProcessorCloneTest has been left at
a tree depth of 1 due to a bug that only appears on Galaxy S20/Mali G77.
The Mali bug doesn't appear to be related to FP cloning, but probably
deserves further analysis. (It appears that on this device, these
processors hooked together in sequence render a tiny bit differently
each time: DitherEffect -> RectBlurEffect -> ImprovedPerlinNoise. By
visual inspection it looks like the dither varies on each draw.)
Change-Id: Ib8f619eb7a8a9c9254080303504c20065ff35453
Bug: skia:10384, skia:10595
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308556
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/GrProcessorUnitTest.h b/src/gpu/GrProcessorUnitTest.h
index 5225c1f..7c2cbde 100644
--- a/src/gpu/GrProcessorUnitTest.h
+++ b/src/gpu/GrProcessorUnitTest.h
@@ -37,25 +37,27 @@
};
/** This allows parent FPs to implement a test create with known leaf children in order to avoid
-creating an unbounded FP tree which may overflow various shader limits. */
+ * creating an unbounded FP tree which may overflow various shader limits.
+ * MakeOptionalChildFP is the same as MakeChildFP, but can return null.
+ */
std::unique_ptr<GrFragmentProcessor> MakeChildFP(GrProcessorTestData*);
+std::unique_ptr<GrFragmentProcessor> MakeOptionalChildFP(GrProcessorTestData*);
} // namespace GrProcessorUnitTest
-/*
- * GrProcessorTestData is an argument struct to TestCreate functions
- * fTextures are valid textures that can optionally be used to construct
- * TextureSampler. The first texture has a RGBA8 format and the second has Alpha8 format for the
- * specific backend API. TestCreate functions are also free to create additional textures using
- * the GrContext.
+/** GrProcessorTestData is an argument struct to TestCreate functions
+ * fTextures are valid textures that can optionally be used to construct
+ * TextureSampler. The first texture has a RGBA8 format and the second has Alpha8 format for the
+ * specific backend API. TestCreate functions are also free to create additional textures using
+ * the GrContext.
*/
class GrProcessorTestData {
public:
using ViewInfo = std::tuple<GrSurfaceProxyView, GrColorType, SkAlphaType>;
- GrProcessorTestData(SkRandom* random, GrRecordingContext* context,
+ GrProcessorTestData(SkRandom* random, GrRecordingContext* context, int maxTreeDepth,
int numViews, const ViewInfo views[]);
- GrProcessorTestData(SkRandom* random, GrRecordingContext* context,
+ GrProcessorTestData(SkRandom* random, GrRecordingContext* context, int maxTreeDepth,
int numViews, const ViewInfo views[],
std::unique_ptr<GrFragmentProcessor> inputFP);
GrProcessorTestData(const GrProcessorTestData&) = delete;
@@ -71,6 +73,8 @@
ViewInfo randomAlphaOnlyView();
SkRandom* fRandom;
+ int fCurrentTreeDepth = 0;
+ int fMaxTreeDepth = 1;
private:
GrRecordingContext* fContext;