In this CL we stop closing batches prematurely, and only close immediately before a flush.

BUG=skia:

Review URL: https://codereview.chromium.org/1092403002
This commit is contained in:
joshualitt 2015-04-27 10:43:19 -07:00 committed by Commit bot
parent 505306374d
commit db3ce12c81
3 changed files with 51 additions and 16 deletions

View File

@ -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);
}

View File

@ -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<DrawBatch*>(genIter.get());
fBatchTarget.resetNumberOfDraws();
db->execute(NULL, currentState);
db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws());
} else if (Cmd::kSetState_CmdType == genIter->type()) {
SetState* ss = reinterpret_cast<SetState*>(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,12 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
}
if (Cmd::kSetState_CmdType == iter->type()) {
#ifndef USE_BITMAP_TEXTBLOBS
SetState* ss = reinterpret_cast<SetState*>(iter.get());
ss->execute(gpu, currentState);
currentState = ss;
#endif
} else {
iter->execute(gpu, currentState);
}
@ -408,7 +432,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 +485,7 @@ bool GrTargetCommands::setupPipelineAndShouldDraw(GrInOrderDrawBuffer* iodb,
fPrevState->getPipeline()->isEqual(*ss->getPipeline())) {
fCmdBuffer.pop_back();
} else {
this->closeBatch();
CLOSE_BATCH
fPrevState = ss;
iodb->recordTraceMarkersIfNecessary(ss);
}

View File

@ -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;