aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawOpAtlas.cpp
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2018-02-16 18:41:41 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-17 00:11:27 +0000
commitcad0acf4db5b03f9b9bf6afedde162fd1c8c4c92 (patch)
tree3dcf5959a84ed60a1fb5de64e46e413eea12d6f1 /src/gpu/GrDrawOpAtlas.cpp
parentdfc0e910dfdf7ad11995d357e44c029d839f2e73 (diff)
Fix thrashing issue with multitextured atlas.
To try to reduce memory usage, the atlas will look for space in the earliest created pages and then invalidate plots in the latest page to try to move those plots into an earlier one. The problem was that the available space was not being evicted, so we kept loading data back into the latest page. Bug: skia: Change-Id: Ic8668f6f66bf1153dbcb5edae7622fa9edfa71dd Reviewed-on: https://skia-review.googlesource.com/98801 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrDrawOpAtlas.cpp')
-rw-r--r--src/gpu/GrDrawOpAtlas.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index b2780e6635..0f18325817 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -371,7 +371,7 @@ void GrDrawOpAtlas::compact(GrDeferredUploadToken startTokenForNextFlush) {
// a blinking cursor is drawn.
// TODO: consider if we should also do this if it's been a long time since the last atlas use
if (atlasUsedThisFlush) {
- int availablePlots = 0;
+ SkTArray<Plot*> availablePlots;
uint32_t lastPageIndex = fNumPages - 1;
// For all plots but the last one, update number of flushes since used, and check to see
@@ -400,7 +400,7 @@ void GrDrawOpAtlas::compact(GrDeferredUploadToken startTokenForNextFlush) {
// Count plots we can potentially upload to in all pages except the last one
// (the potential compactee).
if (plot->flushesSinceLastUsed() > kRecentlyUsedCount) {
- ++availablePlots;
+ availablePlots.push_back() = plot;
}
plotIter.next();
@@ -439,9 +439,10 @@ void GrDrawOpAtlas::compact(GrDeferredUploadToken startTokenForNextFlush) {
// see if there's room in an earlier page and if so evict.
// We need to be somewhat harsh here so that one plot that is consistently in use
// doesn't end up locking the page in memory.
- if (availablePlots) {
+ if (availablePlots.count() > 0) {
this->processEvictionAndResetRects(plot);
- --availablePlots;
+ this->processEvictionAndResetRects(availablePlots.back());
+ availablePlots.pop_back();
}
} else if (plot->lastUseToken() != GrDeferredUploadToken::AlreadyFlushedToken()) {
// otherwise if aged out just evict it.