Skip to content

Commit

Permalink
Fixup ::computeLoadProgress to take RequestDispatcher into account
Browse files Browse the repository at this point in the history
  • Loading branch information
csciguy8 committed Nov 8, 2023
1 parent 90999f5 commit c56f2f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class RequestDispatcher {

void TakeCompletedWork(size_t maxCount, std::vector<TileLoadWork>& out);

size_t GetNumberOfRequestsPending();

private:
void dispatchRequest(TileLoadWork& request);
void stageRequestWork(
Expand Down
19 changes: 13 additions & 6 deletions Cesium3DTilesSelection/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,17 @@ float Tileset::computeLoadProgress() noexcept {
this->_pTilesetContentManager->getNumberOfTilesLoading();
int32_t numOfTilesLoaded =
this->_pTilesetContentManager->getNumberOfTilesLoaded();
int32_t numOfTilesKicked =
static_cast<int32_t>(this->_updateResult.tilesKicked);
int32_t numOfRequestsPending =
(int32_t)this->_requestDispatcher.GetNumberOfRequestsPending();

// Amount of work actively being done
int32_t inProgressSum = numOfTilesLoading + queueSizeSum;
int32_t inProgressSum =
queueSizeSum + numOfRequestsPending + numOfTilesLoading;

// Total work so far. Add already loaded tiles and kicked tiles.
// Kicked tiles are transient, and never in progress, but are an indicator
// that there is more work to do next frame.
int32_t totalNum = inProgressSum + numOfTilesLoaded + numOfTilesKicked;
int32_t totalNum = inProgressSum + numOfTilesLoaded;
float percentage =
static_cast<float>(numOfTilesLoaded) / static_cast<float>(totalNum);
return (percentage * 100.f);
Expand Down Expand Up @@ -1621,7 +1622,7 @@ void Tileset::discoverLoadWork(
size_t workIndex, endIndex = parsedTileWork.size();
for (workIndex = 0; workIndex < endIndex; ++workIndex) {
TilesetContentManager::ParsedTileWork& work = parsedTileWork[workIndex];
maxDepth = std::max (maxDepth, work.depthIndex);
maxDepth = std::max(maxDepth, work.depthIndex);
}

// Add all the work, biasing priority by depth
Expand All @@ -1635,7 +1636,7 @@ void Tileset::discoverLoadWork(
work.requestUrl,
work.projections,
loadRequest.group,
loadRequest.priority + priorityBias };
loadRequest.priority + priorityBias};

checkNotAdded(newWorkUnit, outRequests);

Expand Down Expand Up @@ -1818,6 +1819,12 @@ void RequestDispatcher::stageRequestWork(
}
}

size_t RequestDispatcher::GetNumberOfRequestsPending() {
std::lock_guard<std::mutex> lock(_requestsLock);
return _queuedRequests.size() + _requestsInFlight.size() +
_doneRequests.size();
}

void RequestDispatcher::TakeCompletedWork(
size_t maxCount,
std::vector<TileLoadWork>& out) {
Expand Down

0 comments on commit c56f2f1

Please sign in to comment.