Merge pull request #2272 from akortunov/optimize_terrain

Do not block loading while compiling composite maps
pull/541/head
Bret Curtis 6 years ago committed by GitHub
commit 5e12073b47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,8 +47,6 @@ void CompositeMapRenderer::drawImplementation(osg::RenderInfo &renderInfo) const
double availableTime = std::max((targetFrameTime - dt)*conservativeTimeRatio, double availableTime = std::max((targetFrameTime - dt)*conservativeTimeRatio,
mMinimumTimeAvailable); mMinimumTimeAvailable);
mCompiled.clear();
if (mWorkQueue) if (mWorkQueue)
mUnrefQueue->flush(mWorkQueue.get()); mUnrefQueue->flush(mWorkQueue.get());
@ -59,26 +57,30 @@ void CompositeMapRenderer::drawImplementation(osg::RenderInfo &renderInfo) const
while (!mImmediateCompileSet.empty()) while (!mImmediateCompileSet.empty())
{ {
CompositeMap* node = *mImmediateCompileSet.begin(); osg::ref_ptr<CompositeMap> node = *mImmediateCompileSet.begin();
mCompiled.insert(node); mImmediateCompileSet.erase(node);
mMutex.unlock();
compile(*node, renderInfo, nullptr); compile(*node, renderInfo, nullptr);
mMutex.lock();
mImmediateCompileSet.erase(mImmediateCompileSet.begin());
} }
double timeLeft = availableTime; double timeLeft = availableTime;
while (!mCompileSet.empty() && timeLeft > 0) while (!mCompileSet.empty() && timeLeft > 0)
{ {
CompositeMap* node = *mCompileSet.begin(); osg::ref_ptr<CompositeMap> node = *mCompileSet.begin();
mCompileSet.erase(node);
mMutex.unlock();
compile(*node, renderInfo, &timeLeft); compile(*node, renderInfo, &timeLeft);
mMutex.lock();
if (node->mCompiled >= node->mDrawables.size()) if (node->mCompiled < node->mDrawables.size())
{ {
mCompiled.insert(node); // We did not compile the map fully.
mCompileSet.erase(mCompileSet.begin()); // Place it back to queue to continue work in the next time.
mCompileSet.insert(node);
} }
} }
mTimer.setStartTick(); mTimer.setStartTick();

@ -76,8 +76,6 @@ namespace Terrain
mutable CompileSet mCompileSet; mutable CompileSet mCompileSet;
mutable CompileSet mImmediateCompileSet; mutable CompileSet mImmediateCompileSet;
mutable CompileSet mCompiled;
mutable OpenThreads::Mutex mMutex; mutable OpenThreads::Mutex mMutex;
osg::ref_ptr<osg::FrameBufferObject> mFBO; osg::ref_ptr<osg::FrameBufferObject> mFBO;

Loading…
Cancel
Save