Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkTypes.h" |
| 9 | #include "Test.h" |
| 10 | |
Brian Salomon | c65aec9 | 2017-03-09 09:03:58 -0500 | [diff] [blame] | 11 | #include "GrClip.h" |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 12 | #include "GrContext.h" |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 13 | #include "GrContextPriv.h" |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 14 | #include "GrGpuResource.h" |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 15 | #include "GrMemoryPool.h" |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 16 | #include "GrProxyProvider.h" |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 17 | #include "GrRenderTargetContext.h" |
| 18 | #include "GrRenderTargetContextPriv.h" |
| 19 | #include "GrResourceProvider.h" |
| 20 | #include "glsl/GrGLSLFragmentProcessor.h" |
| 21 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 22 | #include "ops/GrFillRectOp.h" |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 23 | #include "ops/GrMeshDrawOp.h" |
Michael Ludwig | e8e1075 | 2018-10-01 12:42:53 -0400 | [diff] [blame] | 24 | #include "TestUtils.h" |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 25 | |
Mike Klein | 0ec1c57 | 2018-12-04 11:52:51 -0500 | [diff] [blame] | 26 | #include <atomic> |
Hal Canary | 8a00144 | 2018-09-19 11:31:27 -0400 | [diff] [blame] | 27 | #include <random> |
| 28 | |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 29 | namespace { |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 30 | class TestOp : public GrMeshDrawOp { |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 31 | public: |
| 32 | DEFINE_OP_CLASS_ID |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 33 | static std::unique_ptr<GrDrawOp> Make(GrContext* context, |
| 34 | std::unique_ptr<GrFragmentProcessor> fp) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 35 | GrOpMemoryPool* pool = context->priv().opMemoryPool(); |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 36 | |
| 37 | return pool->allocate<TestOp>(std::move(fp)); |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 38 | } |
| 39 | |
Robert Phillips | 5f567c7 | 2017-09-14 08:27:37 -0400 | [diff] [blame] | 40 | const char* name() const override { return "TestOp"; } |
| 41 | |
Brian Salomon | 7d94bb5 | 2018-10-12 14:37:19 -0400 | [diff] [blame] | 42 | void visitProxies(const VisitProxyFunc& func, VisitorType) const override { |
Robert Phillips | 5f567c7 | 2017-09-14 08:27:37 -0400 | [diff] [blame] | 43 | fProcessors.visitProxies(func); |
| 44 | } |
| 45 | |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 46 | FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; } |
| 47 | |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame^] | 48 | GrProcessorSet::Analysis finalize(const GrCaps& caps, const GrAppliedClip* clip, |
| 49 | GrFSAAType fsaaType, GrClampType clampType) override { |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 50 | static constexpr GrProcessorAnalysisColor kUnknownColor; |
Brian Osman | cf86085 | 2018-10-31 14:04:39 -0400 | [diff] [blame] | 51 | SkPMColor4f overrideColor; |
Chris Dalton | b8fff0d | 2019-03-05 10:11:58 -0700 | [diff] [blame] | 52 | return fProcessors.finalize( |
| 53 | kUnknownColor, GrProcessorAnalysisCoverage::kNone, clip, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame^] | 54 | &GrUserStencilSettings::kUnused, fsaaType, caps, clampType, &overrideColor); |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 55 | } |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 56 | |
| 57 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 58 | friend class ::GrOpMemoryPool; // for ctor |
| 59 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 60 | TestOp(std::unique_ptr<GrFragmentProcessor> fp) |
| 61 | : INHERITED(ClassID()), fProcessors(std::move(fp)) { |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 62 | this->setBounds(SkRect::MakeWH(100, 100), HasAABloat::kNo, IsZeroArea::kNo); |
| 63 | } |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 64 | |
Brian Salomon | 91326c3 | 2017-08-09 16:02:19 -0400 | [diff] [blame] | 65 | void onPrepareDraws(Target* target) override { return; } |
Chris Dalton | 07cdcfc9 | 2019-02-26 11:13:22 -0700 | [diff] [blame] | 66 | void onExecute(GrOpFlushState*, const SkRect&) override { return; } |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 67 | |
Brian Salomon | 82ddc94 | 2017-07-14 12:00:13 -0400 | [diff] [blame] | 68 | GrProcessorSet fProcessors; |
| 69 | |
| 70 | typedef GrMeshDrawOp INHERITED; |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /** |
| 74 | * FP used to test ref/IO counts on owned GrGpuResources. Can also be a parent FP to test counts |
| 75 | * of resources owned by child FPs. |
| 76 | */ |
| 77 | class TestFP : public GrFragmentProcessor { |
| 78 | public: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 79 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child) { |
| 80 | return std::unique_ptr<GrFragmentProcessor>(new TestFP(std::move(child))); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 81 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 82 | static std::unique_ptr<GrFragmentProcessor> Make(const SkTArray<sk_sp<GrTextureProxy>>& proxies, |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 83 | const SkTArray<sk_sp<GrGpuBuffer>>& buffers) { |
Brian Salomon | 559f556 | 2017-11-15 14:28:33 -0500 | [diff] [blame] | 84 | return std::unique_ptr<GrFragmentProcessor>(new TestFP(proxies, buffers)); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | const char* name() const override { return "test"; } |
| 88 | |
| 89 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override { |
Mike Klein | 0ec1c57 | 2018-12-04 11:52:51 -0500 | [diff] [blame] | 90 | static std::atomic<int32_t> nextKey{0}; |
| 91 | b->add32(nextKey++); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 92 | } |
| 93 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 94 | std::unique_ptr<GrFragmentProcessor> clone() const override { |
| 95 | return std::unique_ptr<GrFragmentProcessor>(new TestFP(*this)); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 96 | } |
| 97 | |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 98 | private: |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 99 | TestFP(const SkTArray<sk_sp<GrTextureProxy>>& proxies, |
| 100 | const SkTArray<sk_sp<GrGpuBuffer>>& buffers) |
Brian Salomon | 662ea4b | 2018-07-12 14:53:49 -0400 | [diff] [blame] | 101 | : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4) { |
Robert Phillips | 30f9bc6 | 2017-02-22 15:28:38 -0500 | [diff] [blame] | 102 | for (const auto& proxy : proxies) { |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 103 | fSamplers.emplace_back(proxy); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 104 | } |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 105 | this->setTextureSamplerCnt(fSamplers.count()); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 106 | } |
| 107 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 108 | TestFP(std::unique_ptr<GrFragmentProcessor> child) |
Brian Salomon | 662ea4b | 2018-07-12 14:53:49 -0400 | [diff] [blame] | 109 | : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4) { |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 110 | this->registerChildProcessor(std::move(child)); |
| 111 | } |
| 112 | |
Brian Salomon | 96271cd | 2017-07-31 16:27:23 -0400 | [diff] [blame] | 113 | explicit TestFP(const TestFP& that) |
Brian Salomon | 662ea4b | 2018-07-12 14:53:49 -0400 | [diff] [blame] | 114 | : INHERITED(kTestFP_ClassID, that.optimizationFlags()), fSamplers(4) { |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 115 | for (int i = 0; i < that.fSamplers.count(); ++i) { |
| 116 | fSamplers.emplace_back(that.fSamplers[i]); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 117 | } |
Brian Salomon | 96271cd | 2017-07-31 16:27:23 -0400 | [diff] [blame] | 118 | for (int i = 0; i < that.numChildProcessors(); ++i) { |
| 119 | this->registerChildProcessor(that.childProcessor(i).clone()); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 120 | } |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 121 | this->setTextureSamplerCnt(fSamplers.count()); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 122 | } |
| 123 | |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 124 | virtual GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
| 125 | class TestGLSLFP : public GrGLSLFragmentProcessor { |
| 126 | public: |
| 127 | TestGLSLFP() {} |
| 128 | void emitCode(EmitArgs& args) override { |
| 129 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 130 | fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, args.fInputColor); |
| 131 | } |
| 132 | |
| 133 | private: |
| 134 | }; |
| 135 | return new TestGLSLFP(); |
| 136 | } |
| 137 | |
| 138 | bool onIsEqual(const GrFragmentProcessor&) const override { return false; } |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 139 | const TextureSampler& onTextureSampler(int i) const override { return fSamplers[i]; } |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 140 | |
| 141 | GrTAllocator<TextureSampler> fSamplers; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 142 | typedef GrFragmentProcessor INHERITED; |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 143 | }; |
| 144 | } |
| 145 | |
Brian Salomon | f046e15 | 2017-01-11 15:24:47 -0500 | [diff] [blame] | 146 | template <typename T> |
| 147 | inline void testingOnly_getIORefCnts(const T* resource, int* refCnt, int* readCnt, int* writeCnt) { |
| 148 | *refCnt = resource->fRefCnt; |
| 149 | *readCnt = resource->fPendingReads; |
| 150 | *writeCnt = resource->fPendingWrites; |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 151 | } |
| 152 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 153 | void testingOnly_getIORefCnts(GrTextureProxy* proxy, int* refCnt, int* readCnt, int* writeCnt) { |
Robert Phillips | 30f9bc6 | 2017-02-22 15:28:38 -0500 | [diff] [blame] | 154 | *refCnt = proxy->getBackingRefCnt_TestOnly(); |
| 155 | *readCnt = proxy->getPendingReadCnt_TestOnly(); |
| 156 | *writeCnt = proxy->getPendingWriteCnt_TestOnly(); |
| 157 | } |
| 158 | |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 159 | DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { |
| 160 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 161 | GrProxyProvider* proxyProvider = context->priv().proxyProvider(); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 162 | |
Robert Phillips | 16d8ec6 | 2017-07-27 16:16:25 -0400 | [diff] [blame] | 163 | GrSurfaceDesc desc; |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 164 | desc.fWidth = 10; |
| 165 | desc.fHeight = 10; |
Robert Phillips | 16d8ec6 | 2017-07-27 16:16:25 -0400 | [diff] [blame] | 166 | desc.fConfig = kRGBA_8888_GrPixelConfig; |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 167 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 168 | const GrBackendFormat format = |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 169 | context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 170 | |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 171 | for (bool makeClone : {false, true}) { |
| 172 | for (int parentCnt = 0; parentCnt < 2; parentCnt++) { |
| 173 | sk_sp<GrRenderTargetContext> renderTargetContext( |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 174 | context->priv().makeDeferredRenderTargetContext( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 175 | format, SkBackingFit::kApprox, 1, 1, |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 176 | kRGBA_8888_GrPixelConfig, nullptr)); |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 177 | { |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 178 | sk_sp<GrTextureProxy> proxy1 = proxyProvider->createProxy( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 179 | format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, |
| 180 | SkBudgeted::kYes); |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 181 | sk_sp<GrTextureProxy> proxy2 = proxyProvider->createProxy( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 182 | format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, |
| 183 | SkBudgeted::kYes); |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 184 | sk_sp<GrTextureProxy> proxy3 = proxyProvider->createProxy( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 185 | format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, |
| 186 | SkBudgeted::kYes); |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 187 | sk_sp<GrTextureProxy> proxy4 = proxyProvider->createProxy( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 188 | format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, |
| 189 | SkBudgeted::kYes); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 190 | { |
| 191 | SkTArray<sk_sp<GrTextureProxy>> proxies; |
Brian Salomon | dbf7072 | 2019-02-07 11:31:24 -0500 | [diff] [blame] | 192 | SkTArray<sk_sp<GrGpuBuffer>> buffers; |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 193 | proxies.push_back(proxy1); |
Brian Salomon | 559f556 | 2017-11-15 14:28:33 -0500 | [diff] [blame] | 194 | auto fp = TestFP::Make(std::move(proxies), std::move(buffers)); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 195 | for (int i = 0; i < parentCnt; ++i) { |
| 196 | fp = TestFP::Make(std::move(fp)); |
| 197 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 198 | std::unique_ptr<GrFragmentProcessor> clone; |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 199 | if (makeClone) { |
| 200 | clone = fp->clone(); |
| 201 | } |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 202 | std::unique_ptr<GrDrawOp> op(TestOp::Make(context, std::move(fp))); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 203 | renderTargetContext->priv().testingOnly_addDrawOp(std::move(op)); |
| 204 | if (clone) { |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 205 | op = TestOp::Make(context, std::move(clone)); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 206 | renderTargetContext->priv().testingOnly_addDrawOp(std::move(op)); |
| 207 | } |
| 208 | } |
| 209 | int refCnt, readCnt, writeCnt; |
| 210 | |
| 211 | testingOnly_getIORefCnts(proxy1.get(), &refCnt, &readCnt, &writeCnt); |
| 212 | // IO counts should be double if there is a clone of the FP. |
| 213 | int ioRefMul = makeClone ? 2 : 1; |
Robert Phillips | 715d08c | 2018-07-18 13:56:48 -0400 | [diff] [blame] | 214 | REPORTER_ASSERT(reporter, -1 == refCnt); |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 215 | REPORTER_ASSERT(reporter, ioRefMul * 1 == readCnt); |
| 216 | REPORTER_ASSERT(reporter, ioRefMul * 0 == writeCnt); |
| 217 | |
Brian Salomon | b17e639 | 2017-07-28 13:41:51 -0400 | [diff] [blame] | 218 | context->flush(); |
| 219 | |
| 220 | testingOnly_getIORefCnts(proxy1.get(), &refCnt, &readCnt, &writeCnt); |
| 221 | REPORTER_ASSERT(reporter, 1 == refCnt); |
| 222 | REPORTER_ASSERT(reporter, ioRefMul * 0 == readCnt); |
| 223 | REPORTER_ASSERT(reporter, ioRefMul * 0 == writeCnt); |
| 224 | |
Brian Salomon | bc6b99d | 2017-01-11 10:32:34 -0500 | [diff] [blame] | 225 | } |
| 226 | } |
| 227 | } |
| 228 | } |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 229 | |
| 230 | // This test uses the random GrFragmentProcessor test factory, which relies on static initializers. |
| 231 | #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 232 | |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 233 | #include "SkCommandLineFlags.h" |
| 234 | DEFINE_bool(randomProcessorTest, false, "Use non-deterministic seed for random processor tests?"); |
Michael Ludwig | 3ad86d0 | 2018-09-28 16:00:38 -0400 | [diff] [blame] | 235 | DEFINE_uint32(processorSeed, 0, "Use specific seed for processor tests. Overridden by " \ |
| 236 | "--randomProcessorTest."); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 237 | |
| 238 | #if GR_TEST_UTILS |
| 239 | |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 240 | static GrColor input_texel_color(int i, int j, SkScalar delta) { |
| 241 | // Delta must be less than 0.5 to prevent over/underflow issues with the input color |
| 242 | SkASSERT(delta <= 0.5); |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 243 | |
Brian Osman | 50ea3c0 | 2019-02-04 10:01:53 -0500 | [diff] [blame] | 244 | SkColor color = SkColorSetARGB((uint8_t)(i & 0xFF), |
| 245 | (uint8_t)(j & 0xFF), |
| 246 | (uint8_t)((i + j) & 0xFF), |
| 247 | (uint8_t)((2 * j - i) & 0xFF)); |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 248 | SkColor4f color4f = SkColor4f::FromColor(color); |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 249 | for (int i = 0; i < 4; i++) { |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 250 | if (color4f[i] > 0.5) { |
| 251 | color4f[i] -= delta; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 252 | } else { |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 253 | color4f[i] += delta; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 254 | } |
| 255 | } |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 256 | return color4f.premul().toBytes_RGBA(); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 257 | } |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 258 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 259 | void test_draw_op(GrContext* context, |
| 260 | GrRenderTargetContext* rtc, |
| 261 | std::unique_ptr<GrFragmentProcessor> fp, |
Robert Phillips | 30f9bc6 | 2017-02-22 15:28:38 -0500 | [diff] [blame] | 262 | sk_sp<GrTextureProxy> inputDataProxy) { |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 263 | GrPaint paint; |
Brian Osman | 2240be9 | 2017-10-18 13:15:13 -0400 | [diff] [blame] | 264 | paint.addColorTextureProcessor(std::move(inputDataProxy), SkMatrix::I()); |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 265 | paint.addColorFragmentProcessor(std::move(fp)); |
| 266 | paint.setPorterDuffXPFactory(SkBlendMode::kSrc); |
Brian Salomon | ac70f84 | 2017-05-08 10:43:33 -0400 | [diff] [blame] | 267 | |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 268 | auto op = GrFillRectOp::Make(context, std::move(paint), GrAAType::kNone, SkMatrix::I(), |
| 269 | SkRect::MakeWH(rtc->width(), rtc->height())); |
Brian Salomon | ac70f84 | 2017-05-08 10:43:33 -0400 | [diff] [blame] | 270 | rtc->addDrawOp(GrNoClip(), std::move(op)); |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 271 | } |
| 272 | |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 273 | // This assumes that the output buffer will be the same size as inputDataProxy |
| 274 | void render_fp(GrContext* context, GrRenderTargetContext* rtc, GrFragmentProcessor* fp, |
| 275 | sk_sp<GrTextureProxy> inputDataProxy, GrColor* buffer) { |
| 276 | int width = inputDataProxy->width(); |
| 277 | int height = inputDataProxy->height(); |
| 278 | |
| 279 | // test_draw_op needs to take ownership of an FP, so give it a clone that it can own |
| 280 | test_draw_op(context, rtc, fp->clone(), inputDataProxy); |
| 281 | memset(buffer, 0x0, sizeof(GrColor) * width * height); |
| 282 | rtc->readPixels(SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, |
| 283 | kPremul_SkAlphaType), |
| 284 | buffer, 0, 0, 0); |
| 285 | } |
| 286 | |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 287 | /** Initializes the two test texture proxies that are available to the FP test factories. */ |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 288 | bool init_test_textures(GrProxyProvider* proxyProvider, SkRandom* random, |
| 289 | sk_sp<GrTextureProxy> proxies[2]) { |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 290 | static const int kTestTextureSize = 256; |
Brian Osman | c35a2d4 | 2017-03-17 10:58:53 -0400 | [diff] [blame] | 291 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 292 | { |
| 293 | // Put premul data into the RGBA texture that the test FPs can optionally use. |
| 294 | std::unique_ptr<GrColor[]> rgbaData(new GrColor[kTestTextureSize * kTestTextureSize]); |
| 295 | for (int y = 0; y < kTestTextureSize; ++y) { |
| 296 | for (int x = 0; x < kTestTextureSize; ++x) { |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 297 | rgbaData[kTestTextureSize * y + x] = input_texel_color( |
| 298 | random->nextULessThan(256), random->nextULessThan(256), 0.0f); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 299 | } |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 300 | } |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 301 | |
Brian Osman | 2700abc | 2018-09-12 10:19:41 -0400 | [diff] [blame] | 302 | SkImageInfo ii = SkImageInfo::Make(kTestTextureSize, kTestTextureSize, |
| 303 | kRGBA_8888_SkColorType, kPremul_SkAlphaType); |
| 304 | SkPixmap pixmap(ii, rgbaData.get(), ii.minRowBytes()); |
| 305 | sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap); |
| 306 | proxies[0] = proxyProvider->createTextureProxy(img, kNone_GrSurfaceFlags, 1, |
| 307 | SkBudgeted::kYes, SkBackingFit::kExact); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 308 | } |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 309 | |
| 310 | { |
| 311 | // Put random values into the alpha texture that the test FPs can optionally use. |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 312 | std::unique_ptr<uint8_t[]> alphaData(new uint8_t[kTestTextureSize * kTestTextureSize]); |
| 313 | for (int y = 0; y < kTestTextureSize; ++y) { |
| 314 | for (int x = 0; x < kTestTextureSize; ++x) { |
| 315 | alphaData[kTestTextureSize * y + x] = random->nextULessThan(256); |
| 316 | } |
| 317 | } |
| 318 | |
Brian Osman | 2700abc | 2018-09-12 10:19:41 -0400 | [diff] [blame] | 319 | SkImageInfo ii = SkImageInfo::Make(kTestTextureSize, kTestTextureSize, |
| 320 | kAlpha_8_SkColorType, kPremul_SkAlphaType); |
| 321 | SkPixmap pixmap(ii, alphaData.get(), ii.minRowBytes()); |
| 322 | sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap); |
| 323 | proxies[1] = proxyProvider->createTextureProxy(img, kNone_GrSurfaceFlags, 1, |
| 324 | SkBudgeted::kYes, SkBackingFit::kExact); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 325 | } |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 326 | |
| 327 | return proxies[0] && proxies[1]; |
| 328 | } |
| 329 | |
| 330 | // Creates a texture of premul colors used as the output of the fragment processor that precedes |
| 331 | // the fragment processor under test. Color values are those provided by input_texel_color(). |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 332 | sk_sp<GrTextureProxy> make_input_texture(GrProxyProvider* proxyProvider, int width, int height, |
| 333 | SkScalar delta) { |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 334 | std::unique_ptr<GrColor[]> data(new GrColor[width * height]); |
| 335 | for (int y = 0; y < width; ++y) { |
| 336 | for (int x = 0; x < height; ++x) { |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 337 | data.get()[width * y + x] = input_texel_color(x, y, delta); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 338 | } |
| 339 | } |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 340 | |
Brian Osman | 2700abc | 2018-09-12 10:19:41 -0400 | [diff] [blame] | 341 | SkImageInfo ii = SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, kPremul_SkAlphaType); |
| 342 | SkPixmap pixmap(ii, data.get(), ii.minRowBytes()); |
| 343 | sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap); |
| 344 | return proxyProvider->createTextureProxy(img, kNone_GrSurfaceFlags, 1, |
| 345 | SkBudgeted::kYes, SkBackingFit::kExact); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 346 | } |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 347 | |
Michael Ludwig | e8e1075 | 2018-10-01 12:42:53 -0400 | [diff] [blame] | 348 | bool log_surface_context(sk_sp<GrSurfaceContext> src, SkString* dst) { |
| 349 | SkImageInfo ii = SkImageInfo::Make(src->width(), src->height(), kRGBA_8888_SkColorType, |
| 350 | kPremul_SkAlphaType); |
| 351 | SkBitmap bm; |
| 352 | SkAssertResult(bm.tryAllocPixels(ii)); |
| 353 | SkAssertResult(src->readPixels(ii, bm.getPixels(), bm.rowBytes(), 0, 0)); |
| 354 | |
| 355 | return bitmap_to_base64_data_uri(bm, dst); |
| 356 | } |
| 357 | |
| 358 | bool log_surface_proxy(GrContext* context, sk_sp<GrSurfaceProxy> src, SkString* dst) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 359 | sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(src)); |
Michael Ludwig | e8e1075 | 2018-10-01 12:42:53 -0400 | [diff] [blame] | 360 | return log_surface_context(sContext, dst); |
| 361 | } |
| 362 | |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 363 | bool fuzzy_color_equals(const SkPMColor4f& c1, const SkPMColor4f& c2) { |
| 364 | // With the loss of precision of rendering into 32-bit color, then estimating the FP's output |
| 365 | // from that, it is not uncommon for a valid output to differ from estimate by up to 0.01 |
| 366 | // (really 1/128 ~ .0078, but frequently floating point issues make that tolerance a little |
| 367 | // too unforgiving). |
| 368 | static constexpr SkScalar kTolerance = 0.01f; |
| 369 | for (int i = 0; i < 4; i++) { |
| 370 | if (!SkScalarNearlyEqual(c1[i], c2[i], kTolerance)) { |
| 371 | return false; |
| 372 | } |
| 373 | } |
| 374 | return true; |
| 375 | } |
| 376 | |
| 377 | int modulation_index(int channelIndex, bool alphaModulation) { |
| 378 | return alphaModulation ? 3 : channelIndex; |
| 379 | } |
| 380 | |
| 381 | // Given three input colors (color preceding the FP being tested), and the output of the FP, this |
| 382 | // ensures that the out1 = fp * in1.a, out2 = fp * in2.a, and out3 = fp * in3.a, where fp is the |
| 383 | // pre-modulated color that should not be changing across frames (FP's state doesn't change). |
| 384 | // |
| 385 | // When alphaModulation is false, this tests the very similar conditions that out1 = fp * in1, |
| 386 | // etc. using per-channel modulation instead of modulation by just the input alpha channel. |
| 387 | // - This estimates the pre-modulated fp color from one of the input/output pairs and confirms the |
| 388 | // conditions hold for the other two pairs. |
| 389 | bool legal_modulation(const GrColor& in1, const GrColor& in2, const GrColor& in3, |
| 390 | const GrColor& out1, const GrColor& out2, const GrColor& out3, |
| 391 | bool alphaModulation) { |
| 392 | // Convert to floating point, which is the number space the FP operates in (more or less) |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 393 | SkPMColor4f in1f = SkPMColor4f::FromBytes_RGBA(in1); |
| 394 | SkPMColor4f in2f = SkPMColor4f::FromBytes_RGBA(in2); |
| 395 | SkPMColor4f in3f = SkPMColor4f::FromBytes_RGBA(in3); |
| 396 | SkPMColor4f out1f = SkPMColor4f::FromBytes_RGBA(out1); |
| 397 | SkPMColor4f out2f = SkPMColor4f::FromBytes_RGBA(out2); |
| 398 | SkPMColor4f out3f = SkPMColor4f::FromBytes_RGBA(out3); |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 399 | |
| 400 | // Reconstruct the output of the FP before the shader modulated its color with the input value. |
| 401 | // When the original input is very small, it may cause the final output color to round |
| 402 | // to 0, in which case we estimate the pre-modulated color using one of the stepped frames that |
| 403 | // will then have a guaranteed larger channel value (since the offset will be added to it). |
| 404 | SkPMColor4f fpPreModulation; |
| 405 | for (int i = 0; i < 4; i++) { |
| 406 | int modulationIndex = modulation_index(i, alphaModulation); |
| 407 | if (in1f[modulationIndex] < 0.2f) { |
| 408 | // Use the stepped frame |
| 409 | fpPreModulation[i] = out2f[i] / in2f[modulationIndex]; |
| 410 | } else { |
| 411 | fpPreModulation[i] = out1f[i] / in1f[modulationIndex]; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | // With reconstructed pre-modulated FP output, derive the expected value of fp * input for each |
| 416 | // of the transformed input colors. |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 417 | SkPMColor4f expected1 = alphaModulation ? (fpPreModulation * in1f.fA) |
| 418 | : (fpPreModulation * in1f); |
| 419 | SkPMColor4f expected2 = alphaModulation ? (fpPreModulation * in2f.fA) |
| 420 | : (fpPreModulation * in2f); |
| 421 | SkPMColor4f expected3 = alphaModulation ? (fpPreModulation * in3f.fA) |
| 422 | : (fpPreModulation * in3f); |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 423 | |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 424 | return fuzzy_color_equals(out1f, expected1) && |
| 425 | fuzzy_color_equals(out2f, expected2) && |
| 426 | fuzzy_color_equals(out3f, expected3); |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 427 | } |
| 428 | |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 429 | DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, reporter, ctxInfo) { |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 430 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 431 | GrProxyProvider* proxyProvider = context->priv().proxyProvider(); |
| 432 | auto resourceProvider = context->priv().resourceProvider(); |
Brian Salomon | 1c05364 | 2017-07-24 10:16:19 -0400 | [diff] [blame] | 433 | using FPFactory = GrFragmentProcessorTestFactory; |
Brian Osman | c35a2d4 | 2017-03-17 10:58:53 -0400 | [diff] [blame] | 434 | |
Michael Ludwig | 3ad86d0 | 2018-09-28 16:00:38 -0400 | [diff] [blame] | 435 | uint32_t seed = FLAGS_processorSeed; |
Brian Osman | c35a2d4 | 2017-03-17 10:58:53 -0400 | [diff] [blame] | 436 | if (FLAGS_randomProcessorTest) { |
| 437 | std::random_device rd; |
| 438 | seed = rd(); |
| 439 | } |
| 440 | // If a non-deterministic bot fails this test, check the output to see what seed it used, then |
Michael Ludwig | 3ad86d0 | 2018-09-28 16:00:38 -0400 | [diff] [blame] | 441 | // use --processorSeed <seed> (without --randomProcessorTest) to reproduce. |
Brian Osman | c35a2d4 | 2017-03-17 10:58:53 -0400 | [diff] [blame] | 442 | SkRandom random(seed); |
| 443 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 444 | const GrBackendFormat format = |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 445 | context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 446 | |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 447 | // Make the destination context for the test. |
| 448 | static constexpr int kRenderSize = 256; |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 449 | sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 450 | format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, |
| 451 | nullptr); |
Brian Salomon | d1a8bdf | 2017-02-10 12:39:26 -0500 | [diff] [blame] | 452 | |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 453 | sk_sp<GrTextureProxy> proxies[2]; |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 454 | if (!init_test_textures(proxyProvider, &random, proxies)) { |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 455 | ERRORF(reporter, "Could not create test textures"); |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 456 | return; |
| 457 | } |
Robert Phillips | e78b725 | 2017-04-06 07:59:41 -0400 | [diff] [blame] | 458 | GrProcessorTestData testData(&random, context, rtc.get(), proxies); |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 459 | |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 460 | // Coverage optimization uses three frames with a linearly transformed input texture. The first |
| 461 | // frame has no offset, second frames add .2 and .4, which should then be present as a fixed |
| 462 | // difference between the frame outputs if the FP is properly following the modulation |
| 463 | // requirements of the coverage optimization. |
| 464 | static constexpr SkScalar kInputDelta = 0.2f; |
| 465 | auto inputTexture1 = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 0.0f); |
| 466 | auto inputTexture2 = make_input_texture(proxyProvider, kRenderSize, kRenderSize, kInputDelta); |
| 467 | auto inputTexture3 = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 2*kInputDelta); |
Robert Phillips | 30f9bc6 | 2017-02-22 15:28:38 -0500 | [diff] [blame] | 468 | |
Michael Ludwig | e8e1075 | 2018-10-01 12:42:53 -0400 | [diff] [blame] | 469 | // Encoded images are very verbose and this tests many potential images, so only export the |
| 470 | // first failure (subsequent failures have a reasonable chance of being related). |
| 471 | bool loggedFirstFailure = false; |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 472 | bool loggedFirstWarning = false; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 473 | |
| 474 | // Storage for the three frames required for coverage compatibility optimization. Each frame |
| 475 | // uses the correspondingly numbered inputTextureX. |
| 476 | std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]); |
| 477 | std::unique_ptr<GrColor[]> readData2(new GrColor[kRenderSize * kRenderSize]); |
| 478 | std::unique_ptr<GrColor[]> readData3(new GrColor[kRenderSize * kRenderSize]); |
| 479 | |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 480 | // Because processor factories configure themselves in random ways, this is not exhaustive. |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 481 | for (int i = 0; i < FPFactory::Count(); ++i) { |
| 482 | int timesToInvokeFactory = 5; |
| 483 | // Increase the number of attempts if the FP has child FPs since optimizations likely depend |
| 484 | // on child optimizations being present. |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 485 | std::unique_ptr<GrFragmentProcessor> fp = FPFactory::MakeIdx(i, &testData); |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 486 | for (int j = 0; j < fp->numChildProcessors(); ++j) { |
| 487 | // This value made a reasonable trade off between time and coverage when this test was |
| 488 | // written. |
| 489 | timesToInvokeFactory *= FPFactory::Count() / 2; |
| 490 | } |
Brian Osman | 50ea3c0 | 2019-02-04 10:01:53 -0500 | [diff] [blame] | 491 | #if defined(__MSVC_RUNTIME_CHECKS) |
| 492 | // This test is infuriatingly slow with MSVC runtime checks enabled |
| 493 | timesToInvokeFactory = 1; |
| 494 | #endif |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 495 | for (int j = 0; j < timesToInvokeFactory; ++j) { |
| 496 | fp = FPFactory::MakeIdx(i, &testData); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 497 | if (!fp->instantiate(resourceProvider)) { |
Robert Phillips | a91e0b7 | 2017-05-01 13:12:20 -0400 | [diff] [blame] | 498 | continue; |
| 499 | } |
| 500 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 501 | if (!fp->hasConstantOutputForConstantInput() && !fp->preservesOpaqueInput() && |
Brian Salomon | f3b995b | 2017-02-15 10:22:23 -0500 | [diff] [blame] | 502 | !fp->compatibleWithCoverageAsAlpha()) { |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 503 | continue; |
| 504 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 505 | |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 506 | if (fp->compatibleWithCoverageAsAlpha()) { |
| 507 | // 2nd and 3rd frames are only used when checking coverage optimization |
| 508 | render_fp(context, rtc.get(), fp.get(), inputTexture2, readData2.get()); |
| 509 | render_fp(context, rtc.get(), fp.get(), inputTexture3, readData3.get()); |
| 510 | } |
| 511 | // Draw base frame last so that rtc holds the original FP behavior if we need to |
| 512 | // dump the image to the log. |
| 513 | render_fp(context, rtc.get(), fp.get(), inputTexture1, readData1.get()); |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 514 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 515 | if (0) { // Useful to see what FPs are being tested. |
| 516 | SkString children; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 517 | for (int c = 0; c < fp->numChildProcessors(); ++c) { |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 518 | if (!c) { |
| 519 | children.append("("); |
| 520 | } |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 521 | children.append(fp->childProcessor(c).name()); |
| 522 | children.append(c == fp->numChildProcessors() - 1 ? ")" : ", "); |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 523 | } |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 524 | SkDebugf("%s %s\n", fp->name(), children.c_str()); |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 525 | } |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 526 | |
| 527 | // This test has a history of being flaky on a number of devices. If an FP is logically |
| 528 | // violating the optimizations, it's reasonable to expect it to violate requirements on |
| 529 | // a large number of pixels in the image. Sporadic pixel violations are more indicative |
| 530 | // of device errors and represents a separate problem. |
Michael Ludwig | 72ab346 | 2018-12-10 12:43:36 -0500 | [diff] [blame] | 531 | #if defined(SK_BUILD_FOR_SKQP) |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 532 | static constexpr int kMaxAcceptableFailedPixels = 0; // Strict when running as SKQP |
| 533 | #else |
| 534 | static constexpr int kMaxAcceptableFailedPixels = 2 * kRenderSize; // ~0.7% of the image |
| 535 | #endif |
| 536 | |
| 537 | int failedPixelCount = 0; |
| 538 | // Collect first optimization failure message, to be output later as a warning or an |
| 539 | // error depending on whether the rendering "passed" or failed. |
| 540 | SkString coverageMessage; |
| 541 | SkString opaqueMessage; |
| 542 | SkString constMessage; |
| 543 | for (int y = 0; y < kRenderSize; ++y) { |
| 544 | for (int x = 0; x < kRenderSize; ++x) { |
| 545 | bool passing = true; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 546 | GrColor input = input_texel_color(x, y, 0.0f); |
| 547 | GrColor output = readData1.get()[y * kRenderSize + x]; |
| 548 | |
| 549 | if (fp->compatibleWithCoverageAsAlpha()) { |
| 550 | GrColor i2 = input_texel_color(x, y, kInputDelta); |
| 551 | GrColor i3 = input_texel_color(x, y, 2 * kInputDelta); |
| 552 | |
| 553 | GrColor o2 = readData2.get()[y * kRenderSize + x]; |
| 554 | GrColor o3 = readData3.get()[y * kRenderSize + x]; |
| 555 | |
| 556 | // A compatible processor is allowed to modulate either the input color or |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 557 | // just the input alpha. |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 558 | bool legalAlphaModulation = legal_modulation(input, i2, i3, output, o2, o3, |
| 559 | /* alpha */ true); |
| 560 | bool legalColorModulation = legal_modulation(input, i2, i3, output, o2, o3, |
| 561 | /* alpha */ false); |
| 562 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 563 | if (!legalColorModulation && !legalAlphaModulation) { |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 564 | passing = false; |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 565 | |
| 566 | if (coverageMessage.isEmpty()) { |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 567 | coverageMessage.printf("\"Modulating\" processor %s did not match " |
| 568 | "alpha-modulation nor color-modulation rules. " |
| 569 | "Input: 0x%08x, Output: 0x%08x, pixel (%d, %d).", |
| 570 | fp->name(), input, output, x, y); |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 571 | } |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 572 | } |
| 573 | } |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 574 | |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 575 | SkPMColor4f input4f = SkPMColor4f::FromBytes_RGBA(input); |
| 576 | SkPMColor4f output4f = SkPMColor4f::FromBytes_RGBA(output); |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 577 | SkPMColor4f expected4f; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 578 | if (fp->hasConstantOutputForConstantInput(input4f, &expected4f)) { |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 579 | float rDiff = fabsf(output4f.fR - expected4f.fR); |
| 580 | float gDiff = fabsf(output4f.fG - expected4f.fG); |
| 581 | float bDiff = fabsf(output4f.fB - expected4f.fB); |
| 582 | float aDiff = fabsf(output4f.fA - expected4f.fA); |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 583 | static constexpr float kTol = 4 / 255.f; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 584 | if (rDiff > kTol || gDiff > kTol || bDiff > kTol || aDiff > kTol) { |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 585 | if (constMessage.isEmpty()) { |
| 586 | passing = false; |
| 587 | |
| 588 | constMessage.printf("Processor %s claimed output for const input " |
| 589 | "doesn't match actual output. Error: %f, Tolerance: %f, " |
| 590 | "input: (%f, %f, %f, %f), actual: (%f, %f, %f, %f), " |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 591 | "expected(%f, %f, %f, %f)", fp->name(), |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 592 | SkTMax(rDiff, SkTMax(gDiff, SkTMax(bDiff, aDiff))), kTol, |
| 593 | input4f.fR, input4f.fG, input4f.fB, input4f.fA, |
Brian Osman | cb3d087 | 2018-10-16 15:19:28 -0400 | [diff] [blame] | 594 | output4f.fR, output4f.fG, output4f.fB, output4f.fA, |
| 595 | expected4f.fR, expected4f.fG, expected4f.fB, expected4f.fA); |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 596 | } |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 597 | } |
| 598 | } |
Brian Osman | 00b2939 | 2018-11-05 15:42:43 -0500 | [diff] [blame] | 599 | if (input4f.isOpaque() && fp->preservesOpaqueInput() && !output4f.isOpaque()) { |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 600 | passing = false; |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 601 | |
| 602 | if (opaqueMessage.isEmpty()) { |
| 603 | opaqueMessage.printf("Processor %s claimed opaqueness is preserved but " |
| 604 | "it is not. Input: 0x%08x, Output: 0x%08x.", |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 605 | fp->name(), input, output); |
Michael Ludwig | e8e1075 | 2018-10-01 12:42:53 -0400 | [diff] [blame] | 606 | } |
Brian Osman | bd1f76f | 2017-03-15 11:33:12 -0400 | [diff] [blame] | 607 | } |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 608 | |
| 609 | if (!passing) { |
| 610 | // Regardless of how many optimizations the pixel violates, count it as a |
| 611 | // single bad pixel. |
| 612 | failedPixelCount++; |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | // Finished analyzing the entire image, see if the number of pixel failures meets the |
| 618 | // threshold for an FP violating the optimization requirements. |
| 619 | if (failedPixelCount > kMaxAcceptableFailedPixels) { |
Michael Ludwig | 4504a652 | 2018-10-03 16:47:55 -0400 | [diff] [blame] | 620 | ERRORF(reporter, "Processor violated %d of %d pixels, seed: 0x%08x, processor: %s" |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 621 | ", first failing pixel details are below:", |
| 622 | failedPixelCount, kRenderSize * kRenderSize, seed, |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 623 | fp->dumpInfo().c_str()); |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 624 | |
| 625 | // Print first failing pixel's details. |
| 626 | if (!coverageMessage.isEmpty()) { |
| 627 | ERRORF(reporter, coverageMessage.c_str()); |
| 628 | } |
| 629 | if (!constMessage.isEmpty()) { |
| 630 | ERRORF(reporter, constMessage.c_str()); |
| 631 | } |
| 632 | if (!opaqueMessage.isEmpty()) { |
| 633 | ERRORF(reporter, opaqueMessage.c_str()); |
| 634 | } |
| 635 | |
| 636 | if (!loggedFirstFailure) { |
| 637 | // Print with ERRORF to make sure the encoded image is output |
| 638 | SkString input; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 639 | log_surface_proxy(context, inputTexture1, &input); |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 640 | SkString output; |
| 641 | log_surface_context(rtc, &output); |
| 642 | ERRORF(reporter, "Input image: %s\n\n" |
| 643 | "===========================================================\n\n" |
| 644 | "Output image: %s\n", input.c_str(), output.c_str()); |
| 645 | loggedFirstFailure = true; |
| 646 | } |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 647 | } else if(failedPixelCount > 0) { |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 648 | // Don't trigger an error, but don't just hide the failures either. |
| 649 | INFOF(reporter, "Processor violated %d of %d pixels (below error threshold), seed: " |
| 650 | "0x%08x, processor: %s", failedPixelCount, kRenderSize * kRenderSize, |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 651 | seed, fp->dumpInfo().c_str()); |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 652 | if (!coverageMessage.isEmpty()) { |
| 653 | INFOF(reporter, coverageMessage.c_str()); |
| 654 | } |
| 655 | if (!constMessage.isEmpty()) { |
| 656 | INFOF(reporter, constMessage.c_str()); |
| 657 | } |
| 658 | if (!opaqueMessage.isEmpty()) { |
| 659 | INFOF(reporter, opaqueMessage.c_str()); |
| 660 | } |
| 661 | if (!loggedFirstWarning) { |
| 662 | SkString input; |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 663 | log_surface_proxy(context, inputTexture1, &input); |
Michael Ludwig | 314d377 | 2018-10-03 16:04:38 -0400 | [diff] [blame] | 664 | SkString output; |
| 665 | log_surface_context(rtc, &output); |
| 666 | INFOF(reporter, "Input image: %s\n\n" |
| 667 | "===========================================================\n\n" |
| 668 | "Output image: %s\n", input.c_str(), output.c_str()); |
| 669 | loggedFirstWarning = true; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 670 | } |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | } |
Robert Phillips | 18166ee | 2017-06-01 12:55:44 -0400 | [diff] [blame] | 675 | |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 676 | // Tests that fragment processors returned by GrFragmentProcessor::clone() are equivalent to their |
| 677 | // progenitors. |
| 678 | DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) { |
| 679 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 680 | GrProxyProvider* proxyProvider = context->priv().proxyProvider(); |
| 681 | auto resourceProvider = context->priv().resourceProvider(); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 682 | |
| 683 | SkRandom random; |
| 684 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 685 | const GrBackendFormat format = |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 686 | context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 687 | |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 688 | // Make the destination context for the test. |
| 689 | static constexpr int kRenderSize = 1024; |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 690 | sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext( |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 691 | format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, |
| 692 | nullptr); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 693 | |
| 694 | sk_sp<GrTextureProxy> proxies[2]; |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 695 | if (!init_test_textures(proxyProvider, &random, proxies)) { |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 696 | ERRORF(reporter, "Could not create test textures"); |
| 697 | return; |
| 698 | } |
| 699 | GrProcessorTestData testData(&random, context, rtc.get(), proxies); |
| 700 | |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 701 | auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 0.0f); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 702 | std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]); |
| 703 | std::unique_ptr<GrColor[]> readData2(new GrColor[kRenderSize * kRenderSize]); |
| 704 | auto readInfo = SkImageInfo::Make(kRenderSize, kRenderSize, kRGBA_8888_SkColorType, |
| 705 | kPremul_SkAlphaType); |
| 706 | |
| 707 | // Because processor factories configure themselves in random ways, this is not exhaustive. |
| 708 | for (int i = 0; i < GrFragmentProcessorTestFactory::Count(); ++i) { |
| 709 | static constexpr int kTimesToInvokeFactory = 10; |
| 710 | for (int j = 0; j < kTimesToInvokeFactory; ++j) { |
| 711 | auto fp = GrFragmentProcessorTestFactory::MakeIdx(i, &testData); |
| 712 | auto clone = fp->clone(); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 713 | if (!clone) { |
Brian Salomon | 96271cd | 2017-07-31 16:27:23 -0400 | [diff] [blame] | 714 | ERRORF(reporter, "Clone of processor %s failed.", fp->name()); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 715 | continue; |
| 716 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 717 | const char* name = fp->name(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 718 | if (!fp->instantiate(resourceProvider) || !clone->instantiate(resourceProvider)) { |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 719 | continue; |
| 720 | } |
Brian Salomon | ce06e26 | 2017-08-01 16:23:40 -0400 | [diff] [blame] | 721 | REPORTER_ASSERT(reporter, !strcmp(fp->name(), clone->name())); |
| 722 | REPORTER_ASSERT(reporter, fp->compatibleWithCoverageAsAlpha() == |
| 723 | clone->compatibleWithCoverageAsAlpha()); |
| 724 | REPORTER_ASSERT(reporter, fp->isEqual(*clone)); |
| 725 | REPORTER_ASSERT(reporter, fp->preservesOpaqueInput() == clone->preservesOpaqueInput()); |
| 726 | REPORTER_ASSERT(reporter, fp->hasConstantOutputForConstantInput() == |
| 727 | clone->hasConstantOutputForConstantInput()); |
| 728 | REPORTER_ASSERT(reporter, fp->numChildProcessors() == clone->numChildProcessors()); |
| 729 | REPORTER_ASSERT(reporter, fp->usesLocalCoords() == clone->usesLocalCoords()); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 730 | // Draw with original and read back the results. |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 731 | render_fp(context, rtc.get(), fp.get(), inputTexture, readData1.get()); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 732 | |
| 733 | // Draw with clone and read back the results. |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 734 | render_fp(context, rtc.get(), clone.get(), inputTexture, readData2.get()); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 735 | |
| 736 | // Check that the results are the same. |
| 737 | bool passing = true; |
| 738 | for (int y = 0; y < kRenderSize && passing; ++y) { |
| 739 | for (int x = 0; x < kRenderSize && passing; ++x) { |
| 740 | int idx = y * kRenderSize + x; |
| 741 | if (readData1[idx] != readData2[idx]) { |
| 742 | ERRORF(reporter, |
| 743 | "Processor %s made clone produced different output. " |
| 744 | "Input color: 0x%08x, Original Output Color: 0x%08x, " |
| 745 | "Clone Output Color: 0x%08x..", |
Michael Ludwig | 7034f15 | 2018-10-08 16:43:58 -0400 | [diff] [blame] | 746 | name, input_texel_color(x, y, 0.0f), readData1[idx], readData2[idx]); |
Brian Salomon | 0e05a82 | 2017-07-25 09:43:22 -0400 | [diff] [blame] | 747 | passing = false; |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | } |
| 754 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 755 | #endif // GR_TEST_UTILS |
| 756 | #endif // SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |