Add creation-time POD memory pool for GrOps
This CL begins pulling some of the work forward into onPrePrepare.
Change-Id: If049e0662db51b465b8b82aafebeef2323bddfd4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249802
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index 081b693..58eb8c5 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -8,6 +8,7 @@
#include "include/private/GrRecordingContext.h"
#include "include/gpu/GrContext.h"
+#include "src/core/SkArenaAlloc.h"
#include "src/gpu/GrAuditTrail.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDrawingManager.h"
@@ -115,6 +116,9 @@
return fDrawingManager.get();
}
+// This entry point exists bc the GrOpsTask (and SkAtlasTextTarget) take refs on the memory pool.
+// Ostensibly, this is to keep the op's data alive in DDL mode but the back pointer is also
+// used for deletion.
sk_sp<GrOpMemoryPool> GrRecordingContext::refOpMemoryPool() {
if (!fOpMemoryPool) {
// DDL TODO: should the size of the memory pool be decreased in DDL mode? CPU-side memory
@@ -131,6 +135,22 @@
return this->refOpMemoryPool().get();
}
+// Stored in this arena:
+// GrTextureOp's DynamicStateArrays and FixedDynamicState
+SkArenaAlloc* GrRecordingContext::opPODAllocator() {
+ if (!fOpPODAllocator) {
+ // TODO: empirically determine a better number for SkArenaAlloc's firstHeapAllocation param
+ fOpPODAllocator = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(sizeof(GrPipeline) * 100));
+ }
+
+ SkASSERT(fOpPODAllocator);
+ return fOpPODAllocator.get();
+}
+
+std::unique_ptr<SkArenaAlloc> GrRecordingContext::detachOpPOD() {
+ return std::move(fOpPODAllocator);
+}
+
GrTextBlobCache* GrRecordingContext::getTextBlobCache() {
return fTextBlobCache.get();
}
@@ -302,6 +322,10 @@
return fContext->refCaps();
}
+std::unique_ptr<SkArenaAlloc> GrRecordingContextPriv::detachOpPOD() {
+ return fContext->detachOpPOD();
+}
+
sk_sp<GrSkSLFPFactoryCache> GrRecordingContextPriv::fpFactoryCache() {
return fContext->fpFactoryCache();
}