diff options
-rw-r--r-- | gyp/gpu.gypi | 12 | ||||
-rw-r--r-- | src/gpu/GrBufferedDrawTarget.cpp | 37 | ||||
-rw-r--r-- | src/gpu/GrBufferedDrawTarget.h | 45 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 94 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 18 | ||||
-rw-r--r-- | src/gpu/GrImmediateDrawTarget.cpp | 47 | ||||
-rw-r--r-- | src/gpu/GrImmediateDrawTarget.h | 41 | ||||
-rw-r--r-- | src/gpu/GrInOrderCommandBuilder.cpp | 29 | ||||
-rw-r--r-- | src/gpu/GrInOrderCommandBuilder.h | 26 | ||||
-rw-r--r-- | src/gpu/GrReorderCommandBuilder.cpp | 82 | ||||
-rw-r--r-- | src/gpu/GrReorderCommandBuilder.h | 25 | ||||
-rw-r--r-- | src/gpu/GrTargetCommands.cpp | 48 | ||||
-rw-r--r-- | src/gpu/GrTargetCommands.h | 99 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrTracing.h | 1 | ||||
-rw-r--r-- | src/gpu/batches/GrStencilPathBatch.h | 1 |
17 files changed, 93 insertions, 523 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index 2f491813f3..2af893c4d7 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -76,8 +76,6 @@ '<(skia_src_path)/gpu/GrBlurUtils.h', '<(skia_src_path)/gpu/GrBufferAllocPool.cpp', '<(skia_src_path)/gpu/GrBufferAllocPool.h', - '<(skia_src_path)/gpu/GrBufferedDrawTarget.cpp', - '<(skia_src_path)/gpu/GrBufferedDrawTarget.h', '<(skia_src_path)/gpu/GrCaps.cpp', '<(skia_src_path)/gpu/GrClip.cpp', '<(skia_src_path)/gpu/GrClipMaskCache.h', @@ -85,8 +83,6 @@ '<(skia_src_path)/gpu/GrClipMaskManager.h', '<(skia_src_path)/gpu/GrClipMaskManager.cpp', '<(skia_src_path)/gpu/GrContext.cpp', - '<(skia_src_path)/gpu/GrCommandBuilder.h', - '<(skia_src_path)/gpu/GrCommandBuilder.cpp', '<(skia_src_path)/gpu/GrCoordTransform.cpp', '<(skia_src_path)/gpu/GrDefaultGeoProcFactory.cpp', '<(skia_src_path)/gpu/GrDefaultGeoProcFactory.h', @@ -105,12 +101,8 @@ '<(skia_src_path)/gpu/GrGpuResource.cpp', '<(skia_src_path)/gpu/GrGpuFactory.cpp', '<(skia_src_path)/gpu/GrGpuFactory.h', - '<(skia_src_path)/gpu/GrImmediateDrawTarget.cpp', - '<(skia_src_path)/gpu/GrImmediateDrawTarget.h', '<(skia_src_path)/gpu/GrIndexBuffer.h', '<(skia_src_path)/gpu/GrInvariantOutput.cpp', - '<(skia_src_path)/gpu/GrInOrderCommandBuilder.cpp', - '<(skia_src_path)/gpu/GrInOrderCommandBuilder.h', '<(skia_src_path)/gpu/GrLayerCache.cpp', '<(skia_src_path)/gpu/GrLayerCache.h', '<(skia_src_path)/gpu/GrLayerHoister.cpp', @@ -160,8 +152,6 @@ '<(skia_src_path)/gpu/GrRenderTargetPriv.h', '<(skia_src_path)/gpu/GrReducedClip.cpp', '<(skia_src_path)/gpu/GrReducedClip.h', - '<(skia_src_path)/gpu/GrReorderCommandBuilder.h', - '<(skia_src_path)/gpu/GrReorderCommandBuilder.cpp', '<(skia_src_path)/gpu/GrResourceCache.cpp', '<(skia_src_path)/gpu/GrResourceCache.h', '<(skia_src_path)/gpu/GrResourceProvider.cpp', @@ -174,8 +164,6 @@ '<(skia_src_path)/gpu/GrStencilAttachment.h', '<(skia_src_path)/gpu/GrStrokeInfo.cpp', '<(skia_src_path)/gpu/GrStrokeInfo.h', - '<(skia_src_path)/gpu/GrTargetCommands.cpp', - '<(skia_src_path)/gpu/GrTargetCommands.h', '<(skia_src_path)/gpu/GrTraceMarker.cpp', '<(skia_src_path)/gpu/GrTraceMarker.h', '<(skia_src_path)/gpu/GrTracing.h', diff --git a/src/gpu/GrBufferedDrawTarget.cpp b/src/gpu/GrBufferedDrawTarget.cpp deleted file mode 100644 index 0b6e885db3..0000000000 --- a/src/gpu/GrBufferedDrawTarget.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrBufferedDrawTarget.h" - -// We will use the reordering buffer, unless we have NVPR. -// TODO move NVPR to batch so we can reorder -static inline bool allow_reordering(const GrCaps* caps) { - return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSupport(); -} - -GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context) - : INHERITED(context) - , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(context->caps()))) - , fDrawID(0) { -} - -GrBufferedDrawTarget::~GrBufferedDrawTarget() { - this->reset(); -} - -void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) { - fCommands->recordDrawBatch(batch, *this->caps()); -} - -void GrBufferedDrawTarget::onFlush() { - fCommands->flush(this->getGpu(), this->getContext()->resourceProvider()); - ++fDrawID; -} - -void GrBufferedDrawTarget::onReset() { - fCommands->reset(); -} diff --git a/src/gpu/GrBufferedDrawTarget.h b/src/gpu/GrBufferedDrawTarget.h deleted file mode 100644 index 79b1a71cfe..0000000000 --- a/src/gpu/GrBufferedDrawTarget.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrBufferedDrawTarget_DEFINED -#define GrBufferedDrawTarget_DEFINED - -#include "GrDrawTarget.h" -#include "GrCommandBuilder.h" -#include "SkChunkAlloc.h" - -/** - * GrBufferedDrawTarget is an implementation of GrDrawTarget that queues up draws for eventual - * playback into a GrGpu. In theory one draw buffer could playback into another. Similarly, it is - * the caller's responsibility to ensure that all referenced textures, buffers, and render-targets - * are associated in the GrGpu object that the buffer is played back into. - */ -class GrBufferedDrawTarget : public GrClipTarget { -public: - /** - * Creates a GrBufferedDrawTarget - * - * @param context the context object that owns this draw buffer. - */ - GrBufferedDrawTarget(GrContext* context); - - ~GrBufferedDrawTarget() override; - -protected: - void onDrawBatch(GrBatch*) override; - -private: - void onReset() override; - void onFlush() override; - - SkAutoTDelete<GrCommandBuilder> fCommands; - uint32_t fDrawID; - - typedef GrClipTarget INHERITED; -}; - -#endif diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 6ae96c498b..c125dd9dd8 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -11,15 +11,14 @@ #include "GrBatchFontCache.h" #include "GrBatchFlushState.h" #include "GrBatchTest.h" -#include "GrBufferedDrawTarget.h" #include "GrCaps.h" #include "GrContextOptions.h" #include "GrDefaultGeoProcFactory.h" #include "GrDrawContext.h" +#include "GrDrawTarget.h" #include "GrGpuResource.h" #include "GrGpuResourcePriv.h" #include "GrGpu.h" -#include "GrImmediateDrawTarget.h" #include "GrIndexBuffer.h" #include "GrLayerCache.h" #include "GrOvalRenderer.h" @@ -61,12 +60,7 @@ void GrContext::DrawingMgr::init(GrContext* context) { fContext = context; - -#ifdef IMMEDIATE_MODE - fDrawTarget = new GrImmediateDrawTarget(context); -#else - fDrawTarget = new GrBufferedDrawTarget(context); -#endif + fDrawTarget = new GrClipTarget(context); } void GrContext::DrawingMgr::cleanup() { diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 0e7e6bce90..7eaa8bc762 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -36,7 +36,8 @@ GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) : fGpu(SkRef(gpu)) , fCaps(SkRef(gpu->caps())) , fResourceProvider(resourceProvider) - , fFlushing(false) { + , fFlushing(false) + , fLastFlushToken(0) { } GrDrawTarget::~GrDrawTarget() { @@ -119,12 +120,31 @@ void GrDrawTarget::flush() { } fFlushing = true; - this->onFlush(); + GrBatchFlushState flushState(fGpu, fResourceProvider, fLastFlushToken); + + // Loop over all batches and generate geometry + for (int i = 0; i < fBatches.count(); ++i) { + fBatches[i]->prepare(&flushState); + } + + // Upload all data to the GPU + flushState.preIssueDraws(); + + // Draw all the generated geometry. + for (int i = 0; i < fBatches.count(); ++i) { + fBatches[i]->draw(&flushState); + } + + fLastFlushToken = flushState.lastFlushedToken(); fFlushing = false; this->reset(); } +void GrDrawTarget::reset() { + fBatches.reset(); +} + void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatch* batch) { // Setup clip GrScissorState scissorState; @@ -148,7 +168,7 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { return; } - this->onDrawBatch(batch); + this->recordBatch(batch); } static const GrStencilSettings& winding_path_stencil_settings() { @@ -213,7 +233,7 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, stencilSettings, scissorState, pipelineBuilder.getRenderTarget(), path); - this->onDrawBatch(batch); + this->recordBatch(batch); batch->unref(); } @@ -269,7 +289,7 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, return; } - this->onDrawBatch(batch); + this->recordBatch(batch); } void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, @@ -344,7 +364,7 @@ void GrDrawTarget::clear(const SkIRect* rect, this->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), *rect); } else { GrBatch* batch = new GrClearBatch(*rect, color, renderTarget); - this->onDrawBatch(batch); + this->recordBatch(batch); batch->unref(); } } @@ -352,7 +372,7 @@ void GrDrawTarget::clear(const SkIRect* rect, void GrDrawTarget::discard(GrRenderTarget* renderTarget) { if (this->caps()->discardRenderTargetSupport()) { GrBatch* batch = new GrDiscardBatch(renderTarget); - this->onDrawBatch(batch); + this->recordBatch(batch); batch->unref(); } } @@ -365,11 +385,67 @@ void GrDrawTarget::copySurface(GrSurface* dst, const SkIPoint& dstPoint) { GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint); if (batch) { - this->onDrawBatch(batch); + this->recordBatch(batch); batch->unref(); } } +template <class Left, class Right> static bool intersect(const Left& a, const Right& b) { + SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && + b.fLeft <= b.fRight && b.fTop <= b.fBottom); + return a.fLeft < b.fRight && b.fLeft < a.fRight && a.fTop < b.fBottom && b.fTop < a.fBottom; +} + +void GrDrawTarget::recordBatch(GrBatch* batch) { + // Check if there is a Batch Draw we can batch with by linearly searching back until we either + // 1) check every draw + // 2) intersect with something + // 3) find a 'blocker' + // Experimentally we have found that most batching occurs within the first 10 comparisons. + static const int kMaxLookback = 10; + + GrBATCH_INFO("Re-Recording (%s, B%u)\n" + "\tBounds (%f, %f, %f, %f)\n", + batch->name(), + batch->uniqueID(), + batch->bounds().fLeft, batch->bounds().fRight, + batch->bounds().fTop, batch->bounds().fBottom); + GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str()); + GrBATCH_INFO("\tOutcome:\n"); + int maxCandidates = SkTMin(kMaxLookback, fBatches.count()); + if (maxCandidates) { + int i = 0; + while (true) { + GrBatch* candidate = fBatches.fromBack(i); + // We cannot continue to search backwards if the render target changes + if (candidate->renderTargetUniqueID() != batch->renderTargetUniqueID()) { + GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n", + candidate->name(), candidate->uniqueID()); + break; + } + if (candidate->combineIfPossible(batch, *this->caps())) { + GrBATCH_INFO("\t\tCombining with (%s, B%u)\n", candidate->name(), + candidate->uniqueID()); + return; + } + // Stop going backwards if we would cause a painter's order violation. + if (intersect(candidate->bounds(), batch->bounds())) { + GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n", candidate->name(), + candidate->uniqueID()); + break; + } + ++i; + if (i == maxCandidates) { + GrBATCH_INFO("\t\tReached max lookback or beginning of batch array %d\n", i); + break; + } + } + } else { + GrBATCH_INFO("\t\tFirstBatch\n"); + } + fBatches.push_back().reset(SkRef(batch)); +} + /////////////////////////////////////////////////////////////////////////////// GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilder, @@ -416,6 +492,6 @@ void GrClipTarget::purgeResources() { void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) { GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); - this->onDrawBatch(batch); + this->recordBatch(batch); batch->unref(); } diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 13f35ac768..15024cd95e 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -39,23 +39,16 @@ class GrPathRangeDraw; class GrDrawTarget : public SkRefCnt { public: - - - typedef GrPathRange::PathIndexType PathIndexType; - typedef GrPathRendering::PathTransformType PathTransformType; - - /////////////////////////////////////////////////////////////////////////// - // The context may not be fully constructed and should not be used during GrDrawTarget // construction. GrDrawTarget(GrGpu* gpu, GrResourceProvider*); - virtual ~GrDrawTarget(); + ~GrDrawTarget() override; /** * Empties the draw buffer of any queued up draws. */ - void reset() { this->onReset(); } + void reset(); /** * This plays any queued up draws to its GrGpu target. It also resets this object (i.e. flushing @@ -211,12 +204,10 @@ protected: GrXferProcessor::DstTexture*, const SkRect* drawBounds); - virtual void onDrawBatch(GrBatch*) = 0; + void recordBatch(GrBatch*); private: - virtual void onReset() = 0; - - virtual void onFlush() = 0; + SkSTArray<256, SkAutoTUnref<GrBatch>, true> fBatches; void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatchBase* batch, GrPathRendering::FillType fill); @@ -235,6 +226,7 @@ private: const GrCaps* fCaps; GrResourceProvider* fResourceProvider; bool fFlushing; + GrBatchToken fLastFlushToken; typedef SkRefCnt INHERITED; }; diff --git a/src/gpu/GrImmediateDrawTarget.cpp b/src/gpu/GrImmediateDrawTarget.cpp deleted file mode 100644 index 66540e32be..0000000000 --- a/src/gpu/GrImmediateDrawTarget.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrImmediateDrawTarget.h" - -#include "GrGpu.h" -#include "GrPipeline.h" -#include "GrRenderTarget.h" -#include "SkRect.h" -#include "SkTypes.h" - -#include "batches/GrDrawBatch.h" -#include "batches/GrVertexBatch.h" - -GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) - : INHERITED(context) - , fDrawID(0) { -} - -GrImmediateDrawTarget::~GrImmediateDrawTarget() { - this->reset(); -} - -void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch) { - -#if 0 - // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so that we can - // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. - GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(batch); - vertexBatch->prepareDraws(&fBatchTarget); - vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); - - fBatchTarget.preFlush(); - fBatchTarget.flushNext(vertexBatch->numberOfDraws()); - fBatchTarget.postFlush(); -#endif -} - -void GrImmediateDrawTarget::onReset() {} - -void GrImmediateDrawTarget::onFlush() { - ++fDrawID; -} diff --git a/src/gpu/GrImmediateDrawTarget.h b/src/gpu/GrImmediateDrawTarget.h deleted file mode 100644 index 4791de9841..0000000000 --- a/src/gpu/GrImmediateDrawTarget.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrImmediateDrawTarget_DEFINED -#define GrImmediateDrawTarget_DEFINED - -#include "GrDrawTarget.h" - -#include "GrBatchFlushState.h" - -/** - * A debug GrDrawTarget which immediately flushes every command it receives - */ -class GrImmediateDrawTarget : public GrClipTarget { -public: - /** - * Creates a GrImmediateDrawTarget - * - * @param context the context object that owns this draw buffer. - */ - GrImmediateDrawTarget(GrContext* context); - - ~GrImmediateDrawTarget() override; - -protected: - void onDrawBatch(GrBatch*) override; - -private: - void onReset() override; - void onFlush() override; - - uint32_t fDrawID; - - typedef GrClipTarget INHERITED; -}; - -#endif diff --git a/src/gpu/GrInOrderCommandBuilder.cpp b/src/gpu/GrInOrderCommandBuilder.cpp deleted file mode 100644 index bbe42a6de5..0000000000 --- a/src/gpu/GrInOrderCommandBuilder.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrInOrderCommandBuilder.h" - -#include "GrBufferedDrawTarget.h" - -#include "GrColor.h" -#include "SkPoint.h" - -GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(GrBatch* batch, - const GrCaps& caps) { - GrBATCH_INFO("In-Recording (%s, %u)\n", batch->name(), batch->uniqueID()); - if (!this->cmdBuffer()->empty() && - Cmd::kDrawBatch_CmdType == this->cmdBuffer()->back().type()) { - DrawBatch* previous = static_cast<DrawBatch*>(&this->cmdBuffer()->back()); - if (previous->batch()->combineIfPossible(batch, caps)) { - GrBATCH_INFO("\tBatching with (%s, %u)\n", - previous->batch()->name(), previous->batch()->uniqueID()); - return nullptr; - } - } - - return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch)); -} diff --git a/src/gpu/GrInOrderCommandBuilder.h b/src/gpu/GrInOrderCommandBuilder.h deleted file mode 100644 index e205ae49eb..0000000000 --- a/src/gpu/GrInOrderCommandBuilder.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrInOrderCommandBuilder_DEFINED -#define GrInOrderCommandBuilder_DEFINED - -#include "GrCommandBuilder.h" - -class GrInOrderCommandBuilder : public GrCommandBuilder { -public: - typedef GrCommandBuilder::Cmd Cmd; - - GrInOrderCommandBuilder() : INHERITED() { } - - Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override; - -private: - typedef GrCommandBuilder INHERITED; - -}; - -#endif diff --git a/src/gpu/GrReorderCommandBuilder.cpp b/src/gpu/GrReorderCommandBuilder.cpp deleted file mode 100644 index b0f9ee2f39..0000000000 --- a/src/gpu/GrReorderCommandBuilder.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrReorderCommandBuilder.h" -#include "SkStringUtils.h" - -template <class Left, class Right> -static bool intersect(const Left& a, const Right& b) { - SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && - b.fLeft <= b.fRight && b.fTop <= b.fBottom); - return a.fLeft < b.fRight && b.fLeft < a.fRight && - a.fTop < b.fBottom && b.fTop < a.fBottom; -} - -GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrBatch* batch, - const GrCaps& caps) { - // Check if there is a Batch Draw we can batch with by linearly searching back until we either - // 1) check every draw - // 2) intersect with something - // 3) find a 'blocker' - // Experimentally we have found that most batching occurs within the first 10 comparisons. - static const int kMaxLookback = 10; - int i = 0; - - GrBATCH_INFO("Re-Recording (%s, B%u)\n" - "\tBounds (%f, %f, %f, %f)\n", - batch->name(), - batch->uniqueID(), - batch->bounds().fLeft, batch->bounds().fRight, - batch->bounds().fTop, batch->bounds().fBottom); - GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str()); - GrBATCH_INFO("\tOutcome:\n"); - if (!this->cmdBuffer()->empty()) { - GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()); - - do { - if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { - DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()); - - if (previous->batch()->renderTargetUniqueID() != batch->renderTargetUniqueID()) { - GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n", - previous->batch()->name(), previous->batch()->uniqueID()); - break; - } - // We cannot continue to search backwards if the render target changes - if (previous->batch()->combineIfPossible(batch, caps)) { - GrBATCH_INFO("\t\tCombining with (%s, B%u)\n", - previous->batch()->name(), previous->batch()->uniqueID()); - return nullptr; - } - - if (intersect(previous->batch()->bounds(), batch->bounds())) { - GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n", - previous->batch()->name(), previous->batch()->uniqueID()); - break; - } - } else { - GrBATCH_INFO("\t\tBreaking because of other %08x\n", reverseIter->type()); - // TODO temporary until we only have batches. - break; - } - } while (reverseIter.previous() && ++i < kMaxLookback); -#if GR_BATCH_SPEW - if (!reverseIter.get()) { - GrBATCH_INFO("\t\tNo more commands to try and batch with\n"); - } else if (i >= kMaxLookback) { - GrBATCH_INFO("\t\tReached max lookback %d\n", i); - } -#endif - } -#if GR_BATCH_SPEW - else { - GrBATCH_INFO("\t\tBreaking because empty command buffer\n"); - } -#endif - - return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch)); -} diff --git a/src/gpu/GrReorderCommandBuilder.h b/src/gpu/GrReorderCommandBuilder.h deleted file mode 100644 index 4670f1b176..0000000000 --- a/src/gpu/GrReorderCommandBuilder.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrReorderCommandBuilder_DEFINED -#define GrReorderCommandBuilder_DEFINED - -#include "GrCommandBuilder.h" - -class GrReorderCommandBuilder : public GrCommandBuilder { -public: - typedef GrCommandBuilder::Cmd Cmd; - - GrReorderCommandBuilder() : INHERITED() {} - - Cmd* recordDrawBatch(GrBatch*, const GrCaps&) override; - -private: - typedef GrCommandBuilder INHERITED; -}; - -#endif diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp deleted file mode 100644 index 2194e08f0a..0000000000 --- a/src/gpu/GrTargetCommands.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrTargetCommands.h" - -#include "GrBatchFlushState.h" -#include "GrGpu.h" -#include "GrPathRendering.h" -#include "batches/GrDrawBatch.h" -#include "batches/GrVertexBatch.h" - -GrBATCH_SPEW(int32_t GrTargetCommands::Cmd::gUniqueID = 0;) - -void GrTargetCommands::reset() { - fCmdBuffer.reset(); -} - -void GrTargetCommands::flush(GrGpu* gpu, GrResourceProvider* resourceProvider) { - GrBATCH_INFO("Flushing\n"); - if (fCmdBuffer.empty()) { - return; - } - GrBatchFlushState flushState(gpu, resourceProvider, fLastFlushToken); - // 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()); - db->batch()->prepare(&flushState); - } - } - - flushState.preIssueDraws(); - - CmdBuffer::Iter iter(fCmdBuffer); - while (iter.next()) { - iter->execute(&flushState); - } - fLastFlushToken = flushState.lastFlushedToken(); -} - -void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) { - fBatch->draw(state); -} diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h deleted file mode 100644 index 5d9cdfc5be..0000000000 --- a/src/gpu/GrTargetCommands.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrTargetCommands_DEFINED -#define GrTargetCommands_DEFINED - -#include "GrDrawTarget.h" -#include "GrPath.h" -#include "GrPendingProgramElement.h" -#include "GrPrimitiveProcessor.h" -#include "GrRenderTarget.h" -#include "GrTRecorder.h" - -#include "batches/GrBatch.h" - -#include "SkRect.h" - -class GrResourceProvider; -class GrBatchFlushState; - -// TODO: Convert all commands into GrBatch and remove this class. -class GrTargetCommands : ::SkNoncopyable { -public: - GrTargetCommands() : fCmdBuffer(kCmdBufferInitialSizeInBytes), fLastFlushToken(0) {} - - class Cmd : ::SkNoncopyable { - public: - enum CmdType { - kDrawBatch_CmdType = 4, - }; - - Cmd(CmdType type) - : fType(type) -#if GR_BATCH_SPEW - , fUniqueID(GenID(&gUniqueID)) -#endif - {} - virtual ~Cmd() {} - - virtual void execute(GrBatchFlushState*) = 0; - - CmdType type() const { return fType; } - - GrBATCH_SPEW(uint32_t uniqueID() const { return fUniqueID;} ) - - private: - // TODO move this to a common header so it can be shared with GrBatch - static uint32_t GenID(int32_t* idCounter) { - uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1; - if (!id) { - SkFAIL("This should never wrap\n"); - } - return id; - } - CmdType fType; - GrBATCH_SPEW(uint32_t fUniqueID); - GrBATCH_SPEW(static int32_t gUniqueID;) - }; - - void reset(); - void flush(GrGpu*, GrResourceProvider*); - -private: - friend class GrCommandBuilder; - friend class GrBufferedDrawTarget; // This goes away when State becomes just a pipeline - friend class GrReorderCommandBuilder; - - typedef GrGpu::DrawArgs DrawArgs; - - struct DrawBatch : public Cmd { - DrawBatch(GrBatch* batch) - : Cmd(kDrawBatch_CmdType) - , fBatch(SkRef(batch)){ - SkASSERT(!batch->isUsed()); - } - - GrBatch* batch() { return fBatch; } - void execute(GrBatchFlushState*) override; - - private: - SkAutoTUnref<GrBatch> fBatch; - }; - - static const int kCmdBufferInitialSizeInBytes = 8 * 1024; - - typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. - typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; - - CmdBuffer* cmdBuffer() { return &fCmdBuffer; } - - CmdBuffer fCmdBuffer; - GrBatchToken fLastFlushToken; -}; - -#endif diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 0852b6dd94..10ce244122 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -10,7 +10,6 @@ #include "GrBatchAtlas.h" #include "GrBatchFontCache.h" -#include "GrBufferedDrawTarget.h" #include "GrContextOptions.h" #include "GrGpuResourceCacheAccess.h" #include "GrResourceCache.h" diff --git a/src/gpu/GrTracing.h b/src/gpu/GrTracing.h index 0eb203fbc4..d758c0329d 100644 --- a/src/gpu/GrTracing.h +++ b/src/gpu/GrTracing.h @@ -8,7 +8,6 @@ #ifndef GrTracing_DEFINED #define GrTracing_DEFINED -#include "GrBufferedDrawTarget.h" #include "GrDrawTarget.h" #include "GrGpu.h" #include "GrTraceMarker.h" diff --git a/src/gpu/batches/GrStencilPathBatch.h b/src/gpu/batches/GrStencilPathBatch.h index 6b4ddf00df..9f6740a046 100644 --- a/src/gpu/batches/GrStencilPathBatch.h +++ b/src/gpu/batches/GrStencilPathBatch.h @@ -50,6 +50,7 @@ private: , fRenderTarget(renderTarget) , fPath(path) { this->initClassID<GrStencilPathBatch>(); + fBounds = path->getBounds(); } bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; } |