Moved performance counters to a separate class
parent
81b7bcc5bc
commit
5fea22ff03
|
@ -117,6 +117,8 @@ set(BASE_SOURCES
|
|||
common/logger.cpp
|
||||
common/logger.h
|
||||
common/make_unique.h
|
||||
common/profiler.cpp
|
||||
common/profiler.h
|
||||
common/regex_utils.cpp
|
||||
common/regex_utils.h
|
||||
common/resources/inputstream.cpp
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "common/key.h"
|
||||
#include "common/logger.h"
|
||||
#include "common/make_unique.h"
|
||||
#include "common/profiler.h"
|
||||
#include "common/stringutils.h"
|
||||
#include "common/version.h"
|
||||
|
||||
|
@ -113,9 +114,7 @@ CApplication::CApplication(CSystemUtils* systemUtils)
|
|||
m_private(MakeUnique<ApplicationPrivate>()),
|
||||
m_configFile(MakeUnique<CConfigFile>()),
|
||||
m_input(MakeUnique<CInput>()),
|
||||
m_pathManager(MakeUnique<CPathManager>(systemUtils)),
|
||||
m_performanceCounters(),
|
||||
m_performanceCountersData()
|
||||
m_pathManager(MakeUnique<CPathManager>(systemUtils))
|
||||
{
|
||||
m_exitCode = 0;
|
||||
m_active = false;
|
||||
|
@ -145,11 +144,6 @@ CApplication::CApplication(CSystemUtils* systemUtils)
|
|||
m_manualFrameLast = m_systemUtils->CreateTimeStamp();
|
||||
m_manualFrameTime = m_systemUtils->CreateTimeStamp();
|
||||
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
m_performanceCounters[i][0] = m_systemUtils->CreateTimeStamp();
|
||||
m_performanceCounters[i][1] = m_systemUtils->CreateTimeStamp();
|
||||
}
|
||||
|
||||
m_joystickEnabled = false;
|
||||
|
||||
|
@ -174,12 +168,6 @@ CApplication::~CApplication()
|
|||
m_systemUtils->DestroyTimeStamp(m_manualFrameLast);
|
||||
m_systemUtils->DestroyTimeStamp(m_manualFrameTime);
|
||||
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
m_systemUtils->DestroyTimeStamp(m_performanceCounters[i][0]);
|
||||
m_systemUtils->DestroyTimeStamp(m_performanceCounters[i][1]);
|
||||
}
|
||||
|
||||
m_joystickEnabled = false;
|
||||
|
||||
m_controller.reset();
|
||||
|
@ -995,12 +983,10 @@ int CApplication::Run()
|
|||
|
||||
while (true)
|
||||
{
|
||||
ResetPerformanceCounters();
|
||||
|
||||
if (m_active)
|
||||
{
|
||||
StartPerformanceCounter(PCNT_ALL);
|
||||
StartPerformanceCounter(PCNT_EVENT_PROCESSING);
|
||||
CProfiler::StartPerformanceCounter(PCNT_ALL);
|
||||
CProfiler::StartPerformanceCounter(PCNT_EVENT_PROCESSING);
|
||||
}
|
||||
|
||||
// To be sure no old event remains
|
||||
|
@ -1089,9 +1075,9 @@ int CApplication::Run()
|
|||
m_controller->ProcessEvent(event);
|
||||
}
|
||||
|
||||
StopPerformanceCounter(PCNT_EVENT_PROCESSING);
|
||||
CProfiler::StopPerformanceCounter(PCNT_EVENT_PROCESSING);
|
||||
|
||||
StartPerformanceCounter(PCNT_UPDATE_ALL);
|
||||
CProfiler::StartPerformanceCounter(PCNT_UPDATE_ALL);
|
||||
|
||||
// Prepare and process step simulation event
|
||||
Event event = CreateUpdateEvent();
|
||||
|
@ -1101,16 +1087,16 @@ int CApplication::Run()
|
|||
|
||||
m_sound->FrameMove(m_relTime);
|
||||
|
||||
StartPerformanceCounter(PCNT_UPDATE_GAME);
|
||||
CProfiler::StartPerformanceCounter(PCNT_UPDATE_GAME);
|
||||
m_controller->ProcessEvent(event);
|
||||
StopPerformanceCounter(PCNT_UPDATE_GAME);
|
||||
CProfiler::StopPerformanceCounter(PCNT_UPDATE_GAME);
|
||||
|
||||
StartPerformanceCounter(PCNT_UPDATE_ENGINE);
|
||||
CProfiler::StartPerformanceCounter(PCNT_UPDATE_ENGINE);
|
||||
m_engine->FrameUpdate();
|
||||
StopPerformanceCounter(PCNT_UPDATE_ENGINE);
|
||||
CProfiler::StopPerformanceCounter(PCNT_UPDATE_ENGINE);
|
||||
}
|
||||
|
||||
StopPerformanceCounter(PCNT_UPDATE_ALL);
|
||||
CProfiler::StopPerformanceCounter(PCNT_UPDATE_ALL);
|
||||
|
||||
/* Update mouse position explicitly right before rendering
|
||||
* because mouse events are usually way behind */
|
||||
|
@ -1118,9 +1104,7 @@ int CApplication::Run()
|
|||
|
||||
Render();
|
||||
|
||||
StopPerformanceCounter(PCNT_ALL);
|
||||
|
||||
UpdatePerformanceCountersData();
|
||||
CProfiler::StopPerformanceCounter(PCNT_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1405,14 +1389,14 @@ Event CApplication::CreateVirtualEvent(const Event& sourceEvent)
|
|||
/** Renders the frame and swaps buffers as necessary */
|
||||
void CApplication::Render()
|
||||
{
|
||||
StartPerformanceCounter(PCNT_RENDER_ALL);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_ALL);
|
||||
m_engine->Render();
|
||||
StopPerformanceCounter(PCNT_RENDER_ALL);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_ALL);
|
||||
|
||||
StartPerformanceCounter(PCNT_SWAP_BUFFERS);
|
||||
CProfiler::StartPerformanceCounter(PCNT_SWAP_BUFFERS);
|
||||
if (m_deviceConfig.doubleBuf)
|
||||
SDL_GL_SwapWindow(m_private->window);
|
||||
StopPerformanceCounter(PCNT_SWAP_BUFFERS);
|
||||
CProfiler::StopPerformanceCounter(PCNT_SWAP_BUFFERS);
|
||||
}
|
||||
|
||||
void CApplication::RenderIfNeeded(int updateRate)
|
||||
|
@ -1849,45 +1833,6 @@ void CApplication::SetLanguage(Language language)
|
|||
GetLogger()->Debug("SetLanguage: Test gettext translation: '%s'\n", gettext("Colobot rules!"));
|
||||
}
|
||||
|
||||
void CApplication::StartPerformanceCounter(PerformanceCounter counter)
|
||||
{
|
||||
m_systemUtils->GetCurrentTimeStamp(m_performanceCounters[counter][0]);
|
||||
}
|
||||
|
||||
void CApplication::StopPerformanceCounter(PerformanceCounter counter)
|
||||
{
|
||||
m_systemUtils->GetCurrentTimeStamp(m_performanceCounters[counter][1]);
|
||||
}
|
||||
|
||||
float CApplication::GetPerformanceCounterData(PerformanceCounter counter) const
|
||||
{
|
||||
return m_performanceCountersData[counter];
|
||||
}
|
||||
|
||||
void CApplication::ResetPerformanceCounters()
|
||||
{
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
StartPerformanceCounter(static_cast<PerformanceCounter>(i));
|
||||
StopPerformanceCounter(static_cast<PerformanceCounter>(i));
|
||||
}
|
||||
}
|
||||
|
||||
void CApplication::UpdatePerformanceCountersData()
|
||||
{
|
||||
long long sum = m_systemUtils->TimeStampExactDiff(m_performanceCounters[PCNT_ALL][0],
|
||||
m_performanceCounters[PCNT_ALL][1]);
|
||||
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
long long diff = m_systemUtils->TimeStampExactDiff(m_performanceCounters[i][0],
|
||||
m_performanceCounters[i][1]);
|
||||
|
||||
m_performanceCountersData[static_cast<PerformanceCounter>(i)] =
|
||||
static_cast<float>(diff) / static_cast<float>(sum);
|
||||
}
|
||||
}
|
||||
|
||||
bool CApplication::GetSceneTestMode()
|
||||
{
|
||||
return m_sceneTest;
|
||||
|
|
|
@ -94,34 +94,6 @@ enum MouseMode
|
|||
MOUSE_NONE, //! < no cursor visible
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum PerformanceCounter
|
||||
* \brief Type of counter testing performance
|
||||
*/
|
||||
enum PerformanceCounter
|
||||
{
|
||||
PCNT_EVENT_PROCESSING, //! < event processing (except update events)
|
||||
|
||||
PCNT_UPDATE_ALL, //! < the whole frame update process
|
||||
PCNT_UPDATE_ENGINE, //! < frame update in CEngine
|
||||
PCNT_UPDATE_PARTICLE, //! < frame update in CParticle
|
||||
PCNT_UPDATE_GAME, //! < frame update in CRobotMain
|
||||
|
||||
PCNT_RENDER_ALL, //! < the whole rendering process
|
||||
PCNT_RENDER_PARTICLE, //! < rendering the particles in 3D
|
||||
PCNT_RENDER_WATER, //! < rendering the water
|
||||
PCNT_RENDER_TERRAIN, //! < rendering the terrain
|
||||
PCNT_RENDER_OBJECTS, //! < rendering the 3D objects
|
||||
PCNT_RENDER_INTERFACE, //! < rendering 2D interface
|
||||
PCNT_RENDER_SHADOW_MAP, //! < rendering shadow map
|
||||
|
||||
PCNT_SWAP_BUFFERS, //! < swapping buffers and vsync
|
||||
|
||||
PCNT_ALL, //! < all counters together
|
||||
|
||||
PCNT_MAX
|
||||
};
|
||||
|
||||
enum DebugMode
|
||||
{
|
||||
DEBUG_SYS_EVENTS = 1 << 0,
|
||||
|
@ -292,13 +264,6 @@ public:
|
|||
void SetLanguage(Language language);
|
||||
//@}
|
||||
|
||||
//! Management of performance counters
|
||||
//@{
|
||||
void StartPerformanceCounter(PerformanceCounter counter);
|
||||
void StopPerformanceCounter(PerformanceCounter counter);
|
||||
float GetPerformanceCounterData(PerformanceCounter counter) const;
|
||||
//@}
|
||||
|
||||
bool GetSceneTestMode();
|
||||
|
||||
//! Renders the image in window
|
||||
|
@ -333,11 +298,6 @@ protected:
|
|||
//! Internal procedure to reset time counters
|
||||
void InternalResumeSimulation();
|
||||
|
||||
//! Resets all performance counters to zero
|
||||
void ResetPerformanceCounters();
|
||||
//! Updates performance counters from gathered timer data
|
||||
void UpdatePerformanceCountersData();
|
||||
|
||||
protected:
|
||||
//! System utils instance
|
||||
CSystemUtils* m_systemUtils;
|
||||
|
@ -382,9 +342,6 @@ protected:
|
|||
SystemTimeStamp* m_lastTimeStamp;
|
||||
SystemTimeStamp* m_curTimeStamp;
|
||||
|
||||
SystemTimeStamp* m_performanceCounters[PCNT_MAX][2];
|
||||
float m_performanceCountersData[PCNT_MAX];
|
||||
|
||||
long long m_realAbsTimeBase;
|
||||
long long m_realAbsTime;
|
||||
long long m_realRelTime;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "common/logger.h"
|
||||
#include "common/make_unique.h"
|
||||
#include "common/profiler.h"
|
||||
#include "common/restext.h"
|
||||
#include "common/version.h"
|
||||
|
||||
|
@ -99,6 +100,8 @@ int main(int argc, char *argv[])
|
|||
auto systemUtils = CSystemUtils::Create(); // platform-specific utils
|
||||
systemUtils->Init();
|
||||
|
||||
CProfiler::SetSystemUtils(systemUtils.get());
|
||||
|
||||
// Add file output to the logger
|
||||
std::string logFileName;
|
||||
#if DEV_BUILD
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "common/profiler.h"
|
||||
|
||||
#include "common/system/system.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
CSystemUtils* CProfiler::m_systemUtils = nullptr;
|
||||
long long CProfiler::m_performanceCounters[PCNT_MAX] = {0};
|
||||
long long CProfiler::m_prevPerformanceCounters[PCNT_MAX] = {0};
|
||||
std::stack<SystemTimeStamp*> CProfiler::m_runningPerformanceCounters;
|
||||
std::stack<PerformanceCounter> CProfiler::m_runningPerformanceCountersType;
|
||||
|
||||
void CProfiler::SetSystemUtils(CSystemUtils* systemUtils)
|
||||
{
|
||||
m_systemUtils = systemUtils;
|
||||
}
|
||||
|
||||
void CProfiler::StartPerformanceCounter(PerformanceCounter counter)
|
||||
{
|
||||
if (counter == PCNT_ALL)
|
||||
ResetPerformanceCounters();
|
||||
|
||||
SystemTimeStamp* timeStamp = m_systemUtils->CreateTimeStamp();
|
||||
m_systemUtils->GetCurrentTimeStamp(timeStamp);
|
||||
m_runningPerformanceCounters.push(timeStamp);
|
||||
m_runningPerformanceCountersType.push(counter);
|
||||
}
|
||||
|
||||
void CProfiler::StopPerformanceCounter(PerformanceCounter counter)
|
||||
{
|
||||
assert(m_runningPerformanceCountersType.top() == counter);
|
||||
m_runningPerformanceCountersType.pop();
|
||||
|
||||
SystemTimeStamp* timeStamp = m_systemUtils->CreateTimeStamp();
|
||||
m_systemUtils->GetCurrentTimeStamp(timeStamp);
|
||||
m_performanceCounters[counter] += m_systemUtils->TimeStampExactDiff(m_runningPerformanceCounters.top(), timeStamp);
|
||||
m_runningPerformanceCounters.pop();
|
||||
|
||||
if (counter == PCNT_ALL)
|
||||
SavePerformanceCounters();
|
||||
}
|
||||
|
||||
long long CProfiler::GetPerformanceCounterTime(PerformanceCounter counter)
|
||||
{
|
||||
return m_prevPerformanceCounters[counter];
|
||||
}
|
||||
|
||||
float CProfiler::GetPerformanceCounterFraction(PerformanceCounter counter)
|
||||
{
|
||||
return static_cast<float>(m_prevPerformanceCounters[counter]) / static_cast<float>(m_prevPerformanceCounters[PCNT_ALL]);
|
||||
}
|
||||
|
||||
void CProfiler::ResetPerformanceCounters()
|
||||
{
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
m_performanceCounters[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CProfiler::SavePerformanceCounters()
|
||||
{
|
||||
assert(m_runningPerformanceCounters.empty());
|
||||
|
||||
for (int i = 0; i < PCNT_MAX; ++i)
|
||||
{
|
||||
m_prevPerformanceCounters[i] = m_performanceCounters[i];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class CSystemUtils;
|
||||
struct SystemTimeStamp;
|
||||
|
||||
#include <stack>
|
||||
|
||||
/**
|
||||
* \enum PerformanceCounter
|
||||
* \brief Type of counter testing performance
|
||||
*/
|
||||
enum PerformanceCounter
|
||||
{
|
||||
PCNT_EVENT_PROCESSING, //! < event processing (except update events)
|
||||
|
||||
PCNT_UPDATE_ALL, //! < the whole frame update process
|
||||
PCNT_UPDATE_ENGINE, //! < frame update in CEngine
|
||||
PCNT_UPDATE_PARTICLE, //! < frame update in CParticle
|
||||
PCNT_UPDATE_GAME, //! < frame update in CRobotMain
|
||||
|
||||
PCNT_RENDER_ALL, //! < the whole rendering process
|
||||
PCNT_RENDER_PARTICLE, //! < rendering the particles in 3D
|
||||
PCNT_RENDER_WATER, //! < rendering the water
|
||||
PCNT_RENDER_TERRAIN, //! < rendering the terrain
|
||||
PCNT_RENDER_OBJECTS, //! < rendering the 3D objects
|
||||
PCNT_RENDER_INTERFACE, //! < rendering 2D interface
|
||||
PCNT_RENDER_SHADOW_MAP, //! < rendering shadow map
|
||||
|
||||
PCNT_SWAP_BUFFERS, //! < swapping buffers and vsync
|
||||
|
||||
PCNT_ALL, //! < all counters together
|
||||
|
||||
PCNT_MAX
|
||||
};
|
||||
|
||||
class CProfiler
|
||||
{
|
||||
public:
|
||||
static void SetSystemUtils(CSystemUtils* systemUtils);
|
||||
|
||||
static void StartPerformanceCounter(PerformanceCounter counter);
|
||||
static void StopPerformanceCounter(PerformanceCounter counter);
|
||||
static long long GetPerformanceCounterTime(PerformanceCounter counter);
|
||||
static float GetPerformanceCounterFraction(PerformanceCounter counter);
|
||||
|
||||
private:
|
||||
static void ResetPerformanceCounters();
|
||||
static void SavePerformanceCounters();
|
||||
|
||||
private:
|
||||
static CSystemUtils* m_systemUtils;
|
||||
|
||||
static long long m_performanceCounters[PCNT_MAX];
|
||||
static long long m_prevPerformanceCounters[PCNT_MAX];
|
||||
static std::stack<SystemTimeStamp*> m_runningPerformanceCounters;
|
||||
static std::stack<PerformanceCounter> m_runningPerformanceCountersType;
|
||||
};
|
||||
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "common/key.h"
|
||||
#include "common/logger.h"
|
||||
#include "common/make_unique.h"
|
||||
#include "common/profiler.h"
|
||||
#include "common/stringutils.h"
|
||||
|
||||
#include "common/system/system.h"
|
||||
|
@ -448,9 +449,9 @@ void CEngine::FrameUpdate()
|
|||
|
||||
m_lightMan->UpdateProgression(rTime);
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_UPDATE_PARTICLE);
|
||||
CProfiler::StartPerformanceCounter(PCNT_UPDATE_PARTICLE);
|
||||
m_particle->FrameParticle(rTime);
|
||||
m_app->StopPerformanceCounter(PCNT_UPDATE_PARTICLE);
|
||||
CProfiler::StopPerformanceCounter(PCNT_UPDATE_PARTICLE);
|
||||
|
||||
ComputeDistance();
|
||||
UpdateGeometry();
|
||||
|
@ -3220,9 +3221,9 @@ void CEngine::Render()
|
|||
}
|
||||
}
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_RENDER_INTERFACE);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_INTERFACE);
|
||||
DrawInterface();
|
||||
m_app->StopPerformanceCounter(PCNT_RENDER_INTERFACE);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_INTERFACE);
|
||||
|
||||
// End the scene
|
||||
m_device->EndScene();
|
||||
|
@ -3261,7 +3262,7 @@ void CEngine::Draw3DScene()
|
|||
|
||||
m_water->DrawBack(); // draws water background
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_RENDER_TERRAIN);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_TERRAIN);
|
||||
|
||||
// Draw terrain
|
||||
|
||||
|
@ -3321,11 +3322,11 @@ void CEngine::Draw3DScene()
|
|||
if (!m_shadowMapping)
|
||||
DrawShadowSpots();
|
||||
|
||||
m_app->StopPerformanceCounter(PCNT_RENDER_TERRAIN);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_TERRAIN);
|
||||
|
||||
// Draw other objects
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_RENDER_OBJECTS);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_OBJECTS);
|
||||
|
||||
bool transparent = false;
|
||||
|
||||
|
@ -3442,7 +3443,7 @@ void CEngine::Draw3DScene()
|
|||
}
|
||||
}
|
||||
|
||||
m_app->StopPerformanceCounter(PCNT_RENDER_OBJECTS);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_OBJECTS);
|
||||
|
||||
m_lightMan->UpdateDeviceLights(ENG_OBJTYPE_TERRAIN);
|
||||
|
||||
|
@ -3455,9 +3456,9 @@ void CEngine::Draw3DScene()
|
|||
m_lightMan->DebugDumpLights();
|
||||
}
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_RENDER_WATER);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_WATER);
|
||||
m_water->DrawSurf(); // draws water surface
|
||||
m_app->StopPerformanceCounter(PCNT_RENDER_WATER);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_WATER);
|
||||
|
||||
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
|
||||
|
||||
|
@ -3479,9 +3480,9 @@ void CEngine::Draw3DScene()
|
|||
}
|
||||
m_displayGoto.clear();
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_RENDER_PARTICLE);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_PARTICLE);
|
||||
m_particle->DrawParticle(SH_WORLD); // draws the particles of the 3D world
|
||||
m_app->StopPerformanceCounter(PCNT_RENDER_PARTICLE);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_PARTICLE);
|
||||
|
||||
m_device->SetRenderState(RENDER_STATE_LIGHTING, true);
|
||||
|
||||
|
@ -3707,7 +3708,7 @@ void CEngine::RenderShadowMap()
|
|||
|
||||
if (!m_shadowMapping) return;
|
||||
|
||||
m_app->StartPerformanceCounter(PCNT_RENDER_SHADOW_MAP);
|
||||
CProfiler::StartPerformanceCounter(PCNT_RENDER_SHADOW_MAP);
|
||||
|
||||
// If no shadow map texture exists, create it
|
||||
if (m_shadowMap.id == 0)
|
||||
|
@ -3897,7 +3898,7 @@ void CEngine::RenderShadowMap()
|
|||
m_device->SetColorMask(true, true, true, true);
|
||||
m_device->Clear();
|
||||
|
||||
m_app->StopPerformanceCounter(PCNT_RENDER_SHADOW_MAP);
|
||||
CProfiler::StopPerformanceCounter(PCNT_RENDER_SHADOW_MAP);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, false);
|
||||
|
@ -5030,7 +5031,7 @@ void CEngine::DrawStats()
|
|||
return;
|
||||
|
||||
float height = m_text->GetAscent(FONT_COLOBOT, 13.0f);
|
||||
float width = 0.25f;
|
||||
float width = 0.4f;
|
||||
const int TOTAL_LINES = 20;
|
||||
|
||||
Math::Point pos(0.05f * m_size.x/m_size.y, 0.05f + TOTAL_LINES * height);
|
||||
|
@ -5053,56 +5054,56 @@ void CEngine::DrawStats()
|
|||
|
||||
SetState(ENG_RSTATE_TEXT);
|
||||
|
||||
std::stringstream str;
|
||||
|
||||
auto drawStatsLine = [&](const std::string& name, const std::string& value)
|
||||
auto drawStatsLine = [&](const std::string& name = "", const std::string& value = "", const std::string& value2 = "")
|
||||
{
|
||||
if (!name.empty())
|
||||
{
|
||||
str.str("");
|
||||
str << name << ": " << value;
|
||||
m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
m_text->DrawText(name+":", FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pos.x += 0.25f;
|
||||
if (!value.empty())
|
||||
m_text->DrawText(value, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pos.x += 0.15f;
|
||||
if (!value2.empty())
|
||||
m_text->DrawText(value2, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pos.x -= 0.4f;
|
||||
pos.y -= height;
|
||||
};
|
||||
|
||||
auto drawStatsValue = [&](const std::string& name, float value)
|
||||
auto drawStatsValue = [&](const std::string& name, long long time)
|
||||
{
|
||||
str.str("");
|
||||
str << std::fixed << std::setprecision(2) << value;
|
||||
drawStatsLine(name, str.str());
|
||||
float value = static_cast<float>(time)/CProfiler::GetPerformanceCounterTime(PCNT_ALL);
|
||||
drawStatsLine(name, StrUtils::Format("%.2f", value), StrUtils::Format("%.2f ms", time/1e6f));
|
||||
};
|
||||
|
||||
auto drawStatsCounter = [&](const std::string& name, PerformanceCounter counter)
|
||||
{
|
||||
drawStatsValue(name, m_app->GetPerformanceCounterData(counter));
|
||||
drawStatsValue(name, CProfiler::GetPerformanceCounterTime(counter));
|
||||
};
|
||||
|
||||
|
||||
float engineUpdate = m_app->GetPerformanceCounterData(PCNT_UPDATE_ENGINE) -
|
||||
m_app->GetPerformanceCounterData(PCNT_UPDATE_PARTICLE);
|
||||
long long engineUpdate = CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_ENGINE) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_PARTICLE);
|
||||
|
||||
float otherUpdate = m_app->GetPerformanceCounterData(PCNT_UPDATE_ALL) -
|
||||
engineUpdate -
|
||||
m_app->GetPerformanceCounterData(PCNT_UPDATE_PARTICLE) -
|
||||
m_app->GetPerformanceCounterData(PCNT_UPDATE_GAME);
|
||||
long long otherUpdate = CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_ALL) -
|
||||
engineUpdate -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_PARTICLE) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_UPDATE_GAME);
|
||||
|
||||
float otherRender = m_app->GetPerformanceCounterData(PCNT_RENDER_ALL) -
|
||||
m_app->GetPerformanceCounterData(PCNT_RENDER_PARTICLE) -
|
||||
m_app->GetPerformanceCounterData(PCNT_RENDER_WATER) -
|
||||
m_app->GetPerformanceCounterData(PCNT_RENDER_TERRAIN) -
|
||||
m_app->GetPerformanceCounterData(PCNT_RENDER_OBJECTS) -
|
||||
m_app->GetPerformanceCounterData(PCNT_RENDER_INTERFACE) -
|
||||
m_app->GetPerformanceCounterData(PCNT_RENDER_SHADOW_MAP);
|
||||
long long otherRender = CProfiler::GetPerformanceCounterTime(PCNT_RENDER_ALL) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_RENDER_PARTICLE) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_RENDER_WATER) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_RENDER_TERRAIN) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_RENDER_OBJECTS) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_RENDER_INTERFACE) -
|
||||
CProfiler::GetPerformanceCounterTime(PCNT_RENDER_SHADOW_MAP);
|
||||
|
||||
drawStatsCounter("Event processing", PCNT_EVENT_PROCESSING);
|
||||
drawStatsLine("", "");
|
||||
drawStatsLine( "");
|
||||
drawStatsCounter("Frame update", PCNT_UPDATE_ALL);
|
||||
drawStatsValue (" Engine update", engineUpdate);
|
||||
drawStatsCounter(" Particle update", PCNT_UPDATE_PARTICLE);
|
||||
drawStatsCounter(" Game update", PCNT_UPDATE_GAME);
|
||||
drawStatsValue( " Other update", otherUpdate);
|
||||
drawStatsLine("", "");
|
||||
drawStatsLine( "");
|
||||
drawStatsCounter("Frame render", PCNT_RENDER_ALL);
|
||||
drawStatsCounter(" Particle render", PCNT_RENDER_PARTICLE);
|
||||
drawStatsCounter(" Water render", PCNT_RENDER_WATER);
|
||||
|
@ -5112,11 +5113,11 @@ void CEngine::DrawStats()
|
|||
drawStatsCounter(" Shadow map render", PCNT_RENDER_SHADOW_MAP);
|
||||
drawStatsValue( " Other render", otherRender);
|
||||
drawStatsCounter("Swap buffers & VSync", PCNT_SWAP_BUFFERS);
|
||||
drawStatsLine("", "");
|
||||
drawStatsLine( "");
|
||||
drawStatsLine( "Triangles", StrUtils::ToString<int>(m_statisticTriangle));
|
||||
drawStatsValue( "FPS", m_fps);
|
||||
drawStatsLine("", "");
|
||||
str.str("");
|
||||
drawStatsLine( "FPS", StrUtils::Format("%.3f", m_fps));
|
||||
drawStatsLine( "");
|
||||
std::stringstream str;
|
||||
str << std::fixed << std::setprecision(2) << m_statisticPos.x << "; " << m_statisticPos.z;
|
||||
drawStatsLine( "Position", str.str());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue