mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +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 #7724: Guards don't help vs werewolves
|
||||
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 #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
|
||||
|
|
|
@ -165,6 +165,15 @@ namespace
|
|||
private:
|
||||
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()
|
||||
|
@ -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 unsigned int frameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
||||
const osg::Timer* const timer = osg::Timer::instance();
|
||||
osg::Stats* const stats = mViewer->getViewerStats();
|
||||
|
||||
|
@ -1021,7 +1029,9 @@ void OMW::Engine::go()
|
|||
|
||||
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));
|
||||
continue;
|
||||
|
@ -1035,16 +1045,16 @@ void OMW::Engine::go()
|
|||
|
||||
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;
|
||||
const auto frameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
||||
if (frameNumber >= statsReportDelay)
|
||||
{
|
||||
const unsigned reportFrameNumber = frameNumber - statsReportDelay;
|
||||
mViewer->getViewerStats()->report(stats, reportFrameNumber);
|
||||
osgViewer::Viewer::Cameras cameras;
|
||||
mViewer->getCameras(cameras);
|
||||
for (auto camera : cameras)
|
||||
camera->getStats()->report(stats, reportFrameNumber);
|
||||
// Viewer frame number can be different from frameNumber because of loading screens which render new
|
||||
// frames inside a simulation frame.
|
||||
const unsigned currentFrameNumber = mViewer->getFrameStamp()->getFrameNumber();
|
||||
for (unsigned i = frameNumber; i <= currentFrameNumber; ++i)
|
||||
reportStats(i - statsReportDelay, *mViewer, stats);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace OMW
|
|||
|
||||
void executeLocalScripts();
|
||||
|
||||
bool frame(float dt);
|
||||
bool frame(unsigned frameNumber, float dt);
|
||||
|
||||
/// Prepare engine for game play
|
||||
void prepareEngine();
|
||||
|
|
Loading…
Reference in a new issue