From: joshualitt Date: Mon, 27 Apr 2015 19:03:05 +0000 (-0700) Subject: In this CL we stop closing batches prematurely, and only close immediately before... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~2631 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0dcb8e32dda93b098d19892a62a528dc6ae1017b;p=platform%2Fupstream%2FlibSkiaSharp.git In this CL we stop closing batches prematurely, and only close immediately before a flush. BUG=skia: Committed: https://skia.googlesource.com/skia/+/db3ce12c810ead7b76faa784e7293197aca0d9f1 Committed: https://skia.googlesource.com/skia/+/9e830ead85e544924344b01436c44cfb09fcf177 Review URL: https://codereview.chromium.org/1092403002 --- diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 8289f00..aaf3fd3 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -411,7 +411,9 @@ void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(GrTargetCommands::Cmd* c void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, size_t vertexStride, int indexCount) { +#ifndef USE_BITMAP_TEXTBLOBS fCommands.closeBatch(); +#endif this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, indexCount); } diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp index 9b968dc..d3c924d 100644 --- a/src/gpu/GrTargetCommands.cpp +++ b/src/gpu/GrTargetCommands.cpp @@ -82,8 +82,11 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDraw( const GrGeometryProcessor* gp, const GrDrawTarget::DrawInfo& info, const GrDrawTarget::PipelineInfo& pipelineInfo) { +#ifdef USE_BITMAP_TEXTBLOBS + SkFAIL("Non-batch no longer supported\n"); +#endif SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); - this->closeBatch(); + CLOSE_BATCH if (!this->setupPipelineAndShouldDraw(iodb, gp, pipelineInfo)) { return NULL; @@ -121,7 +124,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDrawBatch( SkASSERT(&fCmdBuffer.back() == fDrawBatch); if (!fDrawBatch->fBatch->combineIfPossible(batch)) { - this->closeBatch(); + CLOSE_BATCH fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fBatchTarget)); } @@ -135,7 +138,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordStencilPath( const GrPath* path, const GrScissorState& scissorState, const GrStencilSettings& stencilSettings) { - this->closeBatch(); + CLOSE_BATCH StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path, pipelineBuilder.getRenderTarget())); @@ -153,7 +156,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDrawPath( const GrPath* path, const GrStencilSettings& stencilSettings, const GrDrawTarget::PipelineInfo& pipelineInfo) { - this->closeBatch(); + CLOSE_BATCH // TODO: Only compare the subset of GrPipelineBuilder relevant to path covering? if (!this->setupPipelineAndShouldDraw(iodb, pathProc, pipelineInfo)) { @@ -178,7 +181,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDrawPaths( SkASSERT(pathRange); SkASSERT(indexValues); SkASSERT(transformValues); - this->closeBatch(); + CLOSE_BATCH if (!this->setupPipelineAndShouldDraw(iodb, pathProc, pipelineInfo)) { return NULL; @@ -234,7 +237,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordClear(GrInOrderDrawBuffer* iodb, bool canIgnoreRect, GrRenderTarget* renderTarget) { SkASSERT(renderTarget); - this->closeBatch(); + CLOSE_BATCH SkIRect r; if (NULL == rect) { @@ -257,7 +260,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordClearStencilClip(GrInOrderDrawBuf bool insideClip, GrRenderTarget* renderTarget) { SkASSERT(renderTarget); - this->closeBatch(); + CLOSE_BATCH ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilClip, (renderTarget)); clr->fRect = rect; @@ -268,7 +271,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordClearStencilClip(GrInOrderDrawBuf GrTargetCommands::Cmd* GrTargetCommands::recordDiscard(GrInOrderDrawBuffer* iodb, GrRenderTarget* renderTarget) { SkASSERT(renderTarget); - this->closeBatch(); + CLOSE_BATCH Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); clr->fColor = GrColor_ILLEGAL; @@ -287,19 +290,38 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { } // TODO this is temporary while batch is being rolled out - this->closeBatch(); - iodb->getVertexAllocPool()->unmap(); - iodb->getIndexAllocPool()->unmap(); - fBatchTarget.preFlush(); + CLOSE_BATCH // Updated every time we find a set state cmd to reflect the current state in the playback // stream. SetState* currentState = NULL; - CmdBuffer::Iter iter(fCmdBuffer); - GrGpu* gpu = iodb->getGpu(); +#ifdef USE_BITMAP_TEXTBLOBS + // Loop over all batches and generate geometry + CmdBuffer::Iter genIter(fCmdBuffer); + while (genIter.next()) { + if (Cmd::kDrawBatch_CmdType == genIter->type()) { + DrawBatch* db = reinterpret_cast(genIter.get()); + fBatchTarget.resetNumberOfDraws(); + db->execute(NULL, currentState); + db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); + } else if (Cmd::kSetState_CmdType == genIter->type()) { + SetState* ss = reinterpret_cast(genIter.get()); + + ss->execute(gpu, currentState); + currentState = ss; + } + } +#endif + + iodb->getVertexAllocPool()->unmap(); + iodb->getIndexAllocPool()->unmap(); + fBatchTarget.preFlush(); + + CmdBuffer::Iter iter(fCmdBuffer); + while (iter.next()) { GrGpuTraceMarker newMarker("", -1); SkString traceString; @@ -321,10 +343,21 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { } if (Cmd::kSetState_CmdType == iter->type()) { +#ifndef USE_BITMAP_TEXTBLOBS SetState* ss = reinterpret_cast(iter.get()); ss->execute(gpu, currentState); currentState = ss; +#else + // TODO this is just until NVPR is in batch + SetState* ss = reinterpret_cast(iter.get()); + + if (ss->fPrimitiveProcessor) { + ss->execute(gpu, currentState); + } + currentState = ss; +#endif + } else { iter->execute(gpu, currentState); } @@ -408,7 +441,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordCopySurface(GrInOrderDrawBuffer* const SkIRect& srcRect, const SkIPoint& dstPoint) { if (iodb->getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { - this->closeBatch(); + CLOSE_BATCH CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst, src)); cs->fSrcRect = srcRect; cs->fDstPoint = dstPoint; @@ -461,7 +494,7 @@ bool GrTargetCommands::setupPipelineAndShouldDraw(GrInOrderDrawBuffer* iodb, fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { fCmdBuffer.pop_back(); } else { - this->closeBatch(); + CLOSE_BATCH fPrevState = ss; iodb->recordTraceMarkersIfNecessary(ss); } diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h index 4b3dd57..696fcec 100644 --- a/src/gpu/GrTargetCommands.h +++ b/src/gpu/GrTargetCommands.h @@ -19,6 +19,15 @@ #include "SkRect.h" #include "SkTypes.h" +// This is just to get a flag +// TODO remove this when batch is everywhere +#include "GrTextContext.h" +#ifdef USE_BITMAP_TEXTBLOBS +#define CLOSE_BATCH +#else +#define CLOSE_BATCH this->closeBatch(); +#endif + class GrInOrderDrawBuffer; class GrVertexBufferAllocPool; class GrIndexBufferAllocPool;