Add debug-only helper methods to get #ops & #clips per opList
authorRobert Phillips <robertphillips@google.com>
Mon, 8 May 2017 19:35:11 +0000 (15:35 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 9 May 2017 17:31:23 +0000 (17:31 +0000)
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 <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>

src/gpu/GrOpList.h
src/gpu/GrRenderTargetContext.cpp
src/gpu/GrRenderTargetOpList.cpp
src/gpu/GrRenderTargetOpList.h
src/gpu/GrTextureContext.cpp
src/gpu/GrTextureOpList.cpp
src/gpu/GrTextureOpList.h

index b354abed762fd704d4c4dc3823a00ad15a16e0bd..54a13e1d911217359a7027971d49ddb9fb2e02c7 100644 (file)
@@ -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;
index f81dc46255ca288542c6d3b1a540219991857b6a..7de1f8dddf94c4badfe0c26a72ac9a5be00702db 100644 (file)
@@ -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) {
index 9920cfd8f7b435d9206e681a5341494f2880b63d..a9f4351a777292886cdff12b903fcb75e7adbb0d 100644 (file)
@@ -29,7 +29,9 @@ static const int kMaxOpLookahead = 10;
 GrRenderTargetOpList::GrRenderTargetOpList(sk_sp<GrRenderTargetProxy> 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<GrOp> op,
     GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op);
     if (clip) {
         clip = fClipAllocator.make<GrAppliedClip>(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());
index 342f9278d5d932844ea541e9df35e55ed38b9217..21dd70e01b06a92f0bcf2515a6745bd2c49be914 100644 (file)
@@ -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;
 };
index 68e94f9be377356bc488879ddafc28c025702479..fb8e79584e55fa2e4354c4173342a6746eda0a4c 100644 (file)
@@ -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
index 689ea4478348226c961b6c76c8c5f9d7727dcbd4..97a4bbf05e2ae32174ece363d126e9aca332c6ef 100644 (file)
@@ -81,6 +81,7 @@ void GrTextureOpList::reset() {
 
 ////////////////////////////////////////////////////////////////////////////////
 
+// MDB TODO: fuse with GrRenderTargetOpList::copySurface
 bool GrTextureOpList::copySurface(GrResourceProvider* resourceProvider,
                                   GrSurfaceProxy* dst,
                                   GrSurfaceProxy* src,
index d42818d140f6bf4dfd534898421912d177ade053..f351ea811b87e769b89e233f0e1d9e9b40f01511 100644 (file)
@@ -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.