diff options
-rw-r--r-- | include/gpu/GrTestUtils.h | 1 | ||||
-rw-r--r-- | src/gpu/GrAAConvexPathRenderer.cpp | 4 | ||||
-rwxr-xr-x | src/gpu/GrAADistanceFieldPathRenderer.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrAtlasTextContext.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrAtlasTextContext.h | 2 | ||||
-rw-r--r-- | src/gpu/GrBatchTest.cpp | 19 | ||||
-rwxr-xr-x | src/gpu/GrContext.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrDefaultPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrOvalRenderer.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrTessellatingPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrTestUtils.cpp | 35 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 17 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 3 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 119 |
15 files changed, 104 insertions, 122 deletions
diff --git a/include/gpu/GrTestUtils.h b/include/gpu/GrTestUtils.h index 83db0d88db..6fed7e1761 100644 --- a/include/gpu/GrTestUtils.h +++ b/include/gpu/GrTestUtils.h @@ -30,6 +30,7 @@ const SkMatrix& TestMatrixPreservesRightAngles(SkRandom*); const SkMatrix& TestMatrixRectStaysRect(SkRandom*); const SkMatrix& TestMatrixInvertible(SkRandom*); const SkRect& TestRect(SkRandom*); +const SkRect& TestSquare(SkRandom*); const SkRRect& TestRRectSimple(SkRandom*); const SkPath& TestPath(SkRandom*); const SkPath& TestPathConvex(SkRandom*); diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index c68410fc6a..2c4175eb03 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -1042,10 +1042,10 @@ bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target, #ifdef GR_TEST_UTILS -BATCH_TEST_DEFINE(AAConvexPath) { +BATCH_TEST_DEFINE(AAConvexPathBatch) { AAConvexPathBatch::Geometry geometry; geometry.fColor = GrRandomColor(random); - geometry.fViewMatrix = GrTest::TestMatrix(random); + geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); geometry.fPath = GrTest::TestPathConvex(random); return AAConvexPathBatch::Create(geometry); diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp index 3e054d144a..dce4f89737 100755 --- a/src/gpu/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp @@ -630,6 +630,7 @@ struct PathTestStruct { SkDELETE(pathData); } SkDELETE(fAtlas); + fPathCache.reset(); } static void HandleEviction(GrBatchAtlas::AtlasID id, void* pr) { @@ -654,7 +655,7 @@ struct PathTestStruct { PathDataList fPathList; }; -BATCH_TEST_DEFINE(AADistanceFieldPathRenderer) { +BATCH_TEST_DEFINE(AADistanceFieldPathBatch) { static PathTestStruct gTestStruct; if (context->uniqueID() != gTestStruct.fContextID) { diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index 81769db6ec..950d93b961 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -2217,7 +2217,7 @@ void GrAtlasTextContext::flush(GrDrawTarget* target, #ifdef GR_TEST_UTILS -BATCH_TEST_DEFINE(TextBlob) { +BATCH_TEST_DEFINE(TextBlobBatch) { static uint32_t gContextID = SK_InvalidGenID; static GrAtlasTextContext* gTextContext = NULL; static SkDeviceProperties gDeviceProperties(SkDeviceProperties::kLegacyLCD_InitType); @@ -2245,7 +2245,7 @@ BATCH_TEST_DEFINE(TextBlob) { // Setup dummy SkPaint / GrPaint GrColor color = GrRandomColor(random); - SkMatrix viewMatrix = GrTest::TestMatrix(random); + SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); SkPaint skPaint; skPaint.setDistanceFieldTextTEMP(random->nextBool()); skPaint.setColor(color); diff --git a/src/gpu/GrAtlasTextContext.h b/src/gpu/GrAtlasTextContext.h index 6590195042..41d6122951 100644 --- a/src/gpu/GrAtlasTextContext.h +++ b/src/gpu/GrAtlasTextContext.h @@ -385,7 +385,7 @@ private: friend class BitmapTextBatch; #ifdef GR_TEST_UTILS - BATCH_TEST_FRIEND(TextBlob); + BATCH_TEST_FRIEND(TextBlobBatch); #endif typedef GrTextContext INHERITED; diff --git a/src/gpu/GrBatchTest.cpp b/src/gpu/GrBatchTest.cpp index fa8333d3c2..d19fcaf1e1 100644 --- a/src/gpu/GrBatchTest.cpp +++ b/src/gpu/GrBatchTest.cpp @@ -11,23 +11,38 @@ #ifdef GR_TEST_UTILS +BATCH_TEST_EXTERN(AAConvexPathBatch); +BATCH_TEST_EXTERN(AADistanceFieldPathBatch); BATCH_TEST_EXTERN(AAFillRectBatch); +BATCH_TEST_EXTERN(AAHairlineBatch); BATCH_TEST_EXTERN(AAStrokeRectBatch); BATCH_TEST_EXTERN(DashBatch); +BATCH_TEST_EXTERN(DefaultPathBatch); BATCH_TEST_EXTERN(CircleBatch); BATCH_TEST_EXTERN(DIEllipseBatch); BATCH_TEST_EXTERN(EllipseBatch); BATCH_TEST_EXTERN(RRectBatch); +BATCH_TEST_EXTERN(StrokeRectBatch); +BATCH_TEST_EXTERN(TesselatingPathBatch); +BATCH_TEST_EXTERN(TextBlobBatch); +BATCH_TEST_EXTERN(VerticesBatch); static BatchTestFunc gTestBatches[] = { + BATCH_TEST_ENTRY(AAConvexPathBatch), + BATCH_TEST_ENTRY(AADistanceFieldPathBatch), BATCH_TEST_ENTRY(AAFillRectBatch), + BATCH_TEST_ENTRY(AAHairlineBatch), BATCH_TEST_ENTRY(AAStrokeRectBatch), BATCH_TEST_ENTRY(DashBatch), + BATCH_TEST_ENTRY(DefaultPathBatch), BATCH_TEST_ENTRY(CircleBatch), BATCH_TEST_ENTRY(DIEllipseBatch), BATCH_TEST_ENTRY(EllipseBatch), - BATCH_TEST_ENTRY(RRectBatch) - + BATCH_TEST_ENTRY(RRectBatch), + BATCH_TEST_ENTRY(StrokeRectBatch), + BATCH_TEST_ENTRY(TesselatingPathBatch), + BATCH_TEST_ENTRY(TextBlobBatch), + BATCH_TEST_ENTRY(VerticesBatch) }; GrBatch* GrRandomBatch(SkRandom* random, GrContext* context) { diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index bf62538434..266ed57e13 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1885,7 +1885,7 @@ void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { #ifdef GR_TEST_UTILS -BATCH_TEST_DEFINE(StrokeRect) { +BATCH_TEST_DEFINE(StrokeRectBatch) { StrokeRectBatch::Geometry geometry; geometry.fViewMatrix = GrTest::TestMatrix(random); geometry.fColor = GrRandomColor(random); @@ -1955,7 +1955,7 @@ static void randomize_params(size_t count, size_t maxVertex, SkScalar min, SkSca } } -BATCH_TEST_DEFINE(Vertices) { +BATCH_TEST_DEFINE(VerticesBatch) { GrPrimitiveType type = GrPrimitiveType(random->nextULessThan(kLast_GrPrimitiveType + 1)); uint32_t primitiveCount = random->nextRangeU(1, 100); diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp index 1cc50dc6c1..4d4331c3b5 100644 --- a/src/gpu/GrDefaultPathRenderer.cpp +++ b/src/gpu/GrDefaultPathRenderer.cpp @@ -749,7 +749,7 @@ void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, #ifdef GR_TEST_UTILS -BATCH_TEST_DEFINE(DefaultPathRenderer) { +BATCH_TEST_DEFINE(DefaultPathBatch) { GrColor color = GrRandomColor(random); SkMatrix viewMatrix = GrTest::TestMatrix(random); diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index b562167424..d1891fed31 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -2094,7 +2094,7 @@ BATCH_TEST_DEFINE(CircleBatch) { SkMatrix viewMatrix = GrTest::TestMatrix(random); GrColor color = GrRandomColor(random); bool useCoverageAA = random->nextBool(); - SkRect circle = GrTest::TestRect(random); + SkRect circle = GrTest::TestSquare(random); return create_circle_batch(color, viewMatrix, useCoverageAA, circle, GrTest::TestStrokeRec(random)); } @@ -2102,9 +2102,8 @@ BATCH_TEST_DEFINE(CircleBatch) { BATCH_TEST_DEFINE(EllipseBatch) { SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); GrColor color = GrRandomColor(random); - bool useCoverageAA = random->nextBool(); - SkRect ellipse = GrTest::TestRect(random); - return create_ellipse_batch(color, viewMatrix, useCoverageAA, ellipse, + SkRect ellipse = GrTest::TestSquare(random); + return create_ellipse_batch(color, viewMatrix, true, ellipse, GrTest::TestStrokeRec(random)); } @@ -2112,7 +2111,7 @@ BATCH_TEST_DEFINE(DIEllipseBatch) { SkMatrix viewMatrix = GrTest::TestMatrix(random); GrColor color = GrRandomColor(random); bool useCoverageAA = random->nextBool(); - SkRect ellipse = GrTest::TestRect(random); + SkRect ellipse = GrTest::TestSquare(random); return create_diellipse_batch(color, viewMatrix, useCoverageAA, ellipse, GrTest::TestStrokeRec(random)); } diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp index e2707a9df3..0fc2b9edbe 100644 --- a/src/gpu/GrTessellatingPathRenderer.cpp +++ b/src/gpu/GrTessellatingPathRenderer.cpp @@ -1520,7 +1520,7 @@ bool GrTessellatingPathRenderer::onDrawPath(GrDrawTarget* target, #ifdef GR_TEST_UTILS -BATCH_TEST_DEFINE(TesselatingPathRenderer) { +BATCH_TEST_DEFINE(TesselatingPathBatch) { GrColor color = GrRandomColor(random); SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); SkPath path = GrTest::TestPath(random); diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp index c91f0fc8a9..b690d7e3cd 100644 --- a/src/gpu/GrTestUtils.cpp +++ b/src/gpu/GrTestUtils.cpp @@ -106,26 +106,33 @@ const SkRect& TestRect(SkRandom* random) { gRects[2] = SkRect::MakeWH(256.0f, 1.0f); gRects[4] = SkRect::MakeLargest(); gRects[5] = SkRect::MakeLTRB(-65535.0f, -65535.0f, 65535.0f, 65535.0f); - gRects[6] = SkRect::MakeLTRB(10.0f, 10.0f, -10.0f, -10.0f); + gRects[6] = SkRect::MakeLTRB(-10.0f, -10.0f, 10.0f, 10.0f); + } + return gRects[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRects)))]; +} + +// Just some simple rects for code which expects its input very sanitized +const SkRect& TestSquare(SkRandom* random) { + static SkRect gRects[2]; + static bool gOnce; + if (!gOnce) { + gOnce = true; + gRects[0] = SkRect::MakeWH(128.f, 128.f); + gRects[1] = SkRect::MakeWH(256.0f, 256.0f); } return gRects[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRects)))]; } const SkRRect& TestRRectSimple(SkRandom* random) { - static SkRRect gRRect[4]; + static SkRRect gRRect[2]; static bool gOnce; if (!gOnce) { gOnce = true; - SkRect square = SkRect::MakeWH(10.f, 10.f); SkRect rectangle = SkRect::MakeWH(10.f, 20.f); - // rect - gRRect[0].setRect(square); - // oval - gRRect[1].setOval(rectangle); // true round rect with circular corners - gRRect[2].setRectXY(rectangle, 1.f, 1.f); + gRRect[0].setRectXY(rectangle, 1.f, 1.f); // true round rect with elliptical corners - gRRect[3].setRectXY(rectangle, 2.0f, 1.0f); + gRRect[1].setRectXY(rectangle, 2.0f, 1.0f); for (size_t i = 0; i < SK_ARRAY_COUNT(gRRect); i++) { SkASSERT(gRRect[i].isSimple()); @@ -181,25 +188,29 @@ const SkPath& TestPathConvex(SkRandom* random) { if (!gOnce) { gOnce = true; // narrow rect - gPath[0].moveTo(0.f, 0.f); + gPath[0].moveTo(-1.5f, -50.0f); gPath[0].lineTo(-1.5f, -50.0f); gPath[0].lineTo( 1.5f, -50.0f); gPath[0].lineTo( 1.5f, 50.0f); gPath[0].lineTo(-1.5f, 50.0f); // degenerate - gPath[1].moveTo(0.f, 0.f); + gPath[1].moveTo(-0.025f, -0.025f); gPath[1].lineTo(-0.025f, -0.025f); gPath[1].lineTo( 0.025f, -0.025f); gPath[1].lineTo( 0.025f, 0.025f); gPath[1].lineTo(-0.025f, 0.025f); // clipped triangle - gPath[2].moveTo(0.f, 0.f); + gPath[2].moveTo(-10.0f, -50.0f); gPath[2].lineTo(-10.0f, -50.0f); gPath[2].lineTo( 10.0f, -50.0f); gPath[2].lineTo( 50.0f, 31.0f); gPath[2].lineTo( 40.0f, 50.0f); gPath[2].lineTo(-40.0f, 50.0f); gPath[2].lineTo(-50.0f, 31.0f); + + for (size_t i = 0; i < SK_ARRAY_COUNT(gPath); i++) { + SkASSERT(SkPath::kConvex_Convexity == gPath[i].getConvexity()); + } } return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPath)))]; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 122331dde3..917a2ff1f5 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1419,7 +1419,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) { fCurrentProgram.reset(fProgramCache->getProgram(args)); if (NULL == fCurrentProgram.get()) { - SkDEBUGFAIL("Failed to create program!"); + GrContextDebugf(this->getContext(), "Failed to create program!\n"); return false; } diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 37ba3dc942..28e1fba20c 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -67,7 +67,9 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp GrGLSLExpr4 inputColor; GrGLSLExpr4 inputCoverage; - pb->emitAndInstallProcs(&inputColor, &inputCoverage); + if (!pb->emitAndInstallProcs(&inputColor, &inputCoverage)) { + return NULL; + } return pb->finalize(); } @@ -189,9 +191,12 @@ const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { return fGpu->ctxInfo(); } -void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage) { +bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage) { // First we loop over all of the installed processors and collect coord transforms. These will // be sent to the GrGLPrimitiveProcessor in its emitCode function + const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); + int totalTextures = primProc.numTextures(); + const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits(); SkSTArray<8, GrGLProcessor::TransformedCoordsArray> outCoords; for (int i = 0; i < this->pipeline().numFragmentStages(); i++) { const GrFragmentProcessor* processor = this->pipeline().getFragmentStage(i).processor(); @@ -199,9 +204,14 @@ void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr for (int t = 0; t < processor->numTransforms(); t++) { procCoords.push_back(&processor->coordTransform(t)); } + + totalTextures += processor->numTextures(); + if (totalTextures >= maxTextureUnits) { + GrContextDebugf(fGpu->getContext(), "Program would use too many texture units\n"); + return false; + } } - const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); this->emitAndInstallProc(primProc, inputColor, inputCoverage); fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs)); @@ -210,6 +220,7 @@ void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr this->emitAndInstallFragProcs(this->pipeline().numColorFragmentStages(), numProcs, inputCoverage); this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputColor, *inputCoverage); + return true; } void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index e7520eee10..5805cfc146 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -290,8 +290,7 @@ protected: // Generates a possibly mangled name for a stage variable and writes it to the fragment shader. // If GrGLSLExpr4 has a valid name then it will use that instead void nameExpression(GrGLSLExpr4*, const char* baseName); - void emitAndInstallProcs(GrGLSLExpr4* inputColor, - GrGLSLExpr4* inputCoverage); + bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage); void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut); void emitAndInstallProc(const GrPendingFragmentStage&, int index, diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 1d7beecc75..1061f3c589 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -13,6 +13,8 @@ #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS #include "GrAutoLocaleSetter.h" +#include "GrBatch.h" +#include "GrBatchTest.h" #include "GrContextFactory.h" #include "GrInvariantOutput.h" #include "GrPipeline.h" @@ -42,7 +44,11 @@ public: const char* outputColor, const char* inputColor, const TransformedCoordsArray&, - const TextureSamplerArray&) {} + const TextureSamplerArray&) { + // pass through + GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); + fsBuilder->codeAppendf("%s = %s;\n", outputColor, inputColor); + } static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) { for (uint32_t i = 0; i < kMaxKeySize; i++) { @@ -109,10 +115,13 @@ static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random texDesc.fConfig = kRGBA_8888_GrPixelConfig; texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; + texDesc.fSampleCnt = random->nextBool() == true ? 4 : 0; + GrUniqueKey key; static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); - GrUniqueKey::Builder builder(&key, kDomain, 1); + GrUniqueKey::Builder builder(&key, kDomain, 2); builder[0] = texDesc.fOrigin; + builder[1] = texDesc.fSampleCnt; builder.finish(); GrTexture* texture = context->textureProvider()->findAndRefTextureByUniqueKey(key); @@ -134,20 +143,9 @@ static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, pipelineBuilder->setXPFactory(xpf.get()); } -static const GrGeometryProcessor* get_random_gp(GrContext* context, - const GrDrawTargetCaps& caps, - SkRandom* random, - GrTexture* dummyTextures[]) { - return GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random, - context, - caps, - dummyTextures); -} - static void set_random_color_coverage_stages(GrGLGpu* gpu, GrPipelineBuilder* pipelineBuilder, int maxStages, - bool usePathRendering, SkRandom* random, GrTexture* dummyTextures[]) { int numProcs = random->nextULessThan(maxStages + 1); @@ -176,6 +174,12 @@ static void set_random_state(GrPipelineBuilder* pipelineBuilder, SkRandom* rando for (int i = 1; i <= GrPipelineBuilder::kLast_Flag; i <<= 1) { state |= random->nextBool() * i; } + + // If we don't have an MSAA rendertarget then we have to disable useHWAA + if ((state | GrPipelineBuilder::kHWAntialias_Flag) && + !pipelineBuilder->getRenderTarget()->isMultisampled()) { + state &= ~GrPipelineBuilder::kHWAntialias_Flag; + } pipelineBuilder->enableState(state); } @@ -228,20 +232,12 @@ bool GrDrawTarget::programUnitTest(int maxStages) { // dummy scissor state GrScissorState scissor; - // setup clip - SkRect screen = SkRect::MakeWH(SkIntToScalar(kRenderTargetWidth), - SkIntToScalar(kRenderTargetHeight)); - - SkClipStack stack; - stack.clipDevRect(screen, SkRegion::kReplace_Op, false); - - // wrap the SkClipStack in a GrClip + // wide open clip GrClip clip; - clip.setClipStack(&stack); SkRandom random; - static const int NUM_TESTS = 512; - for (int t = 0; t < NUM_TESTS;) { + static const int NUM_TESTS = 2048; + for (int t = 0; t < NUM_TESTS; t++) { // setup random render target(can fail) SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, &random)); if (!rt.get()) { @@ -253,23 +249,12 @@ bool GrDrawTarget::programUnitTest(int maxStages) { pipelineBuilder.setRenderTarget(rt.get()); pipelineBuilder.setClip(clip); - // if path rendering we have to setup a couple of things like the draw type - bool usePathRendering = gpu->glCaps().shaderCaps()->pathRenderingSupport() && - random.nextBool(); + SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, fContext)); + SkASSERT(batch); - // twiddle drawstate knobs randomly - bool hasGeometryProcessor = !usePathRendering; - SkAutoTUnref<const GrGeometryProcessor> gp; - SkAutoTUnref<const GrPathProcessor> pathProc; - if (hasGeometryProcessor) { - gp.reset(get_random_gp(fContext, gpu->glCaps(), &random, dummyTextures)); - } else { - pathProc.reset(GrPathProcessor::Create(GrColor_WHITE)); - } set_random_color_coverage_stages(gpu, &pipelineBuilder, - maxStages - hasGeometryProcessor, - usePathRendering, + maxStages, &random, dummyTextures); @@ -279,55 +264,11 @@ bool GrDrawTarget::programUnitTest(int maxStages) { set_random_state(&pipelineBuilder, &random); set_random_stencil(&pipelineBuilder, &random); - GrDeviceCoordTexture dstCopy; - - const GrPrimitiveProcessor* primProc; - if (hasGeometryProcessor) { - primProc = gp.get(); - } else { - primProc = pathProc.get(); - } - - const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(primProc); - const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(primProc); - - if (!this->setupDstReadIfNecessary(pipelineBuilder, colorPOI, coveragePOI, &dstCopy, - NULL)) { - SkDebugf("Couldn't setup dst read texture"); - return false; - } - - // create optimized draw state, setup readDst texture if required, and build a descriptor - // and program. ODS creation can fail, so we have to check - GrPipeline pipeline(pipelineBuilder, colorPOI, coveragePOI, - *gpu->caps(), scissor, &dstCopy); - if (pipeline.mustSkip()) { - continue; - } - - GrXferBarrierType barrierType; - if (pipeline.getXferProcessor()->willNeedXferBarrier(rt, *gpu->caps(), &barrierType)) { - gpu->xferBarrier(barrierType); - } - - GrBatchTracker bt; - primProc->initBatchTracker(&bt, pipeline.getInitBatchTracker()); - - GrProgramDesc desc; - gpu->buildProgramDesc(&desc, *primProc, pipeline, bt); - - GrGpu::DrawArgs args(primProc, &pipeline, &desc, &bt); - SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(args, gpu)); - - if (NULL == program.get()) { - SkDebugf("Failed to create program!"); - return false; - } - - // because occasionally optimized drawstate creation will fail for valid reasons, we only - // want to increment on success - ++t; + this->drawBatch(&pipelineBuilder, batch); } + + // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes) + this->flush(); return true; } @@ -340,8 +281,12 @@ DEF_GPUTEST(GLPrograms, reporter, factory) { GrAutoLocaleSetter als("sv_SE.UTF-8"); #endif + // We suppress prints to avoid spew + GrContext::Options opts; + opts.fSuppressPrints = true; + GrContextFactory debugFactory(opts); for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { - GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(type)); + GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(type)); if (context) { GrGLGpu* gpu = static_cast<GrGLGpu*>(context->getGpu()); |