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 <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrDDLTask.cpp b/src/gpu/GrDDLTask.cpp
index a6be087..57f8dce 100644
--- a/src/gpu/GrDDLTask.cpp
+++ b/src/gpu/GrDDLTask.cpp
@@ -106,11 +106,34 @@
}
#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 e87717e..820799e 100644
--- a/src/gpu/GrDDLTask.h
+++ b/src/gpu/GrDDLTask.h
@@ -59,7 +59,10 @@
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 8ca4553..d6eee6c 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -303,7 +303,9 @@
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 59a66b2..7a20c9a 100644
--- a/src/gpu/GrOpsTask.cpp
+++ b/src/gpu/GrOpsTask.cpp
@@ -692,10 +692,13 @@
////////////////////////////////////////////////////////////////////////////////
#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 @@
break;
}
- SkDebugf("fInitialStencilContent: ");
+ SkDebugf("%sfInitialStencilContent: ", indent.c_str());
switch (fInitialStencilContent) {
case StencilContent::kDontCare:
SkDebugf("kDontCare\n");
@@ -725,25 +728,32 @@
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: <combined forward or failed instantiation>\n", i);
+ SkDebugf("%s%d: <combined forward or failed instantiation>\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 c0448f4..baad640 100644
--- a/src/gpu/GrOpsTask.h
+++ b/src/gpu/GrOpsTask.h
@@ -95,7 +95,10 @@
#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 b1a4b15..0c24d50 100644
--- a/src/gpu/GrRenderTask.cpp
+++ b/src/gpu/GrRenderTask.cpp
@@ -282,34 +282,42 @@
}
#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 4b23b71..701e7b7 100644
--- a/src/gpu/GrRenderTask.h
+++ b/src/gpu/GrRenderTask.h
@@ -84,7 +84,10 @@
/*
* 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 ec9eab2..bf9d0ca 100644
--- a/src/gpu/GrResourceAllocator.h
+++ b/src/gpu/GrResourceAllocator.h
@@ -146,8 +146,8 @@
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 @@
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 7719dc9..fea4e70 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -336,6 +336,17 @@
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 9a73ccc..1ac26a1 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -318,6 +318,7 @@
#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 1274cf1..c27a8b6 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -622,8 +622,9 @@
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 @@
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<int>(fMetadata.fFilter),
static_cast<int>(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 @@
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;