summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Greg Daniel <egdaniel@google.com> 2019-04-17 12:18:50 -0400
committer Greg Daniel <egdaniel@google.com> 2019-04-22 13:43:06 +0000
commit1d857f03f70cf20a523f95fc5085e4e6e0b61492 (patch)
tree638f6e8c6266be5997acaa7c50c2462fee7b7e72
parentfc0f0ea6903ee69c6b077ec3236980b928f9acdb (diff)
Make sure to sync GPU after deleting memory in trimMemory.
On GL some devices may not delete gpu memory immediately after calling delete and instead will just queue it up. We must call glFinish to make sure the memory is deleted when we want it. More importantly Vulkan memory will not be freed until the GPU is done with all the work. Thus we require an additional flush to make sure the previous gpu work we submitted has finished and we can delete the memory. Test: manual testing on device Bug: b/130440975 Change-Id: I2a9202dd7d15d97b365120a8caf9e10b4100efc3
-rw-r--r--libs/hwui/renderthread/CacheManager.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index 7cb241d22668..1b638c12ac7b 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -126,6 +126,10 @@ void CacheManager::trimMemory(TrimMemoryMode mode) {
SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes);
break;
}
+
+ // We must sync the cpu to make sure deletions of resources still queued up on the GPU actually
+ // happen.
+ mGrContext->flush(kSyncCpu_GrFlushFlag, 0, nullptr);
}
void CacheManager::trimStaleResources() {