1
0
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:
vyordan
2026-05-04 11:20:13 -06:00
committed by Phosit
parent f38b956eb3
commit 843f39ba55
2 changed files with 9 additions and 1 deletions
@@ -317,6 +317,7 @@
{ "nick": "voroskoi" }, { "nick": "voroskoi" },
{ "nick": "vts", "name": "Jeroen DR" }, { "nick": "vts", "name": "Jeroen DR" },
{ "nick": "vv221", "name": "Antoine Le Gonidec" }, { "nick": "vv221", "name": "Antoine Le Gonidec" },
{ "nick": "vyordan", "name": "Yordan Vasquez" },
{ "nick": "wacko", "name": "Andrew Spiering" }, { "nick": "wacko", "name": "Andrew Spiering" },
{ "nick": "WhiteTreePaladin", "name": "Brian Ashley" }, { "nick": "WhiteTreePaladin", "name": "Brian Ashley" },
{ "nick": "wowgetoffyourcellphone", "name": "Justus Avramenko" }, { "nick": "wowgetoffyourcellphone", "name": "Justus Avramenko" },
+8 -1
View File
@@ -93,6 +93,7 @@ that of Atlas depending on commandline parameters.
#include <SDL_stdinc.h> #include <SDL_stdinc.h>
#include <SDL_timer.h> #include <SDL_timer.h>
#include <SDL_video.h> #include <SDL_video.h>
#include <algorithm>
#include <chrono> #include <chrono>
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
@@ -327,11 +328,17 @@ static int ProgressiveLoad()
{ {
PROFILE3("progressive load"); 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; std::wstring description;
int progressPercent{0}; int progressPercent{0};
try try
{ {
const PS::Loader::ProgressiveLoadResult result{PS::Loader::ProgressiveLoad(10e-3)}; const PS::Loader::ProgressiveLoadResult result{PS::Loader::ProgressiveLoad(budget)};
description = result.nextDescription; description = result.nextDescription;
progressPercent = result.progressPercent; progressPercent = result.progressPercent;
switch(result.status) switch(result.status)