Move the start benchmark function to the profiler
This simplifies its reuse for the recommend video settings function
This commit is contained in:
parent
fb3596f699
commit
dca91a6ee8
@ -249,7 +249,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
|
|||||||
// Auto-compute the rendering distance, but use a high scaling factor
|
// Auto-compute the rendering distance, but use a high scaling factor
|
||||||
// to ensure that even at low settings, on-track items only become invisible
|
// to ensure that even at low settings, on-track items only become invisible
|
||||||
// when already quite far.
|
// when already quite far.
|
||||||
lodnode->autoComputeLevel(24); // The distance grows with the square of the scaling factor
|
lodnode->autoComputeLevel(24); // The distance grows with the square root of the scaling factor
|
||||||
m_node = lodnode;
|
m_node = lodnode;
|
||||||
}
|
}
|
||||||
setType(type);
|
setType(type);
|
||||||
|
@ -21,10 +21,9 @@
|
|||||||
#include "graphics/central_settings.hpp"
|
#include "graphics/central_settings.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "race/race_manager.hpp"
|
|
||||||
#include "replay/replay_play.hpp"
|
|
||||||
#include "states_screens/dialogs/custom_video_settings.hpp"
|
#include "states_screens/dialogs/custom_video_settings.hpp"
|
||||||
#include "states_screens/dialogs/recommend_video_settings.hpp"
|
#include "states_screens/dialogs/recommend_video_settings.hpp"
|
||||||
|
#include "utils/profiler.hpp"
|
||||||
|
|
||||||
#ifndef SERVER_ONLY
|
#ifndef SERVER_ONLY
|
||||||
#include <ge_main.hpp>
|
#include <ge_main.hpp>
|
||||||
@ -317,7 +316,7 @@ void OptionsScreenVideo::init()
|
|||||||
// the graphics engine, start the benchmark when the
|
// the graphics engine, start the benchmark when the
|
||||||
// video settings screen is loaded back afterwards.
|
// video settings screen is loaded back afterwards.
|
||||||
if (RaceManager::get()->isBenchmarkScheduled())
|
if (RaceManager::get()->isBenchmarkScheduled())
|
||||||
startBenchmark();
|
profiler.startBenchmark();
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
@ -665,20 +664,11 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
else if (name == "benchmarkCurrent")
|
else if (name == "benchmarkCurrent")
|
||||||
{
|
{
|
||||||
#ifndef SERVER_ONLY
|
#ifndef SERVER_ONLY
|
||||||
// TODO - Add the possibility to benchmark more tracks and define replay benchmarks in
|
|
||||||
// a config file
|
|
||||||
const std::string bf_bench("benchmark_black_forest.replay");
|
|
||||||
const bool result = ReplayPlay::get()->addReplayFile(file_manager
|
|
||||||
->getAsset(FileManager::REPLAY, bf_bench), true/*custom_replay*/);
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
Log::fatal("OptionsScreenVideo", "Can't open replay for benchmark!");
|
|
||||||
|
|
||||||
// To avoid crashes and ensure the proper settings are used during the benchmark,
|
// To avoid crashes and ensure the proper settings are used during the benchmark,
|
||||||
// we apply the settings. If this doesn't require restarting the screen, we start
|
// we apply the settings. If this doesn't require restarting the screen, we start
|
||||||
// the benchmark immediately, otherwise we schedule it to start after the restart.
|
// the benchmark immediately, otherwise we schedule it to start after the restart.
|
||||||
if (applySettings() == 0)
|
if (applySettings() == 0)
|
||||||
startBenchmark();
|
profiler.startBenchmark();
|
||||||
else
|
else
|
||||||
RaceManager::get()->scheduleBenchmark();
|
RaceManager::get()->scheduleBenchmark();
|
||||||
#endif
|
#endif
|
||||||
@ -691,24 +681,6 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void OptionsScreenVideo::startBenchmark()
|
|
||||||
{
|
|
||||||
RaceManager::get()->setRaceGhostKarts(true);
|
|
||||||
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
|
|
||||||
ReplayPlay::ReplayData bench_rd = ReplayPlay::get()->getCurrentReplayData();
|
|
||||||
RaceManager::get()->setReverseTrack(bench_rd.m_reverse);
|
|
||||||
RaceManager::get()->setRecordRace(false);
|
|
||||||
RaceManager::get()->setWatchingReplay(true);
|
|
||||||
RaceManager::get()->setDifficulty((RaceManager::Difficulty)bench_rd.m_difficulty);
|
|
||||||
|
|
||||||
// The race manager automatically adds karts for the ghosts
|
|
||||||
RaceManager::get()->setNumKarts(0);
|
|
||||||
RaceManager::get()->setBenchmarking(true); // Also turns off the scheduled benchmark if needed
|
|
||||||
RaceManager::get()->startWatchingReplay(bench_rd.m_track_name, bench_rd.m_laps);
|
|
||||||
} // startBenchmark
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void OptionsScreenVideo::tearDown()
|
void OptionsScreenVideo::tearDown()
|
||||||
{
|
{
|
||||||
#ifndef SERVER_ONLY
|
#ifndef SERVER_ONLY
|
||||||
|
@ -72,7 +72,6 @@ private:
|
|||||||
void updateTooltip();
|
void updateTooltip();
|
||||||
void updateBlurTooltip();
|
void updateBlurTooltip();
|
||||||
void initPresets();
|
void initPresets();
|
||||||
void startBenchmark();
|
|
||||||
static void onScrollResolutionsList(void* data);
|
static void onScrollResolutionsList(void* data);
|
||||||
/* Returns 1 or 2 if a restart will be done, 0 otherwise */
|
/* Returns 1 or 2 if a restart will be done, 0 otherwise */
|
||||||
int applySettings();
|
int applySettings();
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
|
#include "replay/replay_play.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
#include "utils/file_utils.hpp"
|
#include "utils/file_utils.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
@ -653,6 +655,33 @@ void Profiler::computeStableFPS()
|
|||||||
m_lock.unlock();
|
m_lock.unlock();
|
||||||
} // computeStableFPS
|
} // computeStableFPS
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void Profiler::startBenchmark()
|
||||||
|
{
|
||||||
|
// TODO - Add the possibility to benchmark more tracks and define replay benchmarks in
|
||||||
|
// a config file
|
||||||
|
const std::string bf_bench("benchmark_black_forest.replay");
|
||||||
|
const bool result = ReplayPlay::get()->addReplayFile(file_manager
|
||||||
|
->getAsset(FileManager::REPLAY, bf_bench), true/*custom_replay*/);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
Log::fatal("OptionsScreenVideo", "Can't open replay for benchmark!");
|
||||||
|
|
||||||
|
RaceManager::get()->setRaceGhostKarts(true);
|
||||||
|
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
|
||||||
|
ReplayPlay::ReplayData bench_rd = ReplayPlay::get()->getCurrentReplayData();
|
||||||
|
RaceManager::get()->setReverseTrack(bench_rd.m_reverse);
|
||||||
|
RaceManager::get()->setRecordRace(false);
|
||||||
|
RaceManager::get()->setWatchingReplay(true);
|
||||||
|
RaceManager::get()->setDifficulty((RaceManager::Difficulty)bench_rd.m_difficulty);
|
||||||
|
|
||||||
|
// The race manager automatically adds karts for the ghosts
|
||||||
|
RaceManager::get()->setNumKarts(0);
|
||||||
|
RaceManager::get()->setBenchmarking(true); // Also turns off the scheduled benchmark if needed
|
||||||
|
RaceManager::get()->startWatchingReplay(bench_rd.m_track_name, bench_rd.m_laps);
|
||||||
|
} // startBenchmark
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Saves the collected profile data to a file. Filename is based on the
|
/** Saves the collected profile data to a file. Filename is based on the
|
||||||
* stdout name (with -profile appended).
|
* stdout name (with -profile appended).
|
||||||
|
@ -322,6 +322,7 @@ public:
|
|||||||
void draw();
|
void draw();
|
||||||
void onClick(const core::vector2di& mouse_pos);
|
void onClick(const core::vector2di& mouse_pos);
|
||||||
void computeStableFPS();
|
void computeStableFPS();
|
||||||
|
void startBenchmark();
|
||||||
void writeToFile();
|
void writeToFile();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user