1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 13:20:35 +00:00

Report CellPreloader stats

This commit is contained in:
elsid 2023-12-21 22:38:45 +01:00
parent 9a24e77d3f
commit ae41ebfc83
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
6 changed files with 44 additions and 1 deletions

View File

@ -4,6 +4,8 @@
#include <atomic> #include <atomic>
#include <limits> #include <limits>
#include <osg/Stats>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm3/loadcell.hpp> #include <components/esm3/loadcell.hpp>
#include <components/loadinglistener/reporter.hpp> #include <components/loadinglistener/reporter.hpp>
@ -276,6 +278,7 @@ namespace MWWorld
{ {
oldestCell->second.mWorkItem->abort(); oldestCell->second.mWorkItem->abort();
mPreloadCells.erase(oldestCell); mPreloadCells.erase(oldestCell);
++mEvicted;
} }
else else
return; return;
@ -285,7 +288,8 @@ namespace MWWorld
mResourceSystem->getKeyframeManager(), mTerrain, mLandManager, mPreloadInstances)); mResourceSystem->getKeyframeManager(), mTerrain, mLandManager, mPreloadInstances));
mWorkQueue->addWorkItem(item); mWorkQueue->addWorkItem(item);
mPreloadCells[&cell] = PreloadEntry(timestamp, item); mPreloadCells.emplace(&cell, PreloadEntry(timestamp, item));
++mAdded;
} }
void CellPreloader::notifyLoaded(CellStore* cell) void CellPreloader::notifyLoaded(CellStore* cell)
@ -300,6 +304,7 @@ namespace MWWorld
} }
mPreloadCells.erase(found); mPreloadCells.erase(found);
++mLoaded;
} }
} }
@ -329,6 +334,7 @@ namespace MWWorld
it->second.mWorkItem = nullptr; it->second.mWorkItem = nullptr;
} }
mPreloadCells.erase(it++); mPreloadCells.erase(it++);
++mExpired;
} }
else else
++it; ++it;
@ -467,4 +473,12 @@ namespace MWWorld
mPreloadCells.clear(); mPreloadCells.clear();
} }
void CellPreloader::reportStats(unsigned int frameNumber, osg::Stats& stats) const
{
stats.setAttribute(frameNumber, "CellPreloader Count", mPreloadCells.size());
stats.setAttribute(frameNumber, "CellPreloader Added", mAdded);
stats.setAttribute(frameNumber, "CellPreloader Evicted", mEvicted);
stats.setAttribute(frameNumber, "CellPreloader Loaded", mLoaded);
stats.setAttribute(frameNumber, "CellPreloader Expired", mExpired);
}
} }

View File

@ -2,11 +2,20 @@
#define OPENMW_MWWORLD_CELLPRELOADER_H #define OPENMW_MWWORLD_CELLPRELOADER_H
#include <components/sceneutil/workqueue.hpp> #include <components/sceneutil/workqueue.hpp>
#include <map> #include <map>
#include <osg/Vec3f> #include <osg/Vec3f>
#include <osg/Vec4i> #include <osg/Vec4i>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <map>
namespace osg
{
class Stats;
}
namespace Resource namespace Resource
{ {
class ResourceSystem; class ResourceSystem;
@ -76,6 +85,8 @@ namespace MWWorld
bool isTerrainLoaded(const CellPreloader::PositionCellGrid& position, double referenceTime) const; bool isTerrainLoaded(const CellPreloader::PositionCellGrid& position, double referenceTime) const;
void setTerrain(Terrain::World* terrain); void setTerrain(Terrain::World* terrain);
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
private: private:
void clearAllTasks(); void clearAllTasks();
@ -118,6 +129,10 @@ namespace MWWorld
std::vector<PositionCellGrid> mLoadedTerrainPositions; std::vector<PositionCellGrid> mLoadedTerrainPositions;
double mLoadedTerrainTimestamp; double mLoadedTerrainTimestamp;
std::size_t mEvicted = 0;
std::size_t mAdded = 0;
std::size_t mExpired = 0;
std::size_t mLoaded = 0;
}; };
} }

View File

@ -1285,4 +1285,9 @@ namespace MWWorld
} }
} }
} }
void Scene::reportStats(unsigned int frameNumber, osg::Stats& stats) const
{
mPreloader->reportStats(frameNumber, stats);
}
} }

View File

@ -19,6 +19,7 @@
namespace osg namespace osg
{ {
class Vec3f; class Vec3f;
class Stats;
} }
namespace ESM namespace ESM
@ -203,6 +204,8 @@ namespace MWWorld
void testExteriorCells(); void testExteriorCells();
void testInteriorCells(); void testInteriorCells();
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
}; };
} }

View File

@ -3786,6 +3786,7 @@ namespace MWWorld
{ {
DetourNavigator::reportStats(mNavigator->getStats(), frameNumber, stats); DetourNavigator::reportStats(mNavigator->getStats(), frameNumber, stats);
mPhysics->reportStats(frameNumber, stats); mPhysics->reportStats(frameNumber, stats);
mWorldScene->reportStats(frameNumber, stats);
} }
void World::updateSkyDate() void World::updateSkyDate()

View File

@ -72,6 +72,11 @@ namespace Resource
"Physics Projectiles", "Physics Projectiles",
"Physics HeightFields", "Physics HeightFields",
"Lua UsedMemory", "Lua UsedMemory",
"CellPreloader Count",
"CellPreloader Added",
"CellPreloader Evicted",
"CellPreloader Loaded",
"CellPreloader Expired",
"NavMesh Jobs", "NavMesh Jobs",
"NavMesh Waiting", "NavMesh Waiting",
"NavMesh Pushed", "NavMesh Pushed",