diff options
author | stephana <stephana@google.com> | 2016-04-25 07:01:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-25 07:01:23 -0700 |
commit | 1dc172165b8186950fda4a269bd1b12c11947b14 (patch) | |
tree | f1482ee0e2d88d139c990b212d479885df5d7c8a /src/gpu/batches | |
parent | edf7fcd8b9e339800edb61ae422f8b6c1b77c3e8 (diff) |
Revert of Batch multiple single NVPR draw paths to instanced draws (patchset #5 id:80001 of https://codereview.chromium.org/1908433002/ )
Reason for revert:
This causes what looks like significantly wrong results. Here is an example:
https://gold.skia.org/diff?test=stroke-fill&left=cb47dc2cabbad7d146aedaac199ebace&top=2c6e65d597c574e3bb170a19ca9634c6
Original issue's description:
> Batch multiple single NVPR draw paths to instanced draws
>
> Batch multiple single NVPR draw paths to instanced draws.
> A draw path batch can be combined to other batch if the
> batches do not overlap and have same draw characteristics.
>
> Join the batches in linked list and flatten the list to a
> path list during draw time.
>
> Replace GrPathRendering::drawPath with GrPathRendering::drawPaths.
>
> Perf changes ARM, Shield TV device, Tegra X1 GPU:
> desk_chalkboard.skp_1 21.5ms -> 17.8ms 0.83x
> desk_mapsvg.skp_1 7.49ms -> 6.18ms 0.82x
> Others results are more volatile.
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1908433002
>
> Committed: https://skia.googlesource.com/skia/+/3c33c389e9f8d14d86756ea1ddeba2097f31ad22
TBR=joshualitt@chromium.org,bsalomon@google.com,kkinnunen@nvidia.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1919843002
Diffstat (limited to 'src/gpu/batches')
-rw-r--r-- | src/gpu/batches/GrBatch.h | 3 | ||||
-rw-r--r-- | src/gpu/batches/GrDrawPathBatch.cpp | 76 | ||||
-rw-r--r-- | src/gpu/batches/GrDrawPathBatch.h | 15 |
3 files changed, 10 insertions, 84 deletions
diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h index 23be88d437..f0559330fe 100644 --- a/src/gpu/batches/GrBatch.h +++ b/src/gpu/batches/GrBatch.h @@ -28,8 +28,7 @@ class GrRenderTarget; * Batches are created when GrContext processes a draw call. Batches of the same subclass may be * merged using combineIfPossible. When two batches merge, one takes on the union of the data * and the other is left empty. The merged batch becomes responsible for drawing the data from both - * the original batches. The merged patch may ref the other batch, if this is more efficient than - * moving the data from the other batch to the merged batch. + * the original batches. * * If there are any possible optimizations which might require knowing more about the full state of * the draw, ie whether or not the GrBatch is allowed to tweak alpha for coverage, then this diff --git a/src/gpu/batches/GrDrawPathBatch.cpp b/src/gpu/batches/GrDrawPathBatch.cpp index fb9ca943dc..1395d08328 100644 --- a/src/gpu/batches/GrDrawPathBatch.cpp +++ b/src/gpu/batches/GrDrawPathBatch.cpp @@ -13,84 +13,18 @@ static void pre_translate_transform_values(const float* xforms, SkString GrDrawPathBatch::dumpInfo() const { SkString string; - string.printf("Color: 0x%08x Fill: %x Path count: %d Paths: ", this->color(), this->fillType(), - fTotalPathCount); - const GrDrawPathBatch* batch = this; - do { - string.appendf("0x%p", batch->fPath.get()); - batch = batch->fNext.get(); - } while (batch); - string.append("\n"); + string.printf("PATH: 0x%p", fPath.get()); return string; } -bool GrDrawPathBatch::ListBoundsIntersects(const GrDrawPathBatch* a, const GrDrawPathBatch* b) { - if (!SkRect::Intersects(a->fBounds, b->fBounds)) { - return false; - } - if (!a->fNext && !b->fNext) { - return true; - } - const GrDrawPathBatch* firstA = a; - do { - do { - if (SkRect::Intersects(a->fPathBounds, b->fPathBounds)) { - return true; - } - a = a->fNext.get(); - } while (a); - a = firstA; - b = b->fNext.get(); - } while (b); - return false; -} - -bool GrDrawPathBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { - GrDrawPathBatch* that = t->cast<GrDrawPathBatch>(); - if (this->color() != that->color() || - !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { - return false; - } - if (!GrPipeline::AreEqual(*this->pipeline(), *that->pipeline(), false)) { - return false; - } - if (that->fillType() != this->fillType() || - this->stencilSettings() != that->stencilSettings()) { - return false; - } - if (ListBoundsIntersects(this, that)) { - return false; - } - if (!fPath.get()->canCombineDrawPathBatchWith(*that->fPath.get())) { - return false; - } - SkASSERT(!*fLastSlot); - fLastSlot->reset(SkRef(that)); - fLastSlot = that->fLastSlot; - fTotalPathCount += that->fTotalPathCount; - this->joinBounds(that->fBounds); - return true; -} - void GrDrawPathBatch::onDraw(GrBatchFlushState* state) { + GrProgramDesc desc; + SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->overrides(), this->viewMatrix())); - if (fTotalPathCount > 1) { - SkAutoSTMalloc<32, const GrPath*> paths(fTotalPathCount); - GrDrawPathBatch* batch = this; - int i = 0; - do { - paths[i++] = batch->fPath.get(); - batch = batch->fNext.get(); - } while (batch); - state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc, - this->stencilSettings(), paths, fTotalPathCount); - } else { - const GrPath* path = fPath.get(); - state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc, - this->stencilSettings(), &path, 1); - } + state->gpu()->pathRendering()->drawPath(*this->pipeline(), *pathProc, this->stencilSettings(), + fPath.get()); } SkString GrDrawPathRangeBatch::dumpInfo() const { diff --git a/src/gpu/batches/GrDrawPathBatch.h b/src/gpu/batches/GrDrawPathBatch.h index 6d5c69a346..d29d046de3 100644 --- a/src/gpu/batches/GrDrawPathBatch.h +++ b/src/gpu/batches/GrDrawPathBatch.h @@ -76,26 +76,19 @@ private: GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, GrPathRendering::FillType fill, const GrPath* path) : INHERITED(ClassID(), viewMatrix, color, fill) - , fPath(path) - , fNext(nullptr) - , fLastSlot(&fNext) - , fTotalPathCount(1) { + , fPath(path) { fBounds = path->getBounds(); viewMatrix.mapRect(&fBounds); - fPathBounds = fBounds; } - static bool ListBoundsIntersects(const GrDrawPathBatch* a, const GrDrawPathBatch* b); - bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; + + bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; } void onPrepare(GrBatchFlushState*) override {} void onDraw(GrBatchFlushState* state) override; GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; - SkRect fPathBounds; - sk_sp<GrDrawPathBatch> fNext; // Batch union is made with a linked list of batch nodes. - sk_sp<GrDrawPathBatch>* fLastSlot; // Points to the fNext of the last batch in the batch list. - int fTotalPathCount; + typedef GrDrawPathBatchBase INHERITED; }; |