-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct and revise OpenGL texture pooling (#2709)
- Loading branch information
Showing
79 changed files
with
817 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
|
||
#include <list> | ||
#include <stdexcept> | ||
#include <unordered_map> | ||
|
||
namespace mbgl { | ||
|
||
// Simple non-thread-safe LRU cache | ||
template <typename Item, typename Hash = std::hash<Item>> | ||
class LRU { | ||
public: | ||
// Number of cached items | ||
size_t size() const { return list.size(); } | ||
|
||
// Check if cache is empty | ||
bool empty() const { return list.empty(); } | ||
|
||
// Access x | ||
// If x is already cached, move it to the front (most recently used) | ||
void touch(Item x) { | ||
auto it = map.find(x); | ||
if (it != map.end()) { | ||
list.splice(list.begin(), list, it->second); | ||
} else { | ||
list.push_front(x); | ||
map[std::move(x)] = list.begin(); | ||
} | ||
} | ||
|
||
// Evict the least recently used item | ||
// If the cache is empty, throw an exception | ||
Item evict() { | ||
if (list.empty()) { | ||
throw std::runtime_error("LRU::evict: empty cache"); | ||
} | ||
Item x = std::move(list.back()); | ||
map.erase(x); | ||
list.pop_back(); | ||
return x; | ||
} | ||
|
||
// Check if item exists in cache without changing its order | ||
bool isHit(const Item& x) const { return map.find(std::move(x)) != map.end(); } | ||
|
||
// remove item from cache if it exists | ||
void remove(const Item& x) { | ||
auto it = map.find(x); | ||
if (it != map.end()) { | ||
list.erase(it->second); | ||
map.erase(it); | ||
} | ||
} | ||
|
||
private: | ||
std::list<Item> list; | ||
std::unordered_map<Item, typename std::list<Item>::iterator, Hash> map; | ||
}; | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
15, | ||
1, | ||
[ | ||
147712, | ||
147712 | ||
164096, | ||
164096 | ||
], | ||
[ | ||
130, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
51, | ||
1, | ||
[ | ||
53024, | ||
53024 | ||
53032, | ||
53032 | ||
], | ||
[ | ||
43734, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
17, | ||
1, | ||
[ | ||
125574, | ||
125574 | ||
191110, | ||
191110 | ||
], | ||
[ | ||
454, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
46, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
8, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
46, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
9, | ||
1, | ||
[ | ||
22784, | ||
22784 | ||
29184, | ||
29184 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
5, | ||
1, | ||
[ | ||
22784, | ||
22784 | ||
25088, | ||
25088 | ||
], | ||
[ | ||
22, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
94, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
9, | ||
1, | ||
[ | ||
33768, | ||
33768 | ||
50702, | ||
50702 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
9, | ||
1, | ||
[ | ||
22080, | ||
22080 | ||
27776, | ||
27776 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
5, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
114688, | ||
114688 | ||
], | ||
[ | ||
22, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
5, | ||
1, | ||
[ | ||
65536, | ||
65536 | ||
81920, | ||
81920 | ||
], | ||
[ | ||
22, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
9, | ||
1, | ||
[ | ||
21264, | ||
21264 | ||
42528, | ||
42528 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
17, | ||
1, | ||
[ | ||
163840, | ||
163840 | ||
196608, | ||
196608 | ||
], | ||
[ | ||
118, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
65536, | ||
65536 | ||
], | ||
[ | ||
82, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
9, | ||
1, | ||
[ | ||
24576, | ||
24576 | ||
46656, | ||
46656 | ||
], | ||
[ | ||
34, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
46, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
7, | ||
1, | ||
[ | ||
32768, | ||
32768 | ||
49152, | ||
49152 | ||
], | ||
[ | ||
46, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
32, | ||
4, | ||
[ | ||
158509, | ||
158509 | ||
321286, | ||
321286 | ||
], | ||
[ | ||
712, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
60, | ||
4, | ||
[ | ||
131780, | ||
131780 | ||
230615, | ||
230615 | ||
], | ||
[ | ||
102328, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
9, | ||
1, | ||
[ | ||
215688, | ||
215688 | ||
281224, | ||
281224 | ||
], | ||
[ | ||
58, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
36, | ||
4, | ||
[ | ||
143344, | ||
143344 | ||
250852, | ||
250852 | ||
], | ||
[ | ||
194056, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
52, | ||
4, | ||
[ | ||
296872, | ||
296872 | ||
685542, | ||
685542 | ||
], | ||
[ | ||
79084, | ||
|
Oops, something went wrong.