blob: ed74ae8f6a65ae828a3c0727580ae1622d6b03db [file] [log] [blame]
bsalomon@google.coma8e686e2011-08-16 15:45:58 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
bsalomon@google.comd4726202012-08-03 14:34:46 +00009// This is a GPU-backend specific test. It relies on static intializers to work
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000010
bsalomon@google.com2a48c3a2012-08-03 14:54:45 +000011#include "SkTypes.h"
12
13#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
14
bsalomon6f7f2012015-03-16 14:00:52 -070015#include "GrAutoLocaleSetter.h"
bsalomon@google.com67b915d2013-02-04 16:13:32 +000016#include "GrContextFactory.h"
egdaniel605dd0f2014-11-12 08:35:25 -080017#include "GrInvariantOutput.h"
egdaniel8dd688b2015-01-22 10:16:09 -080018#include "GrPipeline.h"
joshualitt2c93efe2014-11-06 12:57:13 -080019#include "GrTest.h"
egdaniel95131432014-12-09 11:15:43 -080020#include "GrXferProcessor.h"
bsalomon@google.com2db3ded2013-05-22 14:34:04 +000021#include "SkChecksum.h"
tfarina@chromium.org223137f2012-11-21 22:38:36 +000022#include "SkRandom.h"
bsalomon@google.comc3841b92012-08-02 18:11:43 +000023#include "Test.h"
joshualitt2c93efe2014-11-06 12:57:13 -080024#include "effects/GrConfigConversionEffect.h"
egdaniel95131432014-12-09 11:15:43 -080025#include "effects/GrPorterDuffXferProcessor.h"
jvanverth39edf762014-12-22 11:44:19 -080026#include "gl/GrGLGpu.h"
joshualitt2c93efe2014-11-06 12:57:13 -080027#include "gl/GrGLPathRendering.h"
joshualitt2c93efe2014-11-06 12:57:13 -080028#include "gl/builders/GrGLProgramBuilder.h"
bsalomon@google.comc3841b92012-08-02 18:11:43 +000029
joshualitt65171342014-10-09 07:25:36 -070030/*
bsalomon98b33eb2014-10-15 11:05:26 -070031 * A dummy processor which just tries to insert a massive key and verify that it can retrieve the
joshualitt65171342014-10-09 07:25:36 -070032 * whole thing correctly
33 */
34static const uint32_t kMaxKeySize = 1024;
35
joshualitt65171342014-10-09 07:25:36 -070036class GLBigKeyProcessor : public GrGLFragmentProcessor {
37public:
joshualitteb2a6762014-12-04 11:35:33 -080038 GLBigKeyProcessor(const GrProcessor&) {}
joshualittd9097592014-10-07 08:37:36 -070039
joshualitt15988992014-10-09 15:04:05 -070040 virtual void emitCode(GrGLFPBuilder* builder,
joshualitt65171342014-10-09 07:25:36 -070041 const GrFragmentProcessor& fp,
joshualitt65171342014-10-09 07:25:36 -070042 const char* outputColor,
43 const char* inputColor,
44 const TransformedCoordsArray&,
joshualitt267ce482014-11-25 14:52:21 -080045 const TextureSamplerArray&) {}
joshualitt65171342014-10-09 07:25:36 -070046
47 static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) {
48 for (uint32_t i = 0; i < kMaxKeySize; i++) {
49 b->add32(i);
joshualittd9097592014-10-07 08:37:36 -070050 }
joshualittd9097592014-10-07 08:37:36 -070051 }
52
joshualitt65171342014-10-09 07:25:36 -070053private:
54 typedef GrGLFragmentProcessor INHERITED;
55};
56
joshualitteb2a6762014-12-04 11:35:33 -080057class BigKeyProcessor : public GrFragmentProcessor {
58public:
59 static GrFragmentProcessor* Create() {
60 GR_CREATE_STATIC_PROCESSOR(gBigKeyProcessor, BigKeyProcessor, ())
61 return SkRef(gBigKeyProcessor);
62 }
63
mtklein36352bf2015-03-25 18:17:31 -070064 const char* name() const override { return "Big Ole Key"; }
joshualitteb2a6762014-12-04 11:35:33 -080065
66 virtual void getGLProcessorKey(const GrGLCaps& caps,
mtklein36352bf2015-03-25 18:17:31 -070067 GrProcessorKeyBuilder* b) const override {
joshualitteb2a6762014-12-04 11:35:33 -080068 GLBigKeyProcessor::GenKey(*this, caps, b);
69 }
70
mtklein36352bf2015-03-25 18:17:31 -070071 GrGLFragmentProcessor* createGLInstance() const override {
joshualitteb2a6762014-12-04 11:35:33 -080072 return SkNEW_ARGS(GLBigKeyProcessor, (*this));
73 }
74
75private:
76 BigKeyProcessor() {
77 this->initClassID<BigKeyProcessor>();
78 }
mtklein36352bf2015-03-25 18:17:31 -070079 bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
80 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { }
joshualitteb2a6762014-12-04 11:35:33 -080081
82 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
83
84 typedef GrFragmentProcessor INHERITED;
85};
86
87GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
88
89GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*,
90 GrContext*,
91 const GrDrawTargetCaps&,
92 GrTexture*[]) {
93 return BigKeyProcessor::Create();
94}
95
joshualitt65171342014-10-09 07:25:36 -070096/*
97 * Begin test code
98 */
99static const int kRenderTargetHeight = 1;
100static const int kRenderTargetWidth = 1;
101
bsalomon24db3b12015-01-23 04:24:04 -0800102static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random) {
joshualitt65171342014-10-09 07:25:36 -0700103 // setup render target
104 GrTextureParams params;
bsalomonf2703d82014-10-28 14:33:06 -0700105 GrSurfaceDesc texDesc;
joshualitt65171342014-10-09 07:25:36 -0700106 texDesc.fWidth = kRenderTargetWidth;
107 texDesc.fHeight = kRenderTargetHeight;
bsalomonf2703d82014-10-28 14:33:06 -0700108 texDesc.fFlags = kRenderTarget_GrSurfaceFlag;
joshualitt65171342014-10-09 07:25:36 -0700109 texDesc.fConfig = kRGBA_8888_GrPixelConfig;
110 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin :
111 kBottomLeft_GrSurfaceOrigin;
bsalomon8718aaf2015-02-19 07:24:21 -0800112 GrUniqueKey key;
113 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
114 GrUniqueKey::Builder builder(&key, kDomain, 1);
bsalomon24db3b12015-01-23 04:24:04 -0800115 builder[0] = texDesc.fOrigin;
116 builder.finish();
joshualitt65171342014-10-09 07:25:36 -0700117
bsalomon37f9a262015-02-02 13:00:10 -0800118 GrTexture* texture = context->findAndRefCachedTexture(key);
bsalomond27726e2014-10-12 05:40:00 -0700119 if (!texture) {
bsalomond0423582015-02-06 08:49:24 -0800120 texture = context->createTexture(texDesc, true);
bsalomon37f9a262015-02-02 13:00:10 -0800121 if (texture) {
bsalomonf99e9612015-02-19 08:24:16 -0800122 context->addResourceToCache(key, texture);
joshualittd9097592014-10-07 08:37:36 -0700123 }
joshualittd9097592014-10-07 08:37:36 -0700124 }
bsalomon37f9a262015-02-02 13:00:10 -0800125 return texture ? texture->asRenderTarget() : NULL;
bsalomon@google.com91207482013-02-12 21:45:24 +0000126}
127
egdaniel8dd688b2015-01-22 10:16:09 -0800128static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps,
129 GrPipelineBuilder* pipelineBuilder, SkRandom* random,
130 GrTexture* dummyTextures[]) {
egdanielc2304142014-12-11 13:15:13 -0800131 SkAutoTUnref<const GrXPFactory> xpf(
132 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps, dummyTextures));
133 SkASSERT(xpf);
egdaniel8dd688b2015-01-22 10:16:09 -0800134 pipelineBuilder->setXPFactory(xpf.get());
egdanielc2304142014-12-11 13:15:13 -0800135}
136
joshualitt56995b52014-12-11 15:44:02 -0800137static const GrGeometryProcessor* get_random_gp(GrContext* context,
138 const GrDrawTargetCaps& caps,
139 SkRandom* random,
140 GrTexture* dummyTextures[]) {
141 return GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random,
142 context,
143 caps,
144 dummyTextures);
joshualitt65171342014-10-09 07:25:36 -0700145}
146
bsalomon861e1032014-12-16 07:33:49 -0800147static void set_random_color_coverage_stages(GrGLGpu* gpu,
egdaniel8dd688b2015-01-22 10:16:09 -0800148 GrPipelineBuilder* pipelineBuilder,
joshualitt65171342014-10-09 07:25:36 -0700149 int maxStages,
150 bool usePathRendering,
151 SkRandom* random,
152 GrTexture* dummyTextures[]) {
153 int numProcs = random->nextULessThan(maxStages + 1);
154 int numColorProcs = random->nextULessThan(numProcs + 1);
155
156 int currTextureCoordSet = 0;
157 for (int s = 0; s < numProcs;) {
bsalomonae59b772014-11-19 08:23:49 -0800158 SkAutoTUnref<const GrFragmentProcessor> fp(
joshualitt65171342014-10-09 07:25:36 -0700159 GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(random,
160 gpu->getContext(),
161 *gpu->caps(),
162 dummyTextures));
163 SkASSERT(fp);
164
joshualitt65171342014-10-09 07:25:36 -0700165 // If adding this effect would exceed the max texture coord set count then generate a
166 // new random effect.
167 if (usePathRendering && gpu->glPathRendering()->texturingMode() ==
168 GrGLPathRendering::FixedFunction_TexturingMode) {;
169 int numTransforms = fp->numTransforms();
170 if (currTextureCoordSet + numTransforms >
171 gpu->glCaps().maxFixedFunctionTextureCoords()) {
172 continue;
173 }
174 currTextureCoordSet += numTransforms;
175 }
176
177 // finally add the stage to the correct pipeline in the drawstate
joshualitt65171342014-10-09 07:25:36 -0700178 if (s < numColorProcs) {
egdaniel8dd688b2015-01-22 10:16:09 -0800179 pipelineBuilder->addColorProcessor(fp);
joshualitt65171342014-10-09 07:25:36 -0700180 } else {
egdaniel8dd688b2015-01-22 10:16:09 -0800181 pipelineBuilder->addCoverageProcessor(fp);
joshualitt65171342014-10-09 07:25:36 -0700182 }
183 ++s;
184 }
185}
186
egdaniel8dd688b2015-01-22 10:16:09 -0800187static void set_random_state(GrPipelineBuilder* pipelineBuilder, SkRandom* random) {
joshualitt65171342014-10-09 07:25:36 -0700188 int state = 0;
egdaniel8dd688b2015-01-22 10:16:09 -0800189 for (int i = 1; i <= GrPipelineBuilder::kLast_StateBit; i <<= 1) {
joshualitt65171342014-10-09 07:25:36 -0700190 state |= random->nextBool() * i;
191 }
egdaniel8dd688b2015-01-22 10:16:09 -0800192 pipelineBuilder->enableState(state);
joshualitt65171342014-10-09 07:25:36 -0700193}
194
joshualitt65171342014-10-09 07:25:36 -0700195// right now, the only thing we seem to care about in drawState's stencil is 'doesWrite()'
egdaniel8dd688b2015-01-22 10:16:09 -0800196static void set_random_stencil(GrPipelineBuilder* pipelineBuilder, SkRandom* random) {
joshualitt65171342014-10-09 07:25:36 -0700197 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil,
198 kReplace_StencilOp,
199 kReplace_StencilOp,
200 kAlways_StencilFunc,
201 0xffff,
202 0xffff,
203 0xffff);
204 GR_STATIC_CONST_SAME_STENCIL(kDoesNotWriteStencil,
205 kKeep_StencilOp,
206 kKeep_StencilOp,
207 kNever_StencilFunc,
208 0xffff,
209 0xffff,
210 0xffff);
211
212 if (random->nextBool()) {
egdaniel8dd688b2015-01-22 10:16:09 -0800213 pipelineBuilder->setStencil(kDoesWriteStencil);
joshualitt65171342014-10-09 07:25:36 -0700214 } else {
egdaniel8dd688b2015-01-22 10:16:09 -0800215 pipelineBuilder->setStencil(kDoesNotWriteStencil);
joshualitt65171342014-10-09 07:25:36 -0700216 }
217}
joshualitt249af152014-09-15 11:41:13 -0700218
joshualitt2c93efe2014-11-06 12:57:13 -0800219bool GrDrawTarget::programUnitTest(int maxStages) {
bsalomon861e1032014-12-16 07:33:49 -0800220 GrGLGpu* gpu = static_cast<GrGLGpu*>(fContext->getGpu());
joshualitt65171342014-10-09 07:25:36 -0700221 // setup dummy textures
bsalomonf2703d82014-10-28 14:33:06 -0700222 GrSurfaceDesc dummyDesc;
223 dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
bsalomon@google.comfec0bc32013-02-07 14:43:04 +0000224 dummyDesc.fConfig = kSkia8888_GrPixelConfig;
bsalomon@google.comd4726202012-08-03 14:34:46 +0000225 dummyDesc.fWidth = 34;
226 dummyDesc.fHeight = 18;
bsalomon5236cf42015-01-14 10:42:08 -0800227 SkAutoTUnref<GrTexture> dummyTexture1(gpu->createTexture(dummyDesc, false, NULL, 0));
bsalomonf2703d82014-10-28 14:33:06 -0700228 dummyDesc.fFlags = kNone_GrSurfaceFlags;
bsalomon@google.comd4726202012-08-03 14:34:46 +0000229 dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
230 dummyDesc.fWidth = 16;
231 dummyDesc.fHeight = 22;
bsalomon5236cf42015-01-14 10:42:08 -0800232 SkAutoTUnref<GrTexture> dummyTexture2(gpu->createTexture(dummyDesc, false, NULL, 0));
bsalomon@google.comd4726202012-08-03 14:34:46 +0000233
bsalomone904c092014-07-17 10:50:59 -0700234 if (!dummyTexture1 || ! dummyTexture2) {
joshualitt65171342014-10-09 07:25:36 -0700235 SkDebugf("Could not allocate dummy textures");
bsalomone904c092014-07-17 10:50:59 -0700236 return false;
237 }
238
joshualitt65171342014-10-09 07:25:36 -0700239 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
240
joshualitt54e0c122014-11-19 09:38:51 -0800241 // dummy scissor state
bsalomon3e791242014-12-17 13:43:13 -0800242 GrScissorState scissor;
joshualitt54e0c122014-11-19 09:38:51 -0800243
joshualitt65171342014-10-09 07:25:36 -0700244 // setup clip
joshualitt2c93efe2014-11-06 12:57:13 -0800245 SkRect screen = SkRect::MakeWH(SkIntToScalar(kRenderTargetWidth),
246 SkIntToScalar(kRenderTargetHeight));
joshualitt65171342014-10-09 07:25:36 -0700247
248 SkClipStack stack;
249 stack.clipDevRect(screen, SkRegion::kReplace_Op, false);
250
joshualitt570d2f82015-02-25 13:19:48 -0800251 // wrap the SkClipStack in a GrClip
joshualitt44701df2015-02-23 14:44:57 -0800252 GrClip clip;
253 clip.setClipStack(&stack);
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000254
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000255 SkRandom random;
joshualitt65171342014-10-09 07:25:36 -0700256 static const int NUM_TESTS = 512;
257 for (int t = 0; t < NUM_TESTS;) {
258 // setup random render target(can fail)
bsalomon24db3b12015-01-23 04:24:04 -0800259 SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, &random));
joshualitt2c93efe2014-11-06 12:57:13 -0800260 if (!rt.get()) {
joshualitt65171342014-10-09 07:25:36 -0700261 SkDebugf("Could not allocate render target");
262 return false;
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000263 }
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000264
egdaniel8dd688b2015-01-22 10:16:09 -0800265 GrPipelineBuilder pipelineBuilder;
266 pipelineBuilder.setRenderTarget(rt.get());
joshualitt44701df2015-02-23 14:44:57 -0800267 pipelineBuilder.setClip(clip);
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000268
joshualitt65171342014-10-09 07:25:36 -0700269 // if path rendering we have to setup a couple of things like the draw type
joshualitt2c93efe2014-11-06 12:57:13 -0800270 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.nextBool();
egdanielc0648242014-09-22 13:17:02 -0700271
joshualitt65171342014-10-09 07:25:36 -0700272 // twiddle drawstate knobs randomly
joshualitt5478d422014-11-14 16:00:38 -0800273 bool hasGeometryProcessor = !usePathRendering;
joshualitt43893e42014-12-13 06:46:13 -0800274 SkAutoTUnref<const GrGeometryProcessor> gp;
275 SkAutoTUnref<const GrPathProcessor> pathProc;
joshualittbd769d02014-09-04 08:56:46 -0700276 if (hasGeometryProcessor) {
joshualitt43893e42014-12-13 06:46:13 -0800277 gp.reset(get_random_gp(fContext, gpu->glCaps(), &random, dummyTextures));
joshualitt56995b52014-12-11 15:44:02 -0800278 } else {
joshualitt43893e42014-12-13 06:46:13 -0800279 pathProc.reset(GrPathProcessor::Create(GrColor_WHITE));
joshualittd9097592014-10-07 08:37:36 -0700280 }
joshualitt2c93efe2014-11-06 12:57:13 -0800281 set_random_color_coverage_stages(gpu,
egdaniel8dd688b2015-01-22 10:16:09 -0800282 &pipelineBuilder,
joshualitt2c93efe2014-11-06 12:57:13 -0800283 maxStages - hasGeometryProcessor,
284 usePathRendering,
285 &random,
286 dummyTextures);
egdanielc2304142014-12-11 13:15:13 -0800287
288 // creates a random xfer processor factory on the draw state
egdaniel8dd688b2015-01-22 10:16:09 -0800289 set_random_xpf(fContext, gpu->glCaps(), &pipelineBuilder, &random, dummyTextures);
egdanielc2304142014-12-11 13:15:13 -0800290
egdaniel8dd688b2015-01-22 10:16:09 -0800291 set_random_state(&pipelineBuilder, &random);
292 set_random_stencil(&pipelineBuilder, &random);
joshualittd9097592014-10-07 08:37:36 -0700293
joshualitt65171342014-10-09 07:25:36 -0700294 GrDeviceCoordTexture dstCopy;
295
joshualitt56995b52014-12-11 15:44:02 -0800296 const GrPrimitiveProcessor* primProc;
297 if (hasGeometryProcessor) {
joshualitt43893e42014-12-13 06:46:13 -0800298 primProc = gp.get();
joshualitt56995b52014-12-11 15:44:02 -0800299 } else {
joshualitt43893e42014-12-13 06:46:13 -0800300 primProc = pathProc.get();
joshualitt56995b52014-12-11 15:44:02 -0800301 }
egdaniele36914c2015-02-13 09:00:33 -0800302
303 const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(primProc);
304 const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(primProc);
305
306 if (!this->setupDstReadIfNecessary(pipelineBuilder, colorPOI, coveragePOI, &dstCopy,
307 NULL)) {
joshualitt65171342014-10-09 07:25:36 -0700308 SkDebugf("Couldn't setup dst read texture");
bsalomon848faf02014-07-11 10:01:02 -0700309 return false;
310 }
joshualitt79f8fae2014-10-28 17:59:26 -0700311
312 // create optimized draw state, setup readDst texture if required, and build a descriptor
313 // and program. ODS creation can fail, so we have to check
egdaniele36914c2015-02-13 09:00:33 -0800314 GrPipeline pipeline(pipelineBuilder, colorPOI, coveragePOI,
315 *gpu->caps(), scissor, &dstCopy);
egdaniel8dd688b2015-01-22 10:16:09 -0800316 if (pipeline.mustSkip()) {
joshualitt79f8fae2014-10-28 17:59:26 -0700317 continue;
joshualittd9097592014-10-07 08:37:36 -0700318 }
joshualitt873ad0e2015-01-20 09:08:51 -0800319 GrBatchTracker bt;
egdaniel8dd688b2015-01-22 10:16:09 -0800320 primProc->initBatchTracker(&bt, pipeline.getInitBatchTracker());
joshualitt873ad0e2015-01-20 09:08:51 -0800321
322 GrProgramDesc desc;
bsalomon50785a32015-02-06 07:02:37 -0800323 gpu->buildProgramDesc(&desc, *primProc, pipeline, bt);
joshualitt873ad0e2015-01-20 09:08:51 -0800324
egdaniel8dd688b2015-01-22 10:16:09 -0800325 GrGpu::DrawArgs args(primProc, &pipeline, &desc, &bt);
joshualitt873ad0e2015-01-20 09:08:51 -0800326 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu));
327
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000328 if (NULL == program.get()) {
joshualitt65171342014-10-09 07:25:36 -0700329 SkDebugf("Failed to create program!");
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000330 return false;
331 }
joshualitt249af152014-09-15 11:41:13 -0700332
joshualitt65171342014-10-09 07:25:36 -0700333 // because occasionally optimized drawstate creation will fail for valid reasons, we only
334 // want to increment on success
335 ++t;
bsalomon@google.comc3841b92012-08-02 18:11:43 +0000336 }
337 return true;
338}
bsalomon@google.coma8e686e2011-08-16 15:45:58 +0000339
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +0000340DEF_GPUTEST(GLPrograms, reporter, factory) {
bsalomon3318ee72015-03-16 11:56:29 -0700341 // Set a locale that would cause shader compilation to fail because of , as decimal separator.
342 // skbug 3330
343#ifdef SK_BUILD_FOR_WIN
344 GrAutoLocaleSetter als("sv-SE");
345#else
346 GrAutoLocaleSetter als("sv_SE.UTF-8");
347#endif
348
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000349 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
350 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(type));
bsalomon49f085d2014-09-05 13:34:00 -0700351 if (context) {
bsalomon861e1032014-12-16 07:33:49 -0800352 GrGLGpu* gpu = static_cast<GrGLGpu*>(context->getGpu());
joshualitt9e87fa72014-10-09 13:12:35 -0700353
354 /*
355 * For the time being, we only support the test with desktop GL or for android on
356 * ARM platforms
357 * TODO When we run ES 3.00 GLSL in more places, test again
358 */
359 int maxStages;
360 if (kGL_GrGLStandard == gpu->glStandard() ||
361 kARM_GrGLVendor == gpu->ctxInfo().vendor()) {
362 maxStages = 6;
363 } else if (kTegra3_GrGLRenderer == gpu->ctxInfo().renderer() ||
364 kOther_GrGLRenderer == gpu->ctxInfo().renderer()) {
365 maxStages = 1;
366 } else {
367 return;
368 }
bsalomon@google.com042a2862013-02-04 18:39:24 +0000369#if SK_ANGLE
370 // Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
371 if (type == GrContextFactory::kANGLE_GLContextType) {
egdaniel305a8892015-02-17 11:18:38 -0800372 maxStages = 2;
bsalomon@google.com042a2862013-02-04 18:39:24 +0000373 }
374#endif
joshualitt2c93efe2014-11-06 12:57:13 -0800375 GrTestTarget target;
376 context->getTestTarget(&target);
377 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages));
bsalomon@google.com67b915d2013-02-04 16:13:32 +0000378 }
379 }
bsalomon@google.coma8e686e2011-08-16 15:45:58 +0000380}
381
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000382#endif