Fix crashing when turning the modern renderer on or off before benchmarking
This commit is contained in:
parent
9206b923f7
commit
01d62be5de
@ -146,6 +146,7 @@ RaceManager::RaceManager()
|
|||||||
setRaceGhostKarts(false);
|
setRaceGhostKarts(false);
|
||||||
setWatchingReplay(false);
|
setWatchingReplay(false);
|
||||||
setBenchmarking(false);
|
setBenchmarking(false);
|
||||||
|
m_scheduled_benchmark = false;
|
||||||
setTrack("jungle");
|
setTrack("jungle");
|
||||||
m_default_ai_list.clear();
|
m_default_ai_list.clear();
|
||||||
setNumPlayers(0);
|
setNumPlayers(0);
|
||||||
@ -1330,6 +1331,7 @@ core::stringw RaceManager::getDifficultyName(Difficulty diff) const
|
|||||||
void RaceManager::setBenchmarking(bool benchmark)
|
void RaceManager::setBenchmarking(bool benchmark)
|
||||||
{
|
{
|
||||||
m_benchmarking = benchmark;
|
m_benchmarking = benchmark;
|
||||||
|
m_scheduled_benchmark = false;
|
||||||
|
|
||||||
// If the benchmark mode is turned off and the profiler is still activated,
|
// If the benchmark mode is turned off and the profiler is still activated,
|
||||||
// turn the profiler off and reset the drawing mode to default.
|
// turn the profiler off and reset the drawing mode to default.
|
||||||
@ -1339,3 +1341,11 @@ void RaceManager::setBenchmarking(bool benchmark)
|
|||||||
profiler.setDrawing(true);
|
profiler.setDrawing(true);
|
||||||
}
|
}
|
||||||
} // setBenchmarking
|
} // setBenchmarking
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------
|
||||||
|
/** Schedule a benchmark. This function is used because the video options screen
|
||||||
|
* might need to be reloaded when switching between old and modern renderer.*/
|
||||||
|
void RaceManager::scheduleBenchmark()
|
||||||
|
{
|
||||||
|
m_scheduled_benchmark = true;
|
||||||
|
} // scheduleBenchmark
|
@ -368,6 +368,7 @@ private:
|
|||||||
bool m_has_ghost_karts;
|
bool m_has_ghost_karts;
|
||||||
bool m_watching_replay;
|
bool m_watching_replay;
|
||||||
bool m_benchmarking;
|
bool m_benchmarking;
|
||||||
|
bool m_scheduled_benchmark;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
@ -438,6 +439,7 @@ public:
|
|||||||
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
|
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
|
||||||
void computeRandomKartList();
|
void computeRandomKartList();
|
||||||
void setBenchmarking(bool benchmark);
|
void setBenchmarking(bool benchmark);
|
||||||
|
void scheduleBenchmark();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
bool hasTimeTarget() const { return m_time_target > 0.0f; }
|
bool hasTimeTarget() const { return m_time_target > 0.0f; }
|
||||||
@ -875,6 +877,11 @@ public:
|
|||||||
return m_benchmarking;
|
return m_benchmarking;
|
||||||
} // isBenchmarking
|
} // isBenchmarking
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
bool isBenchmarkScheduled() const
|
||||||
|
{
|
||||||
|
return m_scheduled_benchmark;
|
||||||
|
} // isBenchmarkSchedule
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
void addSpareTireKart(const std::string& name)
|
void addSpareTireKart(const std::string& name)
|
||||||
{
|
{
|
||||||
m_kart_status.push_back(KartStatus(name, 0, -1, -1,
|
m_kart_status.push_back(KartStatus(name, 0, -1, -1,
|
||||||
|
@ -371,6 +371,12 @@ void OptionsScreenVideo::init()
|
|||||||
m_fullscreen_checkbox_focus = false;
|
m_fullscreen_checkbox_focus = false;
|
||||||
getWidget("fullscreen")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
getWidget("fullscreen")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a benchmark was requested and the game had to reload
|
||||||
|
// the graphics engine, start the benchmark when the
|
||||||
|
// video settings screen is loaded back afterwards.
|
||||||
|
if (RaceManager::get()->isBenchmarkScheduled())
|
||||||
|
startBenchmark();
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
@ -882,7 +888,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
|
|
||||||
updateBlurSlider();
|
updateBlurSlider();
|
||||||
}
|
}
|
||||||
else if (name == "vsync")
|
else if (name == "vsync") // Also handles the FPS limiter
|
||||||
{
|
{
|
||||||
GUIEngine::SpinnerWidget* vsync = getWidget<GUIEngine::SpinnerWidget>("vsync");
|
GUIEngine::SpinnerWidget* vsync = getWidget<GUIEngine::SpinnerWidget>("vsync");
|
||||||
assert( vsync != NULL );
|
assert( vsync != NULL );
|
||||||
@ -904,7 +910,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||||
update_swap_interval(UserConfigParams::m_swap_interval);
|
update_swap_interval(UserConfigParams::m_swap_interval);
|
||||||
#endif
|
#endif
|
||||||
}
|
} // vSync
|
||||||
else if (name == "scale_rtts")
|
else if (name == "scale_rtts")
|
||||||
{
|
{
|
||||||
GUIEngine::SpinnerWidget* scale_rtts_level =
|
GUIEngine::SpinnerWidget* scale_rtts_level =
|
||||||
@ -924,7 +930,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
updateScaleRTTsSlider();
|
updateScaleRTTsSlider();
|
||||||
}
|
} // scale_rtts
|
||||||
else if (name == "benchmarkCurrent")
|
else if (name == "benchmarkCurrent")
|
||||||
{
|
{
|
||||||
// TODO - Add the possibility to benchmark more tracks and define replay benchmarks in
|
// TODO - Add the possibility to benchmark more tracks and define replay benchmarks in
|
||||||
@ -935,20 +941,27 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
Log::fatal("OptionsScreenVideo", "Can't open replay for benchmark!");
|
Log::fatal("OptionsScreenVideo", "Can't open replay for benchmark!");
|
||||||
RaceManager::get()->setRaceGhostKarts(true);
|
|
||||||
|
|
||||||
RaceManager::get()->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
|
// Avoid crashing, when switching between advanced lighting and the old renderer
|
||||||
ReplayPlay::ReplayData bench_rd = ReplayPlay::get()->getCurrentReplayData();
|
// before starting a performance test, ensure the image quality setting is applied
|
||||||
RaceManager::get()->setReverseTrack(bench_rd.m_reverse);
|
if (m_prev_adv_pipline != UserConfigParams::m_dynamic_lights &&
|
||||||
RaceManager::get()->setRecordRace(false);
|
CVS->isGLSL())
|
||||||
RaceManager::get()->setWatchingReplay(true);
|
{
|
||||||
RaceManager::get()->setDifficulty((RaceManager::Difficulty)bench_rd.m_difficulty);
|
irr_driver->sameRestart();
|
||||||
|
// We cannot start the benchmark immediately, in case we just restarted the graphics engine
|
||||||
// The race manager automatically adds karts for the ghosts
|
RaceManager::get()->scheduleBenchmark();
|
||||||
RaceManager::get()->setNumKarts(0);
|
}
|
||||||
RaceManager::get()->setBenchmarking(true);
|
else if (m_prev_img_quality != getImageQuality())
|
||||||
RaceManager::get()->startWatchingReplay(bench_rd.m_track_name, bench_rd.m_laps);
|
{
|
||||||
}
|
// TODO - check if this is enough for the setting to be properly applied
|
||||||
|
irr_driver->setMaxTextureSize();
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
} // benchmarkCurrent
|
||||||
// TODO - Add a standard benchmark testing multiple presets
|
// TODO - Add a standard benchmark testing multiple presets
|
||||||
/*else if (name == "benchmarkStandard")
|
/*else if (name == "benchmarkStandard")
|
||||||
{
|
{
|
||||||
@ -998,6 +1011,24 @@ 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()
|
||||||
{
|
{
|
||||||
if (getWidget("fullscreen")->isVisible() &&
|
if (getWidget("fullscreen")->isVisible() &&
|
||||||
|
@ -104,6 +104,7 @@ private:
|
|||||||
void updateResolutionsList();
|
void updateResolutionsList();
|
||||||
void configResolutionsList();
|
void configResolutionsList();
|
||||||
void initPresets();
|
void initPresets();
|
||||||
|
void startBenchmark();
|
||||||
static void onScrollResolutionsList(void* data);
|
static void onScrollResolutionsList(void* data);
|
||||||
public:
|
public:
|
||||||
friend class GUIEngine::ScreenSingleton<OptionsScreenVideo>;
|
friend class GUIEngine::ScreenSingleton<OptionsScreenVideo>;
|
||||||
|
Loading…
Reference in New Issue
Block a user