Determine recylability at expire-time in GrResourceAllocator
The detachAll function was unused before this CL. Gone!
This also removes the late-check of canSkipResourceAllocator
on the premise that, these days it seems impossible for that
value to change between addInterval, where the first check is,
and assign, where the current check is.
All path renderers work on my machine, will also run this against
the Nexus7 and AndroidOne bots.
Bug: skia:10877
Change-Id: Ife63ca2fb8e7c94c2053dbc10c42df18c48c0c20
Cq-Include-Trybots: luci.skia.skia.primary:Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Debug-All-Android,Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-All-Android,Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-All-Android,Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-All-Android
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385278
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp
index f271f4e..848665b 100644
--- a/src/gpu/GrResourceAllocator.cpp
+++ b/src/gpu/GrResourceAllocator.cpp
@@ -28,21 +28,6 @@
}
#endif
-void GrResourceAllocator::determineRecyclability() {
- for (Interval* cur = fIntvlList.peekHead(); cur; cur = cur->next()) {
- if (cur->proxy()->canSkipResourceAllocator()) {
- // These types of proxies can slip in here if they require a stencil buffer
- continue;
- }
-
- if (!cur->proxy()->refCntGreaterThan(cur->uses())) {
- // All the refs on the proxy are known to the resource allocator thus no one
- // should be holding onto it outside of Ganesh.
- cur->markAsRecyclable();
- }
- }
-}
-
GrResourceAllocator::~GrResourceAllocator() {
SkASSERT(fIntvlList.empty());
SkASSERT(fActiveIntvls.empty());
@@ -74,8 +59,8 @@
}
uint32_t proxyID = proxy->uniqueID().asUInt();
if (Interval** intvlPtr = fIntvlHash.find(proxyID)) {
- Interval* intvl = *intvlPtr;
// Revise the interval for an existing use
+ Interval* intvl = *intvlPtr;
#ifdef SK_DEBUG
if (0 == start && 0 == end) {
// This interval is for the initial upload to a deferred proxy. Due to the vagaries
@@ -105,6 +90,12 @@
fIntvlHash.set(proxyID, newIntvl);
}
+bool GrResourceAllocator::Interval::isSurfaceRecyclable() const {
+ // All the refs on the proxy are known to the resource allocator thus no one
+ // should be holding onto it outside of Ganesh.
+ return !fProxy->refCntGreaterThan(fUses);
+}
+
GrResourceAllocator::Interval* GrResourceAllocator::IntervalList::popHead() {
SkDEBUGCODE(this->validate());
@@ -195,13 +186,6 @@
}
#endif
- GrResourceAllocator::Interval* GrResourceAllocator::IntervalList::detachAll() {
- Interval* tmp = fHead;
- fHead = nullptr;
- fTail = nullptr;
- return tmp;
-}
-
// 'surface' can be reused. Add it back to the free pool.
void GrResourceAllocator::recycleSurface(sk_sp<GrSurface> surface) {
const GrScratchKey &key = surface->resourcePriv().getScratchKey();
@@ -267,7 +251,7 @@
SkASSERT(!intvl->next());
if (GrSurface* surf = intvl->proxy()->peekSurface()) {
- if (intvl->isRecyclable()) {
+ if (intvl->isSurfaceRecyclable()) {
this->recycleSurface(sk_ref_sp(surf));
}
}
@@ -288,11 +272,7 @@
this->dumpIntervals();
#endif
- // TODO: Can this be done inline during the main iteration?
- this->determineRecyclability();
-
- Interval* cur = nullptr;
- while ((cur = fIntvlList.popHead())) {
+ while (Interval* cur = fIntvlList.popHead()) {
this->expire(cur->start());
if (cur->proxy()->isInstantiated()) {