OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 // This is a GPU-backend specific test. It relies on static intializers to work | 9 // This is a GPU-backend specific test. It relies on static intializers to work |
10 | 10 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 if (s < numColorProcs) { | 255 if (s < numColorProcs) { |
256 pipelineBuilder->addColorFragmentProcessor(fp); | 256 pipelineBuilder->addColorFragmentProcessor(fp); |
257 } else { | 257 } else { |
258 pipelineBuilder->addCoverageFragmentProcessor(fp); | 258 pipelineBuilder->addCoverageFragmentProcessor(fp); |
259 } | 259 } |
260 ++s; | 260 ++s; |
261 } | 261 } |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 static void set_random_state(GrPipelineBuilder* pipelineBuilder, SkRandom* rando
m) { | 265 static void set_random_state(GrPipelineBuilder* pipelineBuilder, SkRandom* rando
m, |
266 int state = 0; | 266 const GrCaps& caps) { |
267 for (int i = 1; i <= GrPipelineBuilder::kLast_Flag; i <<= 1) { | 267 enum { kStateMask = GrPipelineBuilder::kLast_Flag | (GrPipelineBuilder::kLas
t_Flag - 1) }; |
268 state |= random->nextBool() * i; | 268 int state = random->nextU() & kStateMask; |
269 } | |
270 | |
271 // If we don't have an MSAA rendertarget then we have to disable useHWAA | 269 // If we don't have an MSAA rendertarget then we have to disable useHWAA |
272 if ((state | GrPipelineBuilder::kHWAntialias_Flag) && | 270 if ((state | GrPipelineBuilder::kHWAntialias_Flag) && |
273 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled()) { | 271 !pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled()) { |
274 state &= ~GrPipelineBuilder::kHWAntialias_Flag; | 272 state &= ~GrPipelineBuilder::kHWAntialias_Flag; |
275 } | 273 } |
| 274 // We can only use sample locations if they are supported and we have HWAA. |
| 275 if (!caps.sampleLocationsSupport() || !(state & GrPipelineBuilder::kHWAntial
ias_Flag)) { |
| 276 state &= ~GrPipelineBuilder::kSampleLocations_Flag; |
| 277 } |
276 pipelineBuilder->enableState(state); | 278 pipelineBuilder->enableState(state); |
277 } | 279 } |
278 | 280 |
279 // right now, the only thing we seem to care about in drawState's stencil is 'do
esWrite()' | 281 // right now, the only thing we seem to care about in drawState's stencil is 'do
esWrite()' |
280 static void set_random_stencil(GrPipelineBuilder* pipelineBuilder, SkRandom* ran
dom) { | 282 static void set_random_stencil(GrPipelineBuilder* pipelineBuilder, SkRandom* ran
dom) { |
281 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil, | 283 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil, |
282 kReplace_StencilOp, | 284 kReplace_StencilOp, |
283 kReplace_StencilOp, | 285 kReplace_StencilOp, |
284 kAlways_StencilFunc, | 286 kAlways_StencilFunc, |
285 0xffff, | 287 0xffff, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 GrPipelineBuilder pipelineBuilder; | 347 GrPipelineBuilder pipelineBuilder; |
346 pipelineBuilder.setRenderTarget(rt.get()); | 348 pipelineBuilder.setRenderTarget(rt.get()); |
347 pipelineBuilder.setClip(clip); | 349 pipelineBuilder.setClip(clip); |
348 | 350 |
349 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); | 351 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); |
350 SkASSERT(batch); | 352 SkASSERT(batch); |
351 | 353 |
352 GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyText
ures); | 354 GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyText
ures); |
353 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); | 355 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); |
354 set_random_xpf(&pipelineBuilder, &ptd); | 356 set_random_xpf(&pipelineBuilder, &ptd); |
355 set_random_state(&pipelineBuilder, &random); | 357 set_random_state(&pipelineBuilder, &random, *context->caps()); |
356 set_random_stencil(&pipelineBuilder, &random); | 358 set_random_stencil(&pipelineBuilder, &random); |
357 | 359 |
358 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); | 360 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); |
359 if (!drawContext) { | 361 if (!drawContext) { |
360 SkDebugf("Could not allocate drawContext"); | 362 SkDebugf("Could not allocate drawContext"); |
361 return false; | 363 return false; |
362 } | 364 } |
363 | 365 |
364 drawContext->internal_drawBatch(pipelineBuilder, batch); | 366 drawContext->internal_drawBatch(pipelineBuilder, batch); |
365 } | 367 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 GrContextOptions opts; | 459 GrContextOptions opts; |
458 opts.fSuppressPrints = true; | 460 opts.fSuppressPrints = true; |
459 GrContextFactory debugFactory(opts); | 461 GrContextFactory debugFactory(opts); |
460 skiatest::RunWithGPUTestContexts(test_glprograms_native, skiatest::kNative_G
PUTestContexts, | 462 skiatest::RunWithGPUTestContexts(test_glprograms_native, skiatest::kNative_G
PUTestContexts, |
461 reporter, &debugFactory); | 463 reporter, &debugFactory); |
462 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 464 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |
463 skiatest::kOther_GPUTestContexts, reporter,
&debugFactory); | 465 skiatest::kOther_GPUTestContexts, reporter,
&debugFactory); |
464 } | 466 } |
465 | 467 |
466 #endif | 468 #endif |
OLD | NEW |