graphite: Reset UniformDataCache on recording snap
UniformDataCache grows unbounded and causes a memory leak with cases
like motionmark leaves - GPU proces memory grows to several GBs before
Chrome grinds to a halt. Reset it on recording snap to keep it from
growing too large.
UniformDataCache is used to deduplicate uniform data blocks uploaded to
uniform/storage buffers for a DrawPass pipeline. It should be ok to
reset it on recording snap since it's only used per DrawPass at the
moment.
Bug: b/274004065
Change-Id: I8367ff18e08d70d2f59f0811737ebfe6f05a20a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/715996
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/graphite/PipelineDataCache.h b/src/gpu/graphite/PipelineDataCache.h
index b520f1d..c670316 100644
--- a/src/gpu/graphite/PipelineDataCache.h
+++ b/src/gpu/graphite/PipelineDataCache.h
@@ -78,7 +78,8 @@
SkArenaAlloc fArena{0};
};
-// A UniformDataCache lives for the entire duration of a Recorder.
+// A UniformDataCache only lives for a single Recording. It's used to deduplicate uniform data
+// blocks uploaded to uniform/storage buffers for a DrawPass pipeline.
using UniformDataCache = PipelineDataCache<UniformDataBlock>;
// A TextureDataCache only lives for a single Recording. When a Recording is snapped it is pulled
diff --git a/src/gpu/graphite/Recorder.cpp b/src/gpu/graphite/Recorder.cpp
index f15047a..dcaef51 100644
--- a/src/gpu/graphite/Recorder.cpp
+++ b/src/gpu/graphite/Recorder.cpp
@@ -161,7 +161,7 @@
fDrawBufferManager.reset(new DrawBufferManager(fResourceProvider.get(),
fSharedContext->caps()));
fTextureDataCache = std::make_unique<TextureDataCache>();
- // We leave the UniformDataCache alone
+ fUniformDataCache = std::make_unique<UniformDataCache>();
fGraph->reset();
fRuntimeEffectDict->reset();
return nullptr;
@@ -185,6 +185,7 @@
fGraph = std::make_unique<TaskGraph>();
fRuntimeEffectDict->reset();
fTextureDataCache = std::make_unique<TextureDataCache>();
+ fUniformDataCache = std::make_unique<UniformDataCache>();
// inject an initial task to maintain atlas state for next Recording
auto uploads = std::make_unique<UploadList>();