mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 17:59:56 +00:00
Report osg stats for all frames showing loading screens
This commit is contained in:
parent
b4976354a5
commit
41d5d3bf09
3 changed files with 22 additions and 11 deletions
|
@ -145,6 +145,7 @@
|
||||||
Bug #7723: Assaulting vampires and werewolves shouldn't be a crime
|
Bug #7723: Assaulting vampires and werewolves shouldn't be a crime
|
||||||
Bug #7724: Guards don't help vs werewolves
|
Bug #7724: Guards don't help vs werewolves
|
||||||
Bug #7733: Launcher shows incorrect data paths when there's two plugins with the same name
|
Bug #7733: Launcher shows incorrect data paths when there's two plugins with the same name
|
||||||
|
Bug #7737: OSG stats are missing some data on loading screens
|
||||||
Bug #7742: Governing attribute training limit should use the modified attribute
|
Bug #7742: Governing attribute training limit should use the modified attribute
|
||||||
Bug #7753: Editor: Actors Don't Scale According to Their Race
|
Bug #7753: Editor: Actors Don't Scale According to Their Race
|
||||||
Bug #7758: Water walking is not taken into account to compute path cost on the water
|
Bug #7758: Water walking is not taken into account to compute path cost on the water
|
||||||
|
|
|
@ -165,6 +165,15 @@ namespace
|
||||||
private:
|
private:
|
||||||
int mMaxTextureImageUnits = 0;
|
int mMaxTextureImageUnits = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void reportStats(unsigned frameNumber, osgViewer::Viewer& viewer, std::ostream& stream)
|
||||||
|
{
|
||||||
|
viewer.getViewerStats()->report(stream, frameNumber);
|
||||||
|
osgViewer::Viewer::Cameras cameras;
|
||||||
|
viewer.getCameras(cameras);
|
||||||
|
for (osg::Camera* camera : cameras)
|
||||||
|
camera->getStats()->report(stream, frameNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::executeLocalScripts()
|
void OMW::Engine::executeLocalScripts()
|
||||||
|
@ -180,10 +189,9 @@ void OMW::Engine::executeLocalScripts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OMW::Engine::frame(float frametime)
|
bool OMW::Engine::frame(unsigned frameNumber, float frametime)
|
||||||
{
|
{
|
||||||
const osg::Timer_t frameStart = mViewer->getStartTick();
|
const osg::Timer_t frameStart = mViewer->getStartTick();
|
||||||
const unsigned int frameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
|
||||||
const osg::Timer* const timer = osg::Timer::instance();
|
const osg::Timer* const timer = osg::Timer::instance();
|
||||||
osg::Stats* const stats = mViewer->getViewerStats();
|
osg::Stats* const stats = mViewer->getViewerStats();
|
||||||
|
|
||||||
|
@ -1021,7 +1029,9 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
mViewer->advance(timeManager.getRenderingSimulationTime());
|
mViewer->advance(timeManager.getRenderingSimulationTime());
|
||||||
|
|
||||||
if (!frame(dt))
|
const unsigned frameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
||||||
|
|
||||||
|
if (!frame(frameNumber, dt))
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
continue;
|
continue;
|
||||||
|
@ -1035,16 +1045,16 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
if (stats)
|
if (stats)
|
||||||
{
|
{
|
||||||
|
// The delay is required because rendering happens in parallel to the main thread and stats from there is
|
||||||
|
// available with delay.
|
||||||
constexpr unsigned statsReportDelay = 3;
|
constexpr unsigned statsReportDelay = 3;
|
||||||
const auto frameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
|
||||||
if (frameNumber >= statsReportDelay)
|
if (frameNumber >= statsReportDelay)
|
||||||
{
|
{
|
||||||
const unsigned reportFrameNumber = frameNumber - statsReportDelay;
|
// Viewer frame number can be different from frameNumber because of loading screens which render new
|
||||||
mViewer->getViewerStats()->report(stats, reportFrameNumber);
|
// frames inside a simulation frame.
|
||||||
osgViewer::Viewer::Cameras cameras;
|
const unsigned currentFrameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
||||||
mViewer->getCameras(cameras);
|
for (unsigned i = frameNumber; i <= currentFrameNumber; ++i)
|
||||||
for (auto camera : cameras)
|
reportStats(i - statsReportDelay, *mViewer, stats);
|
||||||
camera->getStats()->report(stats, reportFrameNumber);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ namespace OMW
|
||||||
|
|
||||||
void executeLocalScripts();
|
void executeLocalScripts();
|
||||||
|
|
||||||
bool frame(float dt);
|
bool frame(unsigned frameNumber, float dt);
|
||||||
|
|
||||||
/// Prepare engine for game play
|
/// Prepare engine for game play
|
||||||
void prepareEngine();
|
void prepareEngine();
|
||||||
|
|
Loading…
Reference in a new issue