Added statistics about rendering to profile output.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5387 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2010-05-06 05:53:06 +00:00
parent fd08bd924a
commit 29539dd39f
2 changed files with 52 additions and 3 deletions

View File

@@ -38,9 +38,15 @@ ProfileWorld::ProfileWorld()
// quering the number of finished karts from the race manager (in laps
// based profiling) - otherwise just a high number.
race_manager->setNumLaps(m_profile_mode==PROFILE_LAPS ? m_num_laps : 99999);
m_phase = RACE_PHASE;
m_frame_count = 0;
m_start_time = irr_driver->getRealTime();
m_phase = RACE_PHASE;
m_frame_count = 0;
m_start_time = irr_driver->getRealTime();
m_num_triangles = 0;
m_num_culls = 0;
m_num_solid = 0;
m_num_transparent = 0;
m_num_trans_effect = 0;
m_num_calls = 0;
} // ProfileWorld
//-----------------------------------------------------------------------------
@@ -118,6 +124,15 @@ void ProfileWorld::update(float dt)
{
StandardRace::update(dt);
m_frame_count++;
video::IVideoDriver *driver = irr_driver->getVideoDriver();
io::IAttributes *attr = irr_driver->getSceneManager()->getParameters();
m_num_triangles += (int)(driver->getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000.f ));
m_num_calls += attr->getAttributeAsInt("calls");
m_num_culls += attr->getAttributeAsInt("culled" );
m_num_solid += attr->getAttributeAsInt("drawn_solid" );
m_num_transparent += attr->getAttributeAsInt("drawn_transparent" );
m_num_trans_effect += attr->getAttributeAsInt("drawn_transparent_effect" );
} // update
//-----------------------------------------------------------------------------
@@ -154,6 +169,17 @@ void ProfileWorld::enterRaceOverState()
float runtime = (irr_driver->getRealTime()-m_start_time)*0.001f;
printf("Number of frames: %d time %f, Average FPS: %f\n",
m_frame_count, runtime, (float)m_frame_count/runtime);
printf("Average #nodes drawn %f k\n",
(float)m_num_triangles/m_frame_count);
printf("Average # culled nodes: %f k\n",
(float)m_num_culls/m_frame_count);
printf("Average # solid nodes: %f k\n",
(float)m_num_solid/m_frame_count);
printf("Average # transparent nodes: %f\n",
(float)m_num_transparent/m_frame_count);
printf("Average # transp. effect nodes: %f\n",
(float)m_num_trans_effect/m_frame_count);
float min_t=999999.9f, max_t=0.0, av_t=0.0;
for ( KartList::size_type i = 0; i < m_karts.size(); ++i)

View File

@@ -33,17 +33,40 @@ class ProfileWorld : public StandardRace
private:
/** Profiling modes. */
enum ProfileType {PROFILE_NONE, PROFILE_TIME, PROFILE_LAPS};
/** If profiling is done, and if so, which mode. */
static ProfileType m_profile_mode;
/** In laps based profiling: number of laps to run. */
static int m_num_laps;
/** In time based profiling only: time to run. */
static float m_time;
/** Return value of real time at start of race. */
unsigned int m_start_time;
/** Number of frames. For statistics only. */
int m_frame_count;
/** Number of primitives drawn (in 1000). */
long long m_num_triangles;
/** Number of culled triangles. */
long long m_num_culls;
/** Numer of solid triangles drawn. */
long long m_num_solid;
/** Number of transparent triangles drawn. */
long long m_num_transparent;
/** Number of transparent effect triangles drawn. */
long long m_num_trans_effect;
/** Number of calls to draw. */
long long m_num_calls;
protected:
virtual Kart *createKart(const std::string &kart_ident, int index,