Add debug memory tracking to SkiaGLPipeline
Test: Sample output is below
D/OpenGLRenderer: Resource Cache Usage:
D/OpenGLRenderer: 32 items out of 8192 maximum items
D/OpenGLRenderer: 4635572 bytes (4.42 MB) out of 96.00 MB maximum
This is less verbose than OpenGL memory debug output for
two reasons:
(1) SkiaGL has less caches.
(2) SkiaGL does not support printing on cache additions/evictions.
This seems like more of an internal debugging tool rather than
a user-facing debug feature. I think it's best to leave this
unimplemented until we find that it might be useful.
BUG:32370375
Change-Id: Ib063f1c2a7f88e9840341b1001d227f556d88f26
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index 494f14d..7d4cf42 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -95,6 +95,11 @@
profileCanvas->flush();
}
+ // Log memory statistics
+ if (CC_UNLIKELY(Properties::debugLevel != kDebugDisabled)) {
+ dumpResourceCacheUsage();
+ }
+
return true;
}
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
index 03fa266..1b50531 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp
@@ -253,6 +253,20 @@
canvas->flush();
}
+void SkiaPipeline::dumpResourceCacheUsage() const {
+ int resources, maxResources;
+ size_t bytes, maxBytes;
+ mRenderThread.getGrContext()->getResourceCacheUsage(&resources, &bytes);
+ mRenderThread.getGrContext()->getResourceCacheLimits(&maxResources, &maxBytes);
+
+ SkString log("Resource Cache Usage:\n");
+ log.appendf("%8d items out of %d maximum items\n", resources, maxResources);
+ log.appendf("%8zu bytes (%.2f MB) out of %.2f MB maximum\n",
+ bytes, bytes * (1.0f / (1024.0f * 1024.0f)), maxBytes * (1.0f / (1024.0f * 1024.0f)));
+
+ ALOGD("%s", log.c_str());
+}
+
} /* namespace skiapipeline */
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.h b/libs/hwui/pipeline/skia/SkiaPipeline.h
index 160046a..a16fabf 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.h
@@ -96,7 +96,10 @@
mSpotShadowAlpha = lightInfo.spotShadowAlpha;
mLightCenter = lightGeometry.center;
}
+
protected:
+ void dumpResourceCacheUsage() const;
+
renderthread::RenderThread& mRenderThread;
private:
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
index 8fffe91..da8f504 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
@@ -81,6 +81,11 @@
profileCanvas->flush();
}
+ // Log memory statistics
+ if (CC_UNLIKELY(Properties::debugLevel != kDebugDisabled)) {
+ dumpResourceCacheUsage();
+ }
+
return true;
}