diff options
author | Greg Daniel <egdaniel@google.com> | 2017-11-08 19:58:51 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-08 19:58:58 +0000 |
commit | 065b41dd90782e22b5708c8b43696db641d54f46 (patch) | |
tree | 218278f670fb63274f6fbbcf68a6f99ad431029b /src/gpu/GrResourceAllocator.cpp | |
parent | 0078ab22519313be727ace05306333910768f58e (diff) |
Revert "Prepare to enable explicit gpu resource allocation"
This reverts commit f290376736b42a19b87da78c6ba2558313896860.
Reason for revert: Changed generated effect instead of FP
Original change's description:
> Prepare to enable explicit gpu resource allocation
>
> Change-Id: I407e45711c61831febbac3d3d3a88e3fdde92c5f
> Reviewed-on: https://skia-review.googlesource.com/68212
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,robertphillips@google.com
Change-Id: I949500d94c7461b7cf38d615117cfcdc9a791780
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/68900
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrResourceAllocator.cpp')
-rw-r--r-- | src/gpu/GrResourceAllocator.cpp | 119 |
1 files changed, 60 insertions, 59 deletions
diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp index f263802448..62f780b177 100644 --- a/src/gpu/GrResourceAllocator.cpp +++ b/src/gpu/GrResourceAllocator.cpp @@ -7,12 +7,8 @@ #include "GrResourceAllocator.h" -#include "GrGpuResourcePriv.h" -#include "GrResourceProvider.h" -#include "GrSurfacePriv.h" #include "GrSurfaceProxy.h" #include "GrSurfaceProxyPriv.h" -#include "GrTextureProxy.h" void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, unsigned int start, unsigned int end) { @@ -21,18 +17,15 @@ void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, if (Interval* intvl = fIntvlHash.find(proxy->uniqueID().asUInt())) { // Revise the interval for an existing use - // TODO: this assert is failing on the copy_on_write_retain GM! - //SkASSERT(intvl->end() <= start); - if (intvl->end() < end) { - intvl->extendEnd(end); - } + //SkASSERT(intvl->fEnd <= end); + intvl->fEnd = end; return; } Interval* newIntvl; if (fFreeIntervalList) { newIntvl = fFreeIntervalList; - fFreeIntervalList = newIntvl->next(); + fFreeIntervalList = newIntvl->fNext; newIntvl->resetTo(proxy, start, end); } else { newIntvl = fIntervalAllocator.make<Interval>(proxy, start, end); @@ -45,7 +38,7 @@ void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, GrResourceAllocator::Interval* GrResourceAllocator::IntervalList::popHead() { Interval* temp = fHead; if (temp) { - fHead = temp->next(); + fHead = temp->fNext; } return temp; } @@ -53,36 +46,36 @@ GrResourceAllocator::Interval* GrResourceAllocator::IntervalList::popHead() { // TODO: fuse this with insertByIncreasingEnd void GrResourceAllocator::IntervalList::insertByIncreasingStart(Interval* intvl) { if (!fHead) { - intvl->setNext(nullptr); + intvl->fNext = nullptr; fHead = intvl; - } else if (intvl->start() <= fHead->start()) { - intvl->setNext(fHead); + } else if (intvl->fStart <= fHead->fStart) { + intvl->fNext = fHead; fHead = intvl; } else { Interval* prev = fHead; - Interval* next = prev->next(); - for (; next && intvl->start() > next->start(); prev = next, next = next->next()) { + Interval* next = prev->fNext; + for (; next && intvl->fStart > next->fStart; prev = next, next = next->fNext) { } - intvl->setNext(next); - prev->setNext(intvl); + intvl->fNext = next; + prev->fNext = intvl; } } // TODO: fuse this with insertByIncreasingStart void GrResourceAllocator::IntervalList::insertByIncreasingEnd(Interval* intvl) { if (!fHead) { - intvl->setNext(nullptr); + intvl->fNext = nullptr; fHead = intvl; - } else if (intvl->end() <= fHead->end()) { - intvl->setNext(fHead); + } else if (intvl->fEnd <= fHead->fEnd) { + intvl->fNext = fHead; fHead = intvl; } else { Interval* prev = fHead; - Interval* next = prev->next(); - for (; next && intvl->end() > next->end(); prev = next, next = next->next()) { + Interval* next = prev->fNext; + for (; next && intvl->fEnd > next->fEnd; prev = next, next = next->fNext) { } - intvl->setNext(next); - prev->setNext(intvl); + intvl->fNext = next; + prev->fNext = intvl; } } @@ -94,15 +87,8 @@ void GrResourceAllocator::freeUpSurface(GrSurface* surface) { return; // can't do it w/o a valid scratch key } - if (surface->getUniqueKey().isValid()) { - // If the surface has a unique key we throw it back into the resource cache. - // If things get really tight 'findSurfaceFor' may pull it back out but there is - // no need to have it in tight rotation. - return; - } - // TODO: fix this insertion so we get a more LRU-ish behavior - fFreePool.insert(key, SkRef(surface)); + fFreePool.insert(key, surface); } // First try to reuse one of the recently allocated/used GrSurfaces in the free pool. @@ -114,19 +100,9 @@ sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy proxy->priv().computeScratchKey(&key); - auto filter = [&] (const GrSurface* s) { - return !proxy->priv().requiresNoPendingIO() || !s->surfacePriv().hasPendingIO(); - }; - sk_sp<GrSurface> surface(fFreePool.findAndRemove(key, filter)); + GrSurface* surface = fFreePool.find(key); if (surface) { - if (SkBudgeted::kYes == proxy->isBudgeted() && - SkBudgeted::kNo == surface->resourcePriv().isBudgeted()) { - // This gets the job done but isn't quite correct. It would be better to try to - // match budgeted proxies w/ budgeted surface and unbudgeted w/ unbudgeted. - surface->resourcePriv().makeBudgeted(); - } - - return surface; + return sk_ref_sp(surface); } // Failing that, try to grab a new one from the resource cache @@ -136,12 +112,12 @@ sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy // Remove any intervals that end before the current index. Return their GrSurfaces // to the free pool. void GrResourceAllocator::expire(unsigned int curIndex) { - while (!fActiveIntvls.empty() && fActiveIntvls.peekHead()->end() < curIndex) { + while (!fActiveIntvls.empty() && fActiveIntvls.peekHead()->fEnd < curIndex) { Interval* temp = fActiveIntvls.popHead(); - this->freeUpSurface(temp->proxy()->priv().peekSurface()); + this->freeUpSurface(temp->fProxy->priv().peekSurface()); // Add temp to the free interval list so it can be reused - temp->setNext(fFreeIntervalList); + temp->fNext = fFreeIntervalList; fFreeIntervalList = temp; } } @@ -151,26 +127,51 @@ void GrResourceAllocator::assign() { SkDEBUGCODE(fAssigned = true;) while (Interval* cur = fIntvlList.popHead()) { - this->expire(cur->start()); + this->expire(cur->fStart); - if (cur->proxy()->priv().isInstantiated()) { + if (cur->fProxy->priv().isInstantiated()) { fActiveIntvls.insertByIncreasingEnd(cur); continue; } // TODO: add over budget handling here? - sk_sp<GrSurface> surface = this->findSurfaceFor(cur->proxy()); + sk_sp<GrSurface> surface = this->findSurfaceFor(cur->fProxy); if (surface) { - // TODO: make getUniqueKey virtual on GrSurfaceProxy - GrTextureProxy* tex = cur->proxy()->asTextureProxy(); - if (tex && tex->getUniqueKey().isValid()) { - fResourceProvider->assignUniqueKeyToResource(tex->getUniqueKey(), surface.get()); - SkASSERT(surface->getUniqueKey() == tex->getUniqueKey()); - } - - cur->proxy()->priv().assign(std::move(surface)); + cur->fProxy->priv().assign(std::move(surface)); } // TODO: handle resouce allocation failure upstack fActiveIntvls.insertByIncreasingEnd(cur); } } + +#ifdef SK_DEBUG +void GrResourceAllocator::dump() { + unsigned int min = fNumOps+1; + unsigned int max = 0; + for(const Interval* cur = fIntvlList.peekHead(); cur; cur = cur->fNext) { + SkDebugf("{ %d,%d }: [%d, %d]\n", + cur->fProxy->uniqueID().asUInt(), cur->fProxy->underlyingUniqueID().asUInt(), + cur->fStart, cur->fEnd); + if (min > cur->fStart) { + min = cur->fStart; + } + if (max < cur->fEnd) { + max = cur->fEnd; + } + } + + for(const Interval* cur = fIntvlList.peekHead(); cur; cur = cur->fNext) { + SkDebugf("{ %3d,%3d }: ", + cur->fProxy->uniqueID().asUInt(), cur->fProxy->underlyingUniqueID().asUInt()); + for (unsigned int i = min; i <= max; ++i) { + if (i >= cur->fStart && i <= cur->fEnd) { + SkDebugf("x"); + } else { + SkDebugf(" "); + } + } + SkDebugf("\n"); + } +} +#endif + |