forked from mirrors/0ad
Use dynamic budget for progressive load timeout
The progressive load timeout was hardcoded to 10ms, causing the CPU to be mostly idle during map loading. This commit replaces the fixed value with a dynamic budget derived from the display refresh rate when VSync is enabled, or from the configured adaptivefps.menu limit otherwise. Fixes: #8774
This commit is contained in:
@@ -317,6 +317,7 @@
|
||||
{ "nick": "voroskoi" },
|
||||
{ "nick": "vts", "name": "Jeroen DR" },
|
||||
{ "nick": "vv221", "name": "Antoine Le Gonidec" },
|
||||
{ "nick": "vyordan", "name": "Yordan Vasquez" },
|
||||
{ "nick": "wacko", "name": "Andrew Spiering" },
|
||||
{ "nick": "WhiteTreePaladin", "name": "Brian Ashley" },
|
||||
{ "nick": "wowgetoffyourcellphone", "name": "Justus Avramenko" },
|
||||
|
||||
+8
-1
@@ -93,6 +93,7 @@ that of Atlas depending on commandline parameters.
|
||||
#include <SDL_stdinc.h>
|
||||
#include <SDL_timer.h>
|
||||
#include <SDL_video.h>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
@@ -327,11 +328,17 @@ static int ProgressiveLoad()
|
||||
{
|
||||
PROFILE3("progressive load");
|
||||
|
||||
const double budget = 1.0 / std::clamp(
|
||||
g_VideoMode.IsVSyncEnabled() ?
|
||||
static_cast<double>(g_VideoMode.GetDesktopFreq()) :
|
||||
g_ConfigDB.Get("adaptivefps.menu", 60.0),
|
||||
10.0, 360.0);
|
||||
|
||||
std::wstring description;
|
||||
int progressPercent{0};
|
||||
try
|
||||
{
|
||||
const PS::Loader::ProgressiveLoadResult result{PS::Loader::ProgressiveLoad(10e-3)};
|
||||
const PS::Loader::ProgressiveLoadResult result{PS::Loader::ProgressiveLoad(budget)};
|
||||
description = result.nextDescription;
|
||||
progressPercent = result.progressPercent;
|
||||
switch(result.status)
|
||||
|
||||
Reference in New Issue
Block a user