From 047d5bb8d39cd9dd320cf2c238dcf864809dc7dc Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Fri, 8 Jan 2021 13:39:19 -0500 Subject: [PATCH] Improve flush-time op spew (esp. for DDL tasks) This CL also centralizes how the SkSurfaceProxy is output. Change-Id: Ibdba1535e65ef21ce206778a8d757ee341334ec0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352081 Reviewed-by: Adlai Holler Commit-Queue: Robert Phillips --- src/gpu/GrDDLTask.cpp | 29 +++++++++++++++++++++++++--- src/gpu/GrDDLTask.h | 5 ++++- src/gpu/GrDrawingManager.cpp | 4 +++- src/gpu/GrOpsTask.cpp | 36 ++++++++++++++++++++++------------- src/gpu/GrOpsTask.h | 5 ++++- src/gpu/GrRenderTask.cpp | 32 +++++++++++++++++++------------ src/gpu/GrRenderTask.h | 5 ++++- src/gpu/GrResourceAllocator.h | 8 ++++---- src/gpu/GrSurfaceProxy.cpp | 11 +++++++++++ src/gpu/GrSurfaceProxy.h | 1 + src/gpu/ops/GrTextureOp.cpp | 15 +++++++-------- 11 files changed, 107 insertions(+), 44 deletions(-) diff --git a/src/gpu/GrDDLTask.cpp b/src/gpu/GrDDLTask.cpp index a6be087095..57f8dcec08 100644 --- a/src/gpu/GrDDLTask.cpp +++ b/src/gpu/GrDDLTask.cpp @@ -106,11 +106,34 @@ bool GrDDLTask::onExecute(GrOpFlushState* flushState) { } #if GR_TEST_UTILS -void GrDDLTask::dump(bool printDependencies) const { - INHERITED::dump(printDependencies); +void GrDDLTask::dump(const SkString& label, + SkString indent, + bool printDependencies, + bool close) const { + INHERITED::dump(label, indent, printDependencies, false); + SkDebugf("%sDDL Target: ", indent.c_str()); + if (fDDLTarget) { + SkString proxyStr = fDDLTarget->dump(); + SkDebugf("%s", proxyStr.c_str()); + } + SkDebugf("\n"); + + SkDebugf("%s%d sub-tasks\n", indent.c_str(), fDDL->priv().numRenderTasks()); + + SkString subIndent(indent); + subIndent.append(" "); + + int index = 0; for (auto& task : fDDL->priv().renderTasks()) { - task->dump(printDependencies); + SkString subLabel; + subLabel.printf("sub-task %d/%d", index++, fDDL->priv().numRenderTasks()); + task->dump(subLabel, subIndent, printDependencies, true); + } + + if (close) { + SkDebugf("%s--------------------------------------------------------------\n\n", + indent.c_str()); } } #endif diff --git a/src/gpu/GrDDLTask.h b/src/gpu/GrDDLTask.h index e87717ee09..820799eb3f 100644 --- a/src/gpu/GrDDLTask.h +++ b/src/gpu/GrDDLTask.h @@ -59,7 +59,10 @@ private: bool onExecute(GrOpFlushState*) override; #if GR_TEST_UTILS - void dump(bool printDependencies) const final; + void dump(const SkString& label, + SkString indent, + bool printDependencies, + bool close) const final; const char* name() const final { return "DDL"; } #endif #ifdef SK_DEBUG diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 8ca4553cb6..d6eee6caca 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -303,7 +303,9 @@ bool GrDrawingManager::executeRenderTasks(int startIndex, int stopIndex, GrOpFlu startIndex, stopIndex, 0, fDAG.count()); for (int i = startIndex; i < stopIndex; ++i) { if (fDAG[i]) { - fDAG[i]->dump(true); + SkString label; + label.printf("task %d/%d", i, fDAG.count()); + fDAG[i]->dump(label, {}, true, true); } } #endif diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp index 59a66b2855..7a20c9ae03 100644 --- a/src/gpu/GrOpsTask.cpp +++ b/src/gpu/GrOpsTask.cpp @@ -692,10 +692,13 @@ void GrOpsTask::discard() { //////////////////////////////////////////////////////////////////////////////// #if GR_TEST_UTILS -void GrOpsTask::dump(bool printDependencies) const { - GrRenderTask::dump(printDependencies); +void GrOpsTask::dump(const SkString& label, + SkString indent, + bool printDependencies, + bool close) const { + GrRenderTask::dump(label, indent, printDependencies, false); - SkDebugf("fColorLoadOp: "); + SkDebugf("%sfColorLoadOp: ", indent.c_str()); switch (fColorLoadOp) { case GrLoadOp::kLoad: SkDebugf("kLoad\n"); @@ -712,7 +715,7 @@ void GrOpsTask::dump(bool printDependencies) const { break; } - SkDebugf("fInitialStencilContent: "); + SkDebugf("%sfInitialStencilContent: ", indent.c_str()); switch (fInitialStencilContent) { case StencilContent::kDontCare: SkDebugf("kDontCare\n"); @@ -725,25 +728,32 @@ void GrOpsTask::dump(bool printDependencies) const { break; } - SkDebugf("ops (%d):\n", fOpChains.count()); + SkDebugf("%s%d ops:\n", indent.c_str(), fOpChains.count()); for (int i = 0; i < fOpChains.count(); ++i) { - SkDebugf("*******************************\n"); + SkDebugf("%s*******************************\n", indent.c_str()); if (!fOpChains[i].head()) { - SkDebugf("%d: \n", i); + SkDebugf("%s%d: \n", indent.c_str(), i); } else { - SkDebugf("%d: %s\n", i, fOpChains[i].head()->name()); + SkDebugf("%s%d: %s\n", indent.c_str(), i, fOpChains[i].head()->name()); SkRect bounds = fOpChains[i].bounds(); - SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", bounds.fLeft, - bounds.fTop, bounds.fRight, bounds.fBottom); + SkDebugf("%sClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", + indent.c_str(), + bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); for (const auto& op : GrOp::ChainRange<>(fOpChains[i].head())) { SkString info = SkTabString(op.dumpInfo(), 1); - SkDebugf("%s\n", info.c_str()); + SkDebugf("%s%s\n", indent.c_str(), info.c_str()); bounds = op.bounds(); - SkDebugf("\tClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", bounds.fLeft, - bounds.fTop, bounds.fRight, bounds.fBottom); + SkDebugf("%s\tClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", + indent.c_str(), + bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); } } } + + if (close) { + SkDebugf("%s--------------------------------------------------------------\n\n", + indent.c_str()); + } } #endif diff --git a/src/gpu/GrOpsTask.h b/src/gpu/GrOpsTask.h index c0448f4100..baad64005a 100644 --- a/src/gpu/GrOpsTask.h +++ b/src/gpu/GrOpsTask.h @@ -95,7 +95,10 @@ public: #endif #if GR_TEST_UTILS - void dump(bool printDependencies) const override; + void dump(const SkString& label, + SkString indent, + bool printDependencies, + bool close) const override; const char* name() const final { return "Ops"; } int numOpChains() const { return fOpChains.count(); } const GrOp* getChain(int index) const { return fOpChains[index].head(); } diff --git a/src/gpu/GrRenderTask.cpp b/src/gpu/GrRenderTask.cpp index b1a4b159f4..0c24d50514 100644 --- a/src/gpu/GrRenderTask.cpp +++ b/src/gpu/GrRenderTask.cpp @@ -282,34 +282,42 @@ void GrRenderTask::addTarget(GrDrawingManager* drawingMgr, GrSurfaceProxyView vi } #if GR_TEST_UTILS -void GrRenderTask::dump(bool printDependencies) const { - SkDebugf("--------------------------------------------------------------\n"); - SkDebugf("%s - renderTaskID: %d\n", this->name(), fUniqueID); +void GrRenderTask::dump(const SkString& label, + SkString indent, + bool printDependencies, + bool close) const { + SkDebugf("%s%s --------------------------------------------------------------\n", + indent.c_str(), + label.c_str()); + SkDebugf("%s%s task - renderTaskID: %d\n", indent.c_str(), this->name(), fUniqueID); if (!fTargets.empty()) { - SkDebugf("Targets: \n"); + SkDebugf("%sTargets: \n", indent.c_str()); for (const GrSurfaceProxyView& target : fTargets) { - GrSurfaceProxy* proxy = target.proxy(); - SkDebugf("proxyID: %d - surfaceID: %d\n", - proxy ? proxy->uniqueID().asUInt() : -1, - proxy && proxy->peekSurface() - ? proxy->peekSurface()->uniqueID().asUInt() - : -1); + if (target.proxy()) { + SkString proxyStr = target.proxy()->dump(); + SkDebugf("%s%s\n", indent.c_str(), proxyStr.c_str()); + } } } if (printDependencies) { - SkDebugf("I rely On (%d): ", fDependencies.count()); + SkDebugf("%sI rely On (%d): ", indent.c_str(), fDependencies.count()); for (int i = 0; i < fDependencies.count(); ++i) { SkDebugf("%d, ", fDependencies[i]->fUniqueID); } SkDebugf("\n"); - SkDebugf("(%d) Rely On Me: ", fDependents.count()); + SkDebugf("%s(%d) Rely On Me: ", indent.c_str(), fDependents.count()); for (int i = 0; i < fDependents.count(); ++i) { SkDebugf("%d, ", fDependents[i]->fUniqueID); } SkDebugf("\n"); } + + if (close) { + SkDebugf("%s--------------------------------------------------------------\n\n", + indent.c_str()); + } } #endif diff --git a/src/gpu/GrRenderTask.h b/src/gpu/GrRenderTask.h index 4b23b71500..701e7b72d1 100644 --- a/src/gpu/GrRenderTask.h +++ b/src/gpu/GrRenderTask.h @@ -84,7 +84,10 @@ public: /* * Dump out the GrRenderTask dependency DAG */ - virtual void dump(bool printDependencies) const; + virtual void dump(const SkString& label, + SkString indent, + bool printDependencies, + bool close) const; virtual const char* name() const = 0; #endif diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h index ec9eab2047..bf9d0ca0f0 100644 --- a/src/gpu/GrResourceAllocator.h +++ b/src/gpu/GrResourceAllocator.h @@ -146,8 +146,8 @@ private: SkASSERT(proxy); #if GR_TRACK_INTERVAL_CREATION fUniqueID = CreateUniqueID(); - SkDebugf("New intvl %d: proxyID: %d [ %d, %d ]\n", - fUniqueID, proxy->uniqueID().asUInt(), start, end); + SkString proxyStr = proxy->dump(); + SkDebugf("New intvl %d: %s [%d, %d]\n", fUniqueID, proxyStr.c_str(), start, end); #endif } @@ -164,8 +164,8 @@ private: fNext = nullptr; #if GR_TRACK_INTERVAL_CREATION fUniqueID = CreateUniqueID(); - SkDebugf("New intvl %d: proxyID: %d [ %d, %d ]\n", - fUniqueID, proxy->uniqueID().asUInt(), start, end); + SkString proxyStr = proxy->dump(); + SkDebugf("New intvl %d: %s [ %d, %d ]\n", fUniqueID, proxyStr.c_str(), start, end); #endif } diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index 7719dc97ec..fea4e70159 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -336,6 +336,17 @@ int32_t GrSurfaceProxy::testingOnly_getBackingRefCnt() const { GrInternalSurfaceFlags GrSurfaceProxy::testingOnly_getFlags() const { return fSurfaceFlags; } + +SkString GrSurfaceProxy::dump() const { + SkString tmp; + + tmp.appendf("proxyID: %d - surfaceID: %d", + this->uniqueID().asUInt(), + this->peekSurface() ? this->peekSurface()->uniqueID().asUInt() + : -1); + return tmp; +} + #endif void GrSurfaceProxyPriv::exactify(bool allocatedCaseOnly) { diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h index 9a73ccc416..1ac26a1a9d 100644 --- a/src/gpu/GrSurfaceProxy.h +++ b/src/gpu/GrSurfaceProxy.h @@ -318,6 +318,7 @@ public: #if GR_TEST_UTILS int32_t testingOnly_getBackingRefCnt() const; GrInternalSurfaceFlags testingOnly_getFlags() const; + SkString dump() const; #endif SkDEBUGCODE(void validate(GrContext_Base*) const;) diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 1274cf16a3..c27a8b6bb0 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -622,8 +622,9 @@ private: DrawQuad extra; // Only clip when there's anti-aliasing. When non-aa, the GPU clips just fine and there's // no inset/outset math that requires w > 0. - int quadCount = quad->fEdgeFlags != GrQuadAAFlags::kNone ? - GrQuadUtils::ClipToW0(quad, &extra) : 1; + int quadCount = quad->fEdgeFlags != GrQuadAAFlags::kNone + ? GrQuadUtils::ClipToW0(quad, &extra) + : 1; if (quadCount == 0) { // We can't discard the op at this point, but disable AA flags so it won't go through // inset/outset processing @@ -1061,12 +1062,12 @@ private: SkString str = SkStringPrintf("# draws: %d\n", fQuads.count()); auto iter = fQuads.iterator(); for (unsigned p = 0; p < fMetadata.fProxyCount; ++p) { - str.appendf("Proxy ID: %d, Filter: %d, MM: %d\n", - fViewCountPairs[p].fProxy->uniqueID().asUInt(), + SkString proxyStr = fViewCountPairs[p].fProxy->dump(); + str.append(proxyStr); + str.appendf(", Filter: %d, MM: %d\n", static_cast(fMetadata.fFilter), static_cast(fMetadata.fMipmapMode)); - int i = 0; - while(i < fViewCountPairs[p].fQuadCnt && iter.next()) { + for (int i = 0; i < fViewCountPairs[p].fQuadCnt && iter.next(); ++i) { const GrQuad* quad = iter.deviceQuad(); GrQuad uv = iter.isLocalValid() ? *(iter.localQuad()) : GrQuad(); const ColorSubsetAndAA& info = iter.metadata(); @@ -1080,8 +1081,6 @@ private: quad->point(2).fX, quad->point(2).fY, quad->point(3).fX, quad->point(3).fY, uv.point(0).fX, uv.point(0).fY, uv.point(1).fX, uv.point(1).fY, uv.point(2).fX, uv.point(2).fY, uv.point(3).fX, uv.point(3).fY); - - i++; } } return str;