mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-01 16:29:43 -05:00
1 Thread for Tile loading, allowing MaxConnections concurrent connections per RasterIO
This commit is contained in:
@@ -69,6 +69,11 @@ namespace openspace {
|
||||
return ChunkIndex(newX, newY, level);
|
||||
}
|
||||
|
||||
int ChunkIndex::manhattan(const ChunkIndex& other) const {
|
||||
ghoul_assert(level == other.level, "makes no sense if not on same level");
|
||||
return std::abs(x - other.x) + std::abs(y - other.y);
|
||||
}
|
||||
|
||||
HashKey ChunkIndex::hashKey() const {
|
||||
return x ^ (y << 16) ^ (level << 24);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ struct ChunkIndex {
|
||||
*/
|
||||
ChunkIndex getRelatedTile(int deltaX, int deltaY) const;
|
||||
|
||||
int manhattan(const ChunkIndex& other) const;
|
||||
|
||||
HashKey hashKey() const;
|
||||
|
||||
bool operator==(const ChunkIndex& other) const;
|
||||
|
||||
@@ -31,7 +31,8 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ThreadPool TileProviderManager::tileRequestThreadPool(5);
|
||||
ThreadPool TileProviderManager::tileRequestThreadPool(1);
|
||||
|
||||
|
||||
TileProviderManager::TileProviderManager()
|
||||
{
|
||||
|
||||
@@ -79,16 +79,13 @@ namespace openspace {
|
||||
}
|
||||
|
||||
std::shared_ptr<RawTileData> tileData = nullptr;
|
||||
//if (worstError <= CE_Warning) {
|
||||
tileData = createRawTileData(region, dataLayout, imageData);
|
||||
//}
|
||||
|
||||
std::shared_ptr<TileIOResult> result(new TileIOResult);
|
||||
result->error = worstError;
|
||||
result->rawTileData = tileData;
|
||||
|
||||
return result;
|
||||
//return tileData;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -64,7 +64,6 @@ namespace openspace {
|
||||
|
||||
bool TileProvider::hasInitializedGDAL = false;
|
||||
|
||||
ThreadPool TileProvider::threadPool(1);
|
||||
|
||||
|
||||
TileProvider::TileProvider(
|
||||
@@ -216,14 +215,23 @@ namespace openspace {
|
||||
|
||||
bool TileProvider::enqueueTileRequest(const ChunkIndex& chunkIndex) {
|
||||
HashKey key = chunkIndex.hashKey();
|
||||
bool tileHasBeenQueued = _queuedTileRequests.find(key) != _queuedTileRequests.end();
|
||||
if (!tileHasBeenQueued) {
|
||||
std::shared_ptr<TextureTileLoadJob> job = std::shared_ptr<TextureTileLoadJob>(
|
||||
new TextureTileLoadJob(this, chunkIndex));
|
||||
_tileLoadManager.enqueueJob(job);
|
||||
_queuedTileRequests.insert(key);
|
||||
auto it = _queuedTileRequests.begin();
|
||||
auto end = _queuedTileRequests.end();
|
||||
for (; it != end; it++) {
|
||||
const ChunkIndex& otherChunk = it->second;
|
||||
if (chunkIndex.level == otherChunk.level &&
|
||||
chunkIndex.manhattan(otherChunk) < 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !tileHasBeenQueued;
|
||||
|
||||
|
||||
std::shared_ptr<TextureTileLoadJob> job = std::shared_ptr<TextureTileLoadJob>(
|
||||
new TextureTileLoadJob(this, chunkIndex));
|
||||
_tileLoadManager.enqueueJob(job);
|
||||
_queuedTileRequests[key] = chunkIndex;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace openspace {
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRUCache<HashKey, MetaTexture> _tileCache;
|
||||
std::set<HashKey> _queuedTileRequests;
|
||||
std::unordered_map<HashKey, ChunkIndex> _queuedTileRequests;
|
||||
|
||||
int _framesSinceLastRequestFlush;
|
||||
int _framesUntilRequestFlush;
|
||||
|
||||
@@ -54,7 +54,7 @@ Fragment getFragment() {
|
||||
//frag.color = frag.color * 0.9 + 0.2*vec4(samplePos, 0, 1);
|
||||
|
||||
// Border overlay
|
||||
frag.color = frag.color + patchBorderOverlay(fs_uv, vec3(0.5, 0.5, 0.5), 0.02);
|
||||
//frag.color = frag.color + patchBorderOverlay(fs_uv, vec3(0.5, 0.5, 0.5), 0.02);
|
||||
|
||||
frag.depth = fs_position.w;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ Fragment getFragment() {
|
||||
//frag.color = frag.color * 0.9 + 0.2*vec4(samplePos, 0, 1);
|
||||
|
||||
// Border overlay
|
||||
frag.color = frag.color + patchBorderOverlay(fs_uv, vec3(0.5, 0.5, 0.5), 0.02);
|
||||
//frag.color = frag.color + patchBorderOverlay(fs_uv, vec3(0.5, 0.5, 0.5), 0.02);
|
||||
|
||||
frag.depth = fs_position.w;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user