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>
This commit is contained in:
Robert Phillips 2021-01-08 13:39:19 -05:00 committed by Skia Commit-Bot
parent e0403a4102
commit 047d5bb8d3
11 changed files with 107 additions and 44 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: <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

View File

@ -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(); }

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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) {

View File

@ -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;)

View File

@ -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<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 @@ 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;