aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceAllocator.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-11-16 07:52:08 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-16 16:35:57 +0000
commiteafd48af63aef270cbea139547bb4fa8a591748d (patch)
treec59febed663b2e00ab9af5eb8ad239a3efded290 /src/gpu/GrResourceAllocator.h
parent5627d65146cb92624b682389e017d488872228c7 (diff)
Add overbudget handling to GrResourceAllocator
Change-Id: I5536c908310e907c77b5d55441a0edac6a74bf0e Reviewed-on: https://skia-review.googlesource.com/71182 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrResourceAllocator.h')
-rw-r--r--src/gpu/GrResourceAllocator.h39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h
index 2f0b00ed72..f576649030 100644
--- a/src/gpu/GrResourceAllocator.h
+++ b/src/gpu/GrResourceAllocator.h
@@ -45,7 +45,7 @@ public:
void incOps() { fNumOps++; }
unsigned int numOps() const { return fNumOps; }
- // Add a usage interval from start to end inclusive. This is usually used for renderTargets.
+ // Add a usage interval from 'start' to 'end' inclusive. This is usually used for renderTargets.
// If an existing interval already exists it will be expanded to include the new range.
void addInterval(GrSurfaceProxy*, unsigned int start, unsigned int end);
@@ -55,7 +55,13 @@ public:
this->addInterval(proxy, fNumOps, fNumOps);
}
- void assign();
+ // Returns true when the opLists from 'startIndex' to 'stopIndex' should be executed;
+ // false when nothing remains to be executed.
+ // This is used to execute a portion of the queued opLists in order to reduce the total
+ // amount of GPU resources required.
+ bool assign(int* startIndex, int* stopIndex);
+
+ void markEndOfOpList(int opListIndex);
private:
class Interval;
@@ -65,7 +71,7 @@ private:
// These two methods wrap the interactions with the free pool
void freeUpSurface(sk_sp<GrSurface> surface);
- sk_sp<GrSurface> findSurfaceFor(const GrSurfaceProxy* proxy);
+ sk_sp<GrSurface> findSurfaceFor(const GrSurfaceProxy* proxy, bool needsStencil);
struct FreePoolTraits {
static const GrScratchKey& GetKey(const GrSurface& s) {
@@ -128,8 +134,6 @@ private:
}
static uint32_t Hash(const uint32_t& key) { return key; }
-
-
private:
sk_sp<GrSurface> fAssignedSurface;
GrSurfaceProxy* fProxy;
@@ -160,19 +164,22 @@ private:
// Gathered statistics indicate that 99% of flushes will be covered by <= 12 Intervals
static const int kInitialArenaSize = 12 * sizeof(Interval);
- GrResourceProvider* fResourceProvider;
- FreePoolMultiMap fFreePool; // Recently created/used GrSurfaces
- IntvlHash fIntvlHash; // All the intervals, hashed by proxyID
+ GrResourceProvider* fResourceProvider;
+ FreePoolMultiMap fFreePool; // Recently created/used GrSurfaces
+ IntvlHash fIntvlHash; // All the intervals, hashed by proxyID
+
+ IntervalList fIntvlList; // All the intervals sorted by increasing start
+ IntervalList fActiveIntvls; // List of live intervals during assignment
+ // (sorted by increasing end)
+ unsigned int fNumOps = 0;
+ SkTArray<unsigned int> fEndOfOpListOpIndices;
+ int fCurOpListIndex = 0;
- IntervalList fIntvlList; // All the intervals sorted by increasing start
- IntervalList fActiveIntvls; // List of live intervals during assignment
- // (sorted by increasing end)
- unsigned int fNumOps = 0;
- SkDEBUGCODE(bool fAssigned = false;)
+ SkDEBUGCODE(bool fAssigned = false;)
- char fStorage[kInitialArenaSize];
- SkArenaAlloc fIntervalAllocator { fStorage, kInitialArenaSize, 0 };
- Interval* fFreeIntervalList = nullptr;
+ char fStorage[kInitialArenaSize];
+ SkArenaAlloc fIntervalAllocator { fStorage, kInitialArenaSize, 0 };
+ Interval* fFreeIntervalList = nullptr;
};
#endif // GrResourceAllocator_DEFINED