Revert of Move state management to GrInOrderDrawBuffer (patchset #4 id:60001 of https://codereview.chromium.org/1120143002/)
Reason for revert:
Breaks windows
Original issue's description:
> Move state management to GrInOrderDrawBuffer
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/5d6bb6f795143ca360b868560b52165de51fa269
TBR=bsalomon@google.com,robertphillips@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1119353002
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 76e085d..e298be6 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -17,7 +17,6 @@
, fCommands(context->getGpu(), vertexPool, indexPool)
, fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
, fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
- , fPipelineBuffer(kPipelineBufferMinReserve)
, fDrawID(0) {
SkASSERT(vertexPool);
@@ -301,12 +300,7 @@
void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,
const PipelineInfo& pipelineInfo) {
- State* state = this->setupPipelineAndShouldDraw(batch, pipelineInfo);
- if (!state) {
- return;
- }
-
- GrTargetCommands::Cmd* cmd = fCommands.recordDrawBatch(state, batch);
+ GrTargetCommands::Cmd* cmd = fCommands.recordDrawBatch(this, batch, pipelineInfo);
this->recordTraceMarkersIfNecessary(cmd);
}
@@ -315,7 +309,7 @@
const GrPath* path,
const GrScissorState& scissorState,
const GrStencilSettings& stencilSettings) {
- GrTargetCommands::Cmd* cmd = fCommands.recordStencilPath(pipelineBuilder,
+ GrTargetCommands::Cmd* cmd = fCommands.recordStencilPath(this, pipelineBuilder,
pathProc, path, scissorState,
stencilSettings);
this->recordTraceMarkersIfNecessary(cmd);
@@ -325,11 +319,9 @@
const GrPath* path,
const GrStencilSettings& stencilSettings,
const PipelineInfo& pipelineInfo) {
- State* state = this->setupPipelineAndShouldDraw(pathProc, pipelineInfo);
- if (!state) {
- return;
- }
- GrTargetCommands::Cmd* cmd = fCommands.recordDrawPath(state, pathProc, path, stencilSettings);
+ GrTargetCommands::Cmd* cmd = fCommands.recordDrawPath(this, pathProc,
+ path, stencilSettings,
+ pipelineInfo);
this->recordTraceMarkersIfNecessary(cmd);
}
@@ -342,11 +334,7 @@
int count,
const GrStencilSettings& stencilSettings,
const PipelineInfo& pipelineInfo) {
- State* state = this->setupPipelineAndShouldDraw(pathProc, pipelineInfo);
- if (!state) {
- return;
- }
- GrTargetCommands::Cmd* cmd = fCommands.recordDrawPaths(state, this, pathProc, pathRange,
+ GrTargetCommands::Cmd* cmd = fCommands.recordDrawPaths(this, pathProc, pathRange,
indices, indexType, transformValues,
transformType, count,
stencilSettings, pipelineInfo);
@@ -355,14 +343,16 @@
void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color,
bool canIgnoreRect, GrRenderTarget* renderTarget) {
- GrTargetCommands::Cmd* cmd = fCommands.recordClear(rect, color, canIgnoreRect, renderTarget);
+ GrTargetCommands::Cmd* cmd = fCommands.recordClear(this, rect, color,
+ canIgnoreRect, renderTarget);
this->recordTraceMarkersIfNecessary(cmd);
}
void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget) {
- GrTargetCommands::Cmd* cmd = fCommands.recordClearStencilClip(rect, insideClip, renderTarget);
+ GrTargetCommands::Cmd* cmd = fCommands.recordClearStencilClip(this, rect,
+ insideClip, renderTarget);
this->recordTraceMarkersIfNecessary(cmd);
}
@@ -371,7 +361,7 @@
return;
}
- GrTargetCommands::Cmd* cmd = fCommands.recordDiscard(renderTarget);
+ GrTargetCommands::Cmd* cmd = fCommands.recordDiscard(this, renderTarget);
this->recordTraceMarkersIfNecessary(cmd);
}
@@ -380,15 +370,6 @@
fPathIndexBuffer.rewind();
fPathTransformBuffer.rewind();
fGpuCmdMarkers.reset();
-
- fPrevState.reset(NULL);
- // Note, fPrevState points into fPipelineBuffer's allocation, so we have to reset first.
- // Furthermore, we have to reset fCommands before fPipelineBuffer too.
- if (fDrawID % kPipelineBufferHighWaterMark) {
- fPipelineBuffer.rewind();
- } else {
- fPipelineBuffer.reset();
- }
}
void GrInOrderDrawBuffer::onFlush() {
@@ -419,55 +400,3 @@
}
}
}
-
-GrTargetCommands::State*
-GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* primProc,
- const GrDrawTarget::PipelineInfo& pipelineInfo) {
- State* state = this->allocState();
- this->setupPipeline(pipelineInfo, state->pipelineLocation());
-
- if (state->getPipeline()->mustSkip()) {
- this->unallocState(state);
- return NULL;
- }
-
- state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker,
- state->getPipeline()->getInitBatchTracker());
-
- if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
- fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
- *state->fPrimitiveProcessor,
- state->fBatchTracker) &&
- fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
- this->unallocState(state);
- } else {
- fPrevState.reset(state);
- }
-
- fCommands.recordXferBarrierIfNecessary(*fPrevState->getPipeline(), this);
- return fPrevState;
-}
-
-GrTargetCommands::State*
-GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch,
- const GrDrawTarget::PipelineInfo& pipelineInfo) {
- State* state = this->allocState();
- this->setupPipeline(pipelineInfo, state->pipelineLocation());
-
- if (state->getPipeline()->mustSkip()) {
- this->unallocState(state);
- return NULL;
- }
-
- batch->initBatchTracker(state->getPipeline()->getInitBatchTracker());
-
- if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
- fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
- this->unallocState(state);
- } else {
- fPrevState.reset(state);
- }
-
- fCommands.recordXferBarrierIfNecessary(*fPrevState->getPipeline(), this);
- return fPrevState;
-}