From 6db59a66bdcdad7e4c565e47c31437860455e832 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Fri, 2 Aug 2019 17:05:26 -0700 Subject: [HWUI] clean up libgui include directives As a first pass removing some stale includes. Bug: 138819035 Change-Id: I7aef319aa8f1b13b6482ef61fda151560e570558 Test: builds --- libs/hwui/renderthread/CacheManager.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 1b638c12ac7b..5469a6810c87 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 57bb0bfb4435bd214dffc9c38501781bdbd16f7d Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Fri, 6 Sep 2019 13:18:17 -0400 Subject: Switch to using GrContext::setResourceCacheLimit and getResourceCacheLimit The old version that took a maxResourceCount are now deprecated Test: does it compile Change-Id: Ib4d69c8907169329c7765c648f46fa5e4a10bf7a --- libs/hwui/renderthread/CacheManager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 5469a6810c87..fc268138e071 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -69,8 +69,7 @@ void CacheManager::reset(sk_sp context) { if (context) { mGrContext = std::move(context); - mGrContext->getResourceCacheLimits(&mMaxResources, nullptr); - mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes); + mGrContext->setResourceCacheLimit(mMaxResourceBytes); } } @@ -119,8 +118,8 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { // limits between the background and max amounts. This causes the unlocked resources // that have persistent data to be purged in LRU order. mGrContext->purgeUnlockedResources(true); - mGrContext->setResourceCacheLimits(mMaxResources, mBackgroundResourceBytes); - mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes); + mGrContext->setResourceCacheLimit(mBackgroundResourceBytes); + mGrContext->setResourceCacheLimit(mMaxResourceBytes); SkGraphics::SetFontCacheLimit(mBackgroundCpuFontCacheBytes); SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); break; -- cgit v1.2.3 From 8a207962ec84904a0fb8c7b5ce547ed2d1b59794 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 4 Oct 2019 13:30:51 -0700 Subject: Drop all caches in UI_HIDDEN Bug: 137853925 Test: none Change-Id: Idf7002d9b07cc6b71b38ce76e7b6382100279a99 --- libs/hwui/renderthread/CacheManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index fc268138e071..20e607dfe6c0 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -135,7 +135,7 @@ void CacheManager::trimStaleResources() { return; } mGrContext->flush(); - mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30)); + mGrContext->performDeferredCleanup(std::chrono::seconds(30)); } sp CacheManager::acquireVectorDrawableAtlas() { -- cgit v1.2.3 From 05ac51641297ae2cbe9b186b8c369f3a23a156b9 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 4 Oct 2019 13:47:55 -0700 Subject: Drop max texture cache size from 12x to 5x Bug: 137853925 Test: none Change-Id: I8d05871a5f54c8e5d6528a6a8ed48f73464a1221 --- libs/hwui/renderthread/CacheManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 20e607dfe6c0..dc07f0d84d18 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -39,7 +39,7 @@ namespace renderthread { // to the screen resolution. This is meant to be a conservative default based on // that analysis. The 4.0f is used because the default pixel format is assumed to // be ARGB_8888. -#define SURFACE_SIZE_MULTIPLIER (12.0f * 4.0f) +#define SURFACE_SIZE_MULTIPLIER (5.0f * 4.0f) #define BACKGROUND_RETENTION_PERCENTAGE (0.5f) CacheManager::CacheManager(const DisplayInfo& display) -- cgit v1.2.3 From 83161dcd6aa15c7da161b4ae561b06d20edd2510 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 4 Oct 2019 14:48:27 -0700 Subject: Delete VectorDrawableAtlas Poking around in a few apps it doesn't appear that the VectorDrawableAtlas is achieving sufficient utilization to justify its existence. The potential for draw call merging doesn't seem warranted for the RAM cost of the atlas. Bug: 137853925 Test: builds Change-Id: Id2419bc6dccb6316636d50c568f8fac75a2d563f --- libs/hwui/renderthread/CacheManager.cpp | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index fc268138e071..ab9b1e20a80d 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -56,10 +56,6 @@ CacheManager::CacheManager(const DisplayInfo& display) , mBackgroundCpuFontCacheBytes(mMaxCpuFontCacheBytes * BACKGROUND_RETENTION_PERCENTAGE) { SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); - - mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( - mMaxSurfaceArea / 2, - skiapipeline::VectorDrawableAtlas::StorageMode::disallowSharedSurface); } void CacheManager::reset(sk_sp context) { @@ -76,9 +72,6 @@ void CacheManager::reset(sk_sp context) { void CacheManager::destroy() { // cleanup any caches here as the GrContext is about to go away... mGrContext.reset(nullptr); - mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( - mMaxSurfaceArea / 2, - skiapipeline::VectorDrawableAtlas::StorageMode::disallowSharedSurface); } class CommonPoolExecutor : public SkExecutor { @@ -109,7 +102,6 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { switch (mode) { case TrimMemoryMode::Complete: - mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas(mMaxSurfaceArea / 2); mGrContext->freeGpuResources(); SkGraphics::PurgeAllCaches(); break; @@ -138,16 +130,6 @@ void CacheManager::trimStaleResources() { mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30)); } -sp CacheManager::acquireVectorDrawableAtlas() { - LOG_ALWAYS_FATAL_IF(mVectorDrawableAtlas.get() == nullptr); - LOG_ALWAYS_FATAL_IF(mGrContext == nullptr); - - /** - * TODO: define memory conditions where we clear the cache (e.g. surface->reset()) - */ - return mVectorDrawableAtlas; -} - void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) { if (!mGrContext) { log.appendFormat("No valid cache instance.\n"); @@ -176,8 +158,6 @@ void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) log.appendFormat("Other Caches:\n"); log.appendFormat(" Current / Maximum\n"); - log.appendFormat(" VectorDrawableAtlas %6.2f kB / %6.2f KB (entries = %zu)\n", 0.0f, 0.0f, - (size_t)0); if (renderState) { if (renderState->mActiveLayers.size() > 0) { -- cgit v1.2.3 From f846aeec9d87cb0cef58061d400efe3af7008903 Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 8 Oct 2019 23:28:41 +0000 Subject: Revert "Drop all caches in UI_HIDDEN" This reverts commit 8a207962ec84904a0fb8c7b5ce547ed2d1b59794. Bug: 142301356 Test: none, speculative Reason for revert: Seems to break alarm? Change-Id: Ia1680d1a937b596297c2eab3e54476daf9589347 --- libs/hwui/renderthread/CacheManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 20e607dfe6c0..fc268138e071 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -135,7 +135,7 @@ void CacheManager::trimStaleResources() { return; } mGrContext->flush(); - mGrContext->performDeferredCleanup(std::chrono::seconds(30)); + mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30)); } sp CacheManager::acquireVectorDrawableAtlas() { -- cgit v1.2.3 From 22d753f74d83bec10fc05a04156adaf76430d540 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Thu, 5 Sep 2019 17:11:45 -0700 Subject: [HWUI] Get DeviceInfo through stable ABI This also removes the dependency on ui/DeviceInfo other than in test code. Bug: 136263392 Bug: 136263238 Test: builds, boots Change-Id: I6a4687e981359f0e6beb83be8a5501ed7fd16f15 --- libs/hwui/renderthread/CacheManager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index dc07f0d84d18..b78c50a4b66d 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -16,6 +16,7 @@ #include "CacheManager.h" +#include "DeviceInfo.h" #include "Layer.h" #include "Properties.h" #include "RenderThread.h" @@ -42,8 +43,8 @@ namespace renderthread { #define SURFACE_SIZE_MULTIPLIER (5.0f * 4.0f) #define BACKGROUND_RETENTION_PERCENTAGE (0.5f) -CacheManager::CacheManager(const DisplayInfo& display) - : mMaxSurfaceArea(display.w * display.h) +CacheManager::CacheManager() + : mMaxSurfaceArea(DeviceInfo::getWidth() * DeviceInfo::getHeight()) , mMaxResourceBytes(mMaxSurfaceArea * SURFACE_SIZE_MULTIPLIER) , mBackgroundResourceBytes(mMaxResourceBytes * BACKGROUND_RETENTION_PERCENTAGE) // This sets the maximum size for a single texture atlas in the GPU font cache. If @@ -52,9 +53,9 @@ CacheManager::CacheManager(const DisplayInfo& display) , mMaxGpuFontAtlasBytes(GrNextSizePow2(mMaxSurfaceArea)) // This sets the maximum size of the CPU font cache to be at least the same size as the // total number of GPU font caches (i.e. 4 separate GPU atlases). - , mMaxCpuFontCacheBytes(std::max(mMaxGpuFontAtlasBytes*4, SkGraphics::GetFontCacheLimit())) + , mMaxCpuFontCacheBytes( + std::max(mMaxGpuFontAtlasBytes * 4, SkGraphics::GetFontCacheLimit())) , mBackgroundCpuFontCacheBytes(mMaxCpuFontCacheBytes * BACKGROUND_RETENTION_PERCENTAGE) { - SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( -- cgit v1.2.3 From e0fae2356b3ec531baec9f575c99a62ac4bfa004 Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Tue, 7 Jan 2020 17:21:49 -0500 Subject: Add memory tracing in HWUI Add ATRACE memory counters to track memory usage at the end of each frame in HWUI. There are 3 catagories: CPU, GPU and Texture memory. There are 3 more counters for memory that can be purged. This CL deletes GpuMemoryTracker class, which implemented similar function for Android O HWUI renderer. Test: Collected systrace with gmail and setting. Test: memory tracing adds ~0.1ms per frame when ATRACE is enabled Bug: 146580770 Change-Id: Icbcc0478bc426dff578e83726fe7c95df171ed93 --- libs/hwui/renderthread/CacheManager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index eaed46c44e5d..d177855e5a7d 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -20,10 +20,12 @@ #include "Layer.h" #include "Properties.h" #include "RenderThread.h" +#include "pipeline/skia/ATraceMemoryDump.h" #include "pipeline/skia/ShaderCache.h" #include "pipeline/skia/SkiaMemoryTracer.h" #include "renderstate/RenderState.h" #include "thread/CommonPool.h" +#include #include #include @@ -184,6 +186,18 @@ void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) gpuTracer.logTotals(log); } +void CacheManager::onFrameCompleted() { + if (ATRACE_ENABLED()) { + static skiapipeline::ATraceMemoryDump tracer; + tracer.startFrame(); + SkGraphics::DumpMemoryStatistics(&tracer); + if (mGrContext) { + mGrContext->dumpMemoryStatistics(&tracer); + } + tracer.logTraces(); + } +} + } /* namespace renderthread */ } /* namespace uirenderer */ } /* namespace android */ -- cgit v1.2.3 From 30d367873477c19e144206d38873471bc51414a8 Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Thu, 11 Jun 2020 15:22:36 +0000 Subject: Revert "Drop max texture cache size from 12x to 5x" Bug: 155002050 Test: Manual - scroll Pchome app This reverts commit 05ac51641297ae2cbe9b186b8c369f3a23a156b9. Reason for revert: When running Pchome, this change resulted in poor performance while scrolling. Every frame appears to be uploading several textures, potentially the same textures over and over again. Change-Id: I0fc7216e16f783051d1bd87af764c1a6f361c138 --- libs/hwui/renderthread/CacheManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index d177855e5a7d..1e5877356e8d 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -42,7 +42,7 @@ namespace renderthread { // to the screen resolution. This is meant to be a conservative default based on // that analysis. The 4.0f is used because the default pixel format is assumed to // be ARGB_8888. -#define SURFACE_SIZE_MULTIPLIER (5.0f * 4.0f) +#define SURFACE_SIZE_MULTIPLIER (12.0f * 4.0f) #define BACKGROUND_RETENTION_PERCENTAGE (0.5f) CacheManager::CacheManager() -- cgit v1.2.3