Avoid allocating large memory for m_gpu_times in no graphics
This commit is contained in:
parent
7d561de3fb
commit
60157a33c4
@ -248,6 +248,7 @@
|
|||||||
#include "utils/leak_check.hpp"
|
#include "utils/leak_check.hpp"
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
#include "utils/mini_glm.hpp"
|
#include "utils/mini_glm.hpp"
|
||||||
|
#include "utils/profiler.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
|
|
||||||
static void cleanSuperTuxKart();
|
static void cleanSuperTuxKart();
|
||||||
@ -1879,6 +1880,9 @@ int main(int argc, char *argv[] )
|
|||||||
ServerConfig::m_wan_server = false;
|
ServerConfig::m_wan_server = false;
|
||||||
ServerConfig::m_validating_player = false;
|
ServerConfig::m_validating_player = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ProfileWorld::isNoGraphics())
|
||||||
|
profiler.init();
|
||||||
initRest();
|
initRest();
|
||||||
|
|
||||||
input_manager = new InputManager ();
|
input_manager = new InputManager ();
|
||||||
|
@ -88,15 +88,7 @@ Profiler::Profiler()
|
|||||||
m_max_frames = 20 * 120;
|
m_max_frames = 20 * 120;
|
||||||
m_current_frame = 0;
|
m_current_frame = 0;
|
||||||
m_has_wrapped_around = false;
|
m_has_wrapped_around = false;
|
||||||
|
|
||||||
const int MAX_THREADS = 10;
|
|
||||||
m_all_threads_data.resize(MAX_THREADS);
|
|
||||||
m_thread_mapping.resize(MAX_THREADS);
|
|
||||||
// Add this thread to the thread mapping
|
|
||||||
m_thread_mapping[0] = pthread_self();
|
|
||||||
m_threads_used = 1;
|
m_threads_used = 1;
|
||||||
|
|
||||||
m_gpu_times.resize(Q_LAST*m_max_frames);
|
|
||||||
} // Profile
|
} // Profile
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -104,6 +96,21 @@ Profiler::~Profiler()
|
|||||||
{
|
{
|
||||||
} // ~Profiler
|
} // ~Profiler
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/** It is split from the constructor so that it can be avoided allocating
|
||||||
|
* unnecessary memory when the profiler is never used (for example in no
|
||||||
|
* graphics). */
|
||||||
|
void Profiler::init()
|
||||||
|
{
|
||||||
|
const int MAX_THREADS = 10;
|
||||||
|
m_all_threads_data.resize(MAX_THREADS);
|
||||||
|
m_thread_mapping.resize(MAX_THREADS);
|
||||||
|
|
||||||
|
// Add this thread to the thread mapping
|
||||||
|
m_thread_mapping[0] = pthread_self();
|
||||||
|
m_gpu_times.resize(Q_LAST * m_max_frames);
|
||||||
|
} // init
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Returns a unique index for a thread. If the calling thread is not yet in
|
/** Returns a unique index for a thread. If the calling thread is not yet in
|
||||||
* the mapping, it will assign a new unique id to this thread. This function
|
* the mapping, it will assign a new unique id to this thread. This function
|
||||||
|
@ -279,7 +279,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
Profiler();
|
Profiler();
|
||||||
virtual ~Profiler();
|
virtual ~Profiler();
|
||||||
|
void init();
|
||||||
void pushCPUMarker(const char* name="N/A",
|
void pushCPUMarker(const char* name="N/A",
|
||||||
const video::SColor& color=video::SColor());
|
const video::SColor& color=video::SColor());
|
||||||
void popCPUMarker();
|
void popCPUMarker();
|
||||||
|
Loading…
Reference in New Issue
Block a user