From c84c030295bac4fcd907cd64456d763f765add80 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Mon, 8 May 2017 15:35:11 -0400 Subject: Add debug-only helper methods to get #ops & #clips per opList These are being/will be used to determine the correct amout of memory to preallocate for ops & clips in the opLists. Change-Id: I98ebaec8a6e72a43d97101aca5fbc58264964ebd Reviewed-on: https://skia-review.googlesource.com/15882 Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- src/gpu/GrOpList.h | 3 +++ src/gpu/GrRenderTargetContext.cpp | 2 +- src/gpu/GrRenderTargetOpList.cpp | 8 ++++++-- src/gpu/GrRenderTargetOpList.h | 4 ++++ src/gpu/GrTextureContext.cpp | 4 ++-- src/gpu/GrTextureOpList.cpp | 1 + src/gpu/GrTextureOpList.h | 2 ++ 7 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h index b354abed76..54a13e1d91 100644 --- a/src/gpu/GrOpList.h +++ b/src/gpu/GrOpList.h @@ -82,6 +82,9 @@ public: SkDEBUGCODE(virtual void validateTargetsSingleRenderTarget() const = 0;) + SkDEBUGCODE(virtual int numOps() const = 0;) + SkDEBUGCODE(virtual int numClips() const { return 0; }) + protected: GrSurfaceProxy* fTarget; GrAuditTrail* fAuditTrail; diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index f81dc46255..7de1f8dddf 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -127,7 +127,7 @@ GrRenderTargetOpList* GrRenderTargetContext::getOpList() { return fOpList.get(); } -// TODO: move this (and GrTextContext::copy) to GrSurfaceContext? +// MDB TODO: move this (and GrTextContext::copy) to GrSurfaceContext? bool GrRenderTargetContext::onCopy(GrSurfaceProxy* srcProxy, const SkIRect& srcRect, const SkIPoint& dstPoint) { diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 9920cfd8f7..a9f4351a77 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -29,7 +29,9 @@ static const int kMaxOpLookahead = 10; GrRenderTargetOpList::GrRenderTargetOpList(sk_sp proxy, GrGpu* gpu, GrAuditTrail* auditTrail) : INHERITED(std::move(proxy), auditTrail) - , fLastClipStackGenID(SK_InvalidUniqueID) { + , fLastClipStackGenID(SK_InvalidUniqueID) + SkDEBUGCODE(, fNumClips(0)) +{ if (GrCaps::InstancedSupport::kNone != gpu->caps()->instancedSupport()) { fInstancedRendering.reset(gpu->createInstancedRendering()); } @@ -246,6 +248,7 @@ void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext, //////////////////////////////////////////////////////////////////////////////// +// MDB TODO: fuse with GrTextureOpList::copySurface bool GrRenderTargetOpList::copySurface(GrResourceProvider* resourceProvider, GrRenderTargetContext* dst, GrSurfaceProxy* src, @@ -359,6 +362,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr op, GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op); if (clip) { clip = fClipAllocator.make(std::move(*clip)); + SkDEBUGCODE(fNumClips++;) } fRecordedOps.emplace_back(std::move(op), renderTarget, clip, dstTexture); fRecordedOps.back().fOp->wasRecorded(this); @@ -398,7 +402,7 @@ void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) { fRecordedOps[j].fOp = std::move(fRecordedOps[i].fOp); break; } - // Stop going traversing if we would cause a painter's order violation. + // Stop traversing if we would cause a painter's order violation. if (!can_reorder(fRecordedOps[j].fOp->bounds(), op->bounds())) { GrOP_INFO("\t\tForward: Intersects with (%s, opID: %u)\n", candidate.fOp->name(), candidate.fOp->uniqueID()); diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index 342f9278d5..21dd70e01b 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -106,6 +106,9 @@ public: SkDEBUGCODE(void validateTargetsSingleRenderTarget() const override;) + SkDEBUGCODE(int numOps() const override { return fRecordedOps.count(); }) + SkDEBUGCODE(int numClips() const override { return fNumClips; }) + private: friend class GrRenderTargetContextPriv; // for stencil clip state. TODO: this is invasive @@ -153,6 +156,7 @@ private: // MDB TODO: 4096 for the first allocation of the clip space will be huge overkill. // Gather statistics to determine the correct size. SkArenaAlloc fClipAllocator{4096}; + SkDEBUGCODE(int fNumClips;) typedef GrOpList INHERITED; }; diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp index 68e94f9be3..fb8e79584e 100644 --- a/src/gpu/GrTextureContext.cpp +++ b/src/gpu/GrTextureContext.cpp @@ -68,14 +68,14 @@ GrTextureOpList* GrTextureContext::getOpList() { return fOpList.get(); } -// TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext? +// MDB TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext? bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy, const SkIRect& srcRect, const SkIPoint& dstPoint) { ASSERT_SINGLE_OWNER RETURN_FALSE_IF_ABANDONED SkDEBUGCODE(this->validate();) - GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copy"); + GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::onCopy"); #ifndef ENABLE_MDB // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index 689ea44783..97a4bbf05e 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -81,6 +81,7 @@ void GrTextureOpList::reset() { //////////////////////////////////////////////////////////////////////////////// +// MDB TODO: fuse with GrRenderTargetOpList::copySurface bool GrTextureOpList::copySurface(GrResourceProvider* resourceProvider, GrSurfaceProxy* dst, GrSurfaceProxy* src, diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h index d42818d140..f351ea811b 100644 --- a/src/gpu/GrTextureOpList.h +++ b/src/gpu/GrTextureOpList.h @@ -64,6 +64,8 @@ public: SkDEBUGCODE(virtual void validateTargetsSingleRenderTarget() const override;) + SkDEBUGCODE(int numOps() const override { return fRecordedOps.count(); }) + private: // MDB TODO: The unique IDs are only needed for the audit trail. There should only be one // on the opList itself. -- cgit v1.2.3