Create cache for the tiles so we don't have to recreate them each frame

This commit is contained in:
Ylva Selling
2023-02-02 12:38:33 -05:00
parent 4e9fcbbd8d
commit c3a94577e8
2 changed files with 12 additions and 2 deletions

View File

@@ -245,8 +245,15 @@ Tile VideoTileProvider::tile(const TileIndex& tileIndex) {
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
LINFO("Framebuffer is not complete");
}
return Tile{ _frameTexture.get(), std::nullopt, Tile::Status::OK};
uint64_t hash = tileIndex.hashKey();
if (_tileCache.find(hash) == _tileCache.end()) {
_tileCache[hash] = Tile{
_frameTexture.get(),
std::nullopt,
Tile::Status::OK
};
}
return _tileCache[hash];
}
Tile::Status VideoTileProvider::tileStatus(const TileIndex& tileIndex) {

View File

@@ -132,6 +132,9 @@ private:
static int _wakeup;
bool _didRender = false;
bool _isPaused = false;
// Cache for rendering the same frame
std::map<TileIndex::TileHashKey, Tile> _tileCache;
};
} // namespace openspace::globebrowsing