Reland "Remove GrDeviceSpaceTextureDecalFragmentProcessor."
This is a reland of af5f9f008de060a91d8069c876a765f11c3d36f6
This was reverted due to Metal GMs failing. That is a bug in Metal where
pipeline creation fails with "internal error". Reporting to Apple, filing
Skia bug, and moving on.
Original change's description:
> Remove GrDeviceSpaceTextureDecalFragmentProcessor.
>
> It was used to sample clip masks using device coords.
>
> Replace with a more generic GrDeviceSpaceEffect that simply calls a
> child FP with sk_FragCoord.
>
> Also fix issue in GrQuadPerEdgeAA GP. It wouldn't setup coord transforms
> at all if they are all applied in the FS (explicit coords). Moreover,
> the GrGLSLGeometryProcessor::emitTransforms() helper required a valid VS
> var for local coords even when all FPs use explicit coords and wouldn't
> use a local coords var.
>
> Make CPP SkSL code gen for clone copy the explicit coord status of
> children.
>
> Change-Id: Ib8bb36028354405c8012f6e91e9eb46db75d16a6
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271658
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
Change-Id: Ia4530e6799019cd92863fe983a2d3c71df6f0620
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273511
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp b/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
new file mode 100644
index 0000000..8df3a1b
--- /dev/null
+++ b/src/gpu/effects/generated/GrDeviceSpaceEffect.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**************************************************************************************************
+ *** This file was autogenerated from GrDeviceSpaceEffect.fp; do not modify.
+ **************************************************************************************************/
+#include "GrDeviceSpaceEffect.h"
+
+#include "include/gpu/GrTexture.h"
+#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
+#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
+#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
+#include "src/sksl/SkSLCPP.h"
+#include "src/sksl/SkSLUtil.h"
+class GrGLSLDeviceSpaceEffect : public GrGLSLFragmentProcessor {
+public:
+ GrGLSLDeviceSpaceEffect() {}
+ void emitCode(EmitArgs& args) override {
+ GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
+ const GrDeviceSpaceEffect& _outer = args.fFp.cast<GrDeviceSpaceEffect>();
+ (void)_outer;
+ SkString _input204 = SkStringPrintf("%s", args.fInputColor);
+ SkString _sample204;
+ SkString _coords204("sk_FragCoord.xy");
+ _sample204 =
+ this->invokeChild(_outer.fp_index, _input204.c_str(), args, _coords204.c_str());
+ fragBuilder->codeAppendf("%s = %s;\n", args.fOutputColor, _sample204.c_str());
+ }
+
+private:
+ void onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrFragmentProcessor& _proc) override {}
+};
+GrGLSLFragmentProcessor* GrDeviceSpaceEffect::onCreateGLSLInstance() const {
+ return new GrGLSLDeviceSpaceEffect();
+}
+void GrDeviceSpaceEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
+ GrProcessorKeyBuilder* b) const {}
+bool GrDeviceSpaceEffect::onIsEqual(const GrFragmentProcessor& other) const {
+ const GrDeviceSpaceEffect& that = other.cast<GrDeviceSpaceEffect>();
+ (void)that;
+ return true;
+}
+GrDeviceSpaceEffect::GrDeviceSpaceEffect(const GrDeviceSpaceEffect& src)
+ : INHERITED(kGrDeviceSpaceEffect_ClassID, src.optimizationFlags()), fp_index(src.fp_index) {
+ {
+ auto clone = src.childProcessor(fp_index).clone();
+ clone->setSampledWithExplicitCoords(
+ src.childProcessor(fp_index).isSampledWithExplicitCoords());
+ this->registerChildProcessor(std::move(clone));
+ }
+}
+std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceEffect::clone() const {
+ return std::unique_ptr<GrFragmentProcessor>(new GrDeviceSpaceEffect(*this));
+}
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceEffect);
+#if GR_TEST_UTILS
+std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceEffect::TestCreate(GrProcessorTestData* d) {
+ std::unique_ptr<GrFragmentProcessor> fp;
+ // We have a restriction that explicit coords only work for FPs with exactly one
+ // coord transform.
+ do {
+ fp = GrProcessorUnitTest::MakeChildFP(d);
+ } while (fp->numCoordTransforms() != 1);
+ return GrDeviceSpaceEffect::Make(std::move(fp));
+}
+#endif