diff options
author | robertphillips <robertphillips@google.com> | 2015-03-05 09:17:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-05 09:17:18 -0800 |
commit | bca3c9fb2d5c043985b878633e9630cf12e04bd6 (patch) | |
tree | bfeae08002e85b3f2b6fc53ab8181ab9d6aa2aec /src/gpu | |
parent | 7bdc8dfaabdee59d1961a390418ae6aafe0f9e62 (diff) |
Update gpu trace marker system for MultiDrawBuffer world
The main thrust of this CL is to remove the currCmdMarker variable from GrTargetCommands::flush. In a MultiDrawBuffer world the Cmds need not be execute in the order of their issuance.
Review URL: https://codereview.chromium.org/978363002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrTargetCommands.cpp | 42 | ||||
-rw-r--r-- | src/gpu/GrTargetCommands.h | 59 |
3 files changed, 52 insertions, 53 deletions
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 24db2e08dd..2584635802 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -395,9 +395,9 @@ void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(GrTargetCommands::Cmd* c const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); if (activeTraceMarkers.count() > 0) { if (cmd->isTraced()) { - fGpuCmdMarkers.back().addSet(activeTraceMarkers); + fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers); } else { - cmd->makeTraced(); + cmd->setMarkerID(fGpuCmdMarkers.count()); fGpuCmdMarkers.push_back(activeTraceMarkers); } } diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp index 30920f884d..9b968dc9e7 100644 --- a/src/gpu/GrTargetCommands.cpp +++ b/src/gpu/GrTargetCommands.cpp @@ -47,7 +47,7 @@ int GrTargetCommands::concatInstancedDraw(GrInOrderDrawBuffer* iodb, // Check if there is a draw info that is compatible that uses the same VB from the pool and // the same IB - if (Cmd::kDraw_Cmd != fCmdBuffer.back().type()) { + if (Cmd::kDraw_CmdType != fCmdBuffer.back().type()) { return 0; } @@ -114,7 +114,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDrawBatch( } // Check if there is a Batch Draw we can batch with - if (Cmd::kDrawBatch_Cmd != fCmdBuffer.back().type() || !fDrawBatch) { + if (Cmd::kDrawBatch_CmdType != fCmdBuffer.back().type() || !fDrawBatch) { fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fBatchTarget)); return fDrawBatch; } @@ -191,7 +191,7 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDrawPaths( transformValues, transformType, count, &savedIndices, &savedTransforms); - if (Cmd::kDrawPaths_Cmd == fCmdBuffer.back().type()) { + if (Cmd::kDrawPaths_CmdType == fCmdBuffer.back().type()) { // The previous command was also DrawPaths. Try to collapse this call into the one // before. Note that stenciling all the paths at once, then covering, may not be // equivalent to two separate draw calls if there is overlap. Blending won't work, @@ -286,37 +286,31 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { return; } - // Updated every time we find a set state cmd to reflect the current state in the playback - // stream. - SetState* currentState = NULL; - // TODO this is temporary while batch is being rolled out this->closeBatch(); iodb->getVertexAllocPool()->unmap(); iodb->getIndexAllocPool()->unmap(); fBatchTarget.preFlush(); - currentState = NULL; - CmdBuffer::Iter iter(fCmdBuffer); + // Updated every time we find a set state cmd to reflect the current state in the playback + // stream. + SetState* currentState = NULL; - int currCmdMarker = 0; + CmdBuffer::Iter iter(fCmdBuffer); GrGpu* gpu = iodb->getGpu(); - int i = 0; while (iter.next()) { - i++; GrGpuTraceMarker newMarker("", -1); SkString traceString; if (iter->isTraced()) { - traceString = iodb->getCmdString(currCmdMarker); + traceString = iodb->getCmdString(iter->markerID()); newMarker.fMarker = traceString.c_str(); gpu->addGpuTraceMarker(&newMarker); - ++currCmdMarker; } // TODO temporary hack - if (Cmd::kDrawBatch_Cmd == iter->type()) { + if (Cmd::kDrawBatch_CmdType == iter->type()) { DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); fBatchTarget.flushNext(db->fBatch->numberOfDraws()); @@ -326,16 +320,10 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { continue; } - if (Cmd::kSetState_Cmd == iter->type()) { + if (Cmd::kSetState_CmdType == iter->type()) { SetState* ss = reinterpret_cast<SetState*>(iter.get()); - // TODO sometimes we have a prim proc, othertimes we have a GrBatch. Eventually we - // will only have GrBatch and we can delete this - if (ss->fPrimitiveProcessor) { - gpu->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProcessor, - *ss->getPipeline(), - ss->fBatchTracker); - } + ss->execute(gpu, currentState); currentState = ss; } else { iter->execute(gpu, currentState); @@ -390,7 +378,13 @@ void GrTargetCommands::DrawBatch::execute(GrGpu*, const SetState* state) { fBatch->generateGeometry(fBatchTarget, state->getPipeline()); } -void GrTargetCommands::SetState::execute(GrGpu*, const SetState*) {} +void GrTargetCommands::SetState::execute(GrGpu* gpu, const SetState*) { + // TODO sometimes we have a prim proc, othertimes we have a GrBatch. Eventually we + // will only have GrBatch and we can delete this + if (fPrimitiveProcessor) { + gpu->buildProgramDesc(&fDesc, *fPrimitiveProcessor, *getPipeline(), fBatchTracker); + } +} void GrTargetCommands::Clear::execute(GrGpu* gpu, const SetState*) { if (GrColor_ILLEGAL == fColor) { diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h index b89f581b4a..035fbeb5bd 100644 --- a/src/gpu/GrTargetCommands.h +++ b/src/gpu/GrTargetCommands.h @@ -35,33 +35,34 @@ public: , fDrawBatch(NULL) { } - struct Cmd : ::SkNoncopyable { - enum { - kDraw_Cmd = 1, - kStencilPath_Cmd = 2, - kSetState_Cmd = 3, - kClear_Cmd = 4, - kCopySurface_Cmd = 5, - kDrawPath_Cmd = 6, - kDrawPaths_Cmd = 7, - kDrawBatch_Cmd = 8, + class Cmd : ::SkNoncopyable { + public: + enum CmdType { + kDraw_CmdType = 1, + kStencilPath_CmdType = 2, + kSetState_CmdType = 3, + kClear_CmdType = 4, + kCopySurface_CmdType = 5, + kDrawPath_CmdType = 6, + kDrawPaths_CmdType = 7, + kDrawBatch_CmdType = 8, }; - Cmd(uint8_t type) : fType(type) {} + Cmd(CmdType type) : fMarkerID(-1), fType(type) {} virtual ~Cmd() {} virtual void execute(GrGpu*, const SetState*) = 0; - uint8_t type() const { return fType & kCmdMask; } + CmdType type() const { return fType; } - bool isTraced() const { return SkToBool(fType & kTraceCmdBit); } - void makeTraced() { fType |= kTraceCmdBit; } + // trace markers + bool isTraced() const { return -1 != fMarkerID; } + void setMarkerID(int markerID) { SkASSERT(-1 == fMarkerID); fMarkerID = markerID; } + int markerID() const { return fMarkerID; } private: - static const int kCmdMask = 0x7F; - static const int kTraceCmdBit = 0x80; - - uint8_t fType; + int fMarkerID; + CmdType fType; }; void reset(); @@ -142,7 +143,7 @@ private: const GrDrawTarget::PipelineInfo&); struct Draw : public Cmd { - Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} + Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(info) {} void execute(GrGpu*, const SetState*) SK_OVERRIDE; @@ -151,7 +152,7 @@ private: struct StencilPath : public Cmd { StencilPath(const GrPath* path, GrRenderTarget* rt) - : Cmd(kStencilPath_Cmd) + : Cmd(kStencilPath_CmdType) , fRenderTarget(rt) , fPath(path) {} @@ -169,7 +170,7 @@ private: }; struct DrawPath : public Cmd { - DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} + DrawPath(const GrPath* path) : Cmd(kDrawPath_CmdType), fPath(path) {} const GrPath* path() const { return fPath.get(); } @@ -182,7 +183,7 @@ private: }; struct DrawPaths : public Cmd { - DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRange(pathRange) {} + DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_CmdType), fPathRange(pathRange) {} const GrPathRange* pathRange() const { return fPathRange.get(); } @@ -201,7 +202,7 @@ private: // This is also used to record a discard by setting the color to GrColor_ILLEGAL struct Clear : public Cmd { - Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} + Clear(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarget(rt) {} GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } @@ -217,7 +218,7 @@ private: // This command is ONLY used by the clip mask manager to clear the stencil clip bits struct ClearStencilClip : public Cmd { - ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} + ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarget(rt) {} GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } @@ -231,7 +232,11 @@ private: }; struct CopySurface : public Cmd { - CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDst(dst), fSrc(src) {} + CopySurface(GrSurface* dst, GrSurface* src) + : Cmd(kCopySurface_CmdType) + , fDst(dst) + , fSrc(src) { + } GrSurface* dst() const { return fDst.get(); } GrSurface* src() const { return fSrc.get(); } @@ -250,7 +255,7 @@ private: struct SetState : public Cmd { // TODO get rid of the prim proc parameter when we use batch everywhere SetState(const GrPrimitiveProcessor* primProc = NULL) - : Cmd(kSetState_Cmd) + : Cmd(kSetState_CmdType) , fPrimitiveProcessor(primProc) {} ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipeline(); } @@ -274,7 +279,7 @@ private: struct DrawBatch : public Cmd { DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget) - : Cmd(kDrawBatch_Cmd) + : Cmd(kDrawBatch_CmdType) , fBatch(SkRef(batch)) , fBatchTarget(batchTarget) { SkASSERT(!batch->isUsed()); |