forked from teamnwah/openmw-tes3coop
Use IncrementalCompileOperation to incrementally upload OpenGL objects during the loading screen
For now, not much difference, but should result in a sizable speed up once MyGUI no longer needs the DYNAMIC flag (i.e. the loading screen truly renders in the background).
This commit is contained in:
parent
37e3118d21
commit
9de575ad42
6 changed files with 41 additions and 5 deletions
|
@ -391,8 +391,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
mEnvironment.setJournal (new MWDialogue::Journal);
|
||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage));
|
||||
|
||||
//mOgre->getRoot()->addFrameListener (this);
|
||||
|
||||
// scripts
|
||||
if (mCompileAll)
|
||||
{
|
||||
|
@ -466,13 +464,12 @@ void OMW::Engine::go()
|
|||
mViewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
mViewer->addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
mViewer->realize();
|
||||
osg::Timer frameTimer;
|
||||
while (!mViewer->done() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
|
||||
{
|
||||
double dt = frameTimer.time_s();
|
||||
frameTimer.setStartTick();
|
||||
//dt = std::min(dt, 0.2f);
|
||||
//dt = std::min(dt, 0.2);
|
||||
|
||||
frame(dt);
|
||||
mViewer->frame(/*simulationTime*/);
|
||||
|
|
|
@ -30,8 +30,9 @@ namespace MWGui
|
|||
: WindowBase("openmw_loading_screen.layout")
|
||||
, mVFS(vfs)
|
||||
, mViewer(viewer)
|
||||
, mLastRenderTime(0.0)
|
||||
, mLastWallpaperChangeTime(0.0)
|
||||
, mLastRenderTime(0.0)
|
||||
, mLoadingOnTime(0.0)
|
||||
, mProgress(0)
|
||||
, mVSyncWasEnabled(false)
|
||||
{
|
||||
|
@ -97,6 +98,7 @@ namespace MWGui
|
|||
|
||||
void LoadingScreen::loadingOn()
|
||||
{
|
||||
mLoadingOnTime = mTimer.time_m();
|
||||
// Early-out if already on
|
||||
if (mMainWidget->getVisible())
|
||||
return;
|
||||
|
@ -143,6 +145,7 @@ namespace MWGui
|
|||
|
||||
void LoadingScreen::loadingOff()
|
||||
{
|
||||
//std::cout << "loading took " << mTimer.time_m() - mLoadingOnTime << std::endl;
|
||||
setVisible(false);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Loading);
|
||||
|
@ -215,6 +218,8 @@ namespace MWGui
|
|||
changeWallpaper();
|
||||
}
|
||||
|
||||
mViewer->getIncrementalCompileOperation()->setMaximumNumOfObjectsToCompilePerFrame(80);
|
||||
|
||||
// Turn off rendering except the GUI
|
||||
int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask();
|
||||
int oldCullMask = mViewer->getCamera()->getCullMask();
|
||||
|
@ -223,6 +228,8 @@ namespace MWGui
|
|||
|
||||
MWBase::Environment::get().getInputManager()->update(0, true, true);
|
||||
|
||||
//std::cout << "num to compile " << mViewer->getIncrementalCompileOperation()->getToCompile().size() << std::endl;
|
||||
|
||||
mViewer->frame();
|
||||
|
||||
// resume 3d rendering
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace MWGui
|
|||
double mLastWallpaperChangeTime;
|
||||
double mLastRenderTime;
|
||||
osg::Timer mTimer;
|
||||
double mLoadingOnTime;
|
||||
|
||||
size_t mProgress;
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <osg/Geode>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
|
||||
#include <osgUtil/IncrementalCompileOperation>
|
||||
|
||||
#include <osgParticle/ParticleSystem>
|
||||
#include <osgParticle/ParticleProcessor>
|
||||
|
||||
|
@ -78,6 +80,11 @@ Objects::~Objects()
|
|||
mCellSceneNodes.clear();
|
||||
}
|
||||
|
||||
void Objects::setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation *ico)
|
||||
{
|
||||
mIncrementalCompileOperation = ico;
|
||||
}
|
||||
|
||||
void Objects::insertBegin(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> cellnode;
|
||||
|
@ -108,6 +115,9 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool
|
|||
|
||||
std::auto_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, allowLight));
|
||||
|
||||
if (mIncrementalCompileOperation && anim->getObjectRoot())
|
||||
mIncrementalCompileOperation->add(anim->getObjectRoot());
|
||||
|
||||
if (!allowLight)
|
||||
{
|
||||
RemoveParticlesVisitor visitor;
|
||||
|
@ -130,6 +140,9 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b
|
|||
else
|
||||
anim.reset(new CreatureAnimation(ptr, mesh, mResourceSystem));
|
||||
|
||||
if (mIncrementalCompileOperation && anim->getObjectRoot())
|
||||
mIncrementalCompileOperation->add(anim->getObjectRoot());
|
||||
|
||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||
}
|
||||
|
||||
|
@ -139,6 +152,9 @@ void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
|||
|
||||
std::auto_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem, 0));
|
||||
|
||||
if (mIncrementalCompileOperation && anim->getObjectRoot())
|
||||
mIncrementalCompileOperation->add(anim->getObjectRoot());
|
||||
|
||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ namespace osg
|
|||
class Group;
|
||||
}
|
||||
|
||||
namespace osgUtil
|
||||
{
|
||||
class IncrementalCompileOperation;
|
||||
}
|
||||
|
||||
namespace Resource
|
||||
{
|
||||
class ResourceSystem;
|
||||
|
@ -41,10 +46,14 @@ class Objects{
|
|||
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
|
||||
osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;
|
||||
|
||||
public:
|
||||
Objects(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> rootNode);
|
||||
~Objects();
|
||||
|
||||
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation* ico);
|
||||
|
||||
/// @param animated Attempt to load separate keyframes from a .kf file matching the model file?
|
||||
/// @param allowLight If false, no lights will be created, and particles systems will be removed.
|
||||
void insertModel(const MWWorld::Ptr& ptr, const std::string &model, bool animated=false, bool allowLight=true);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <osg/Group>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
|
||||
#include <osgUtil/IncrementalCompileOperation>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <components/resource/resourcesystem.hpp>
|
||||
|
@ -95,6 +97,10 @@ namespace MWRender
|
|||
|
||||
mObjects.reset(new Objects(mResourceSystem, lightRoot));
|
||||
|
||||
mViewer.setIncrementalCompileOperation(new osgUtil::IncrementalCompileOperation);
|
||||
|
||||
mObjects->setIncrementalCompileOperation(mViewer.getIncrementalCompileOperation());
|
||||
|
||||
mEffectManager.reset(new EffectManager(mRootNode, mResourceSystem));
|
||||
|
||||
mViewer.setLightingMode(osgViewer::View::NO_LIGHT);
|
||||
|
|
Loading…
Reference in a new issue