mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-11-22 13:47:11 +00:00
Keep Dynamic MFG's back-off across restarts
With the target as a cap it kept stepping down and undoing it every 5-12 s. A restart (FG back on, the window back in front) now keeps the back-off, and a block lifts only once the reachable rate is 10% over the highest one a step down failed at.
This commit is contained in:
1 parent
dcf3a44b06
commit
eba224dcdf
2 files changed
+25
-6
No files matched your search
@@ -14,8 +14,9 @@
|
||||
// - A step down after which the presented rate stays more than 7% under the target is undone (judged on the frames
|
||||
// after the 3 still in flight for the old count, at least 6 and 0.4 s, nothing else decided for 1.5 s), and so is
|
||||
// one whose mean over those 1.5 s is more than 3% under (the bar Up uses, or the two take turns). The next waits
|
||||
// twice as long (5 s up to 60 s), unless the reachable rate has since grown by 10%: a GPU bound game's low
|
||||
// latency sleep also holds the CPU while the GPU works, so that measure can promise more than the GPU gives.
|
||||
// twice as long (5 s up to 60 s), unless the reachable rate has since grown by 10% over the highest it failed at
|
||||
// (it swings 250-410 fps from noise alone): a GPU bound game's low latency sleep also holds the CPU while the GPU
|
||||
// works, so that measure can promise more than the GPU gives. A pause or focus change keeps all of this.
|
||||
class XeFG_DynamicCap
|
||||
{
|
||||
public:
|
||||
@@ -95,7 +96,7 @@ class XeFG_DynamicCap
|
||||
{
|
||||
_backoffMs = std::min(_backoffMs * 2.0, kMaxBackoffMs);
|
||||
_downBlockedUntilMs = s.nowMs + _backoffMs;
|
||||
_failedReachable = _downReachable;
|
||||
_failedReachable = std::max(_failedReachable, _downReachable);
|
||||
return Change(count + 1, s.nowMs, Reason::Undo, reachable);
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ class XeFG_DynamicCap
|
||||
{
|
||||
_backoffMs = std::min(_backoffMs * 2.0, kMaxBackoffMs);
|
||||
_downBlockedUntilMs = s.nowMs + _backoffMs;
|
||||
_failedReachable = _downReachable;
|
||||
_failedReachable = std::max(_failedReachable, _downReachable);
|
||||
return Change(count + 1, s.nowMs, Reason::Undo, reachable);
|
||||
}
|
||||
|
||||
@@ -188,6 +189,24 @@ class XeFG_DynamicCap
|
||||
|
||||
void Reset() { *this = XeFG_DynamicCap {}; }
|
||||
|
||||
// FG back on or the game back in front: the averages start over, what failed step downs taught stays
|
||||
void Restart()
|
||||
{
|
||||
const auto blockedUntil = _downBlockedUntilMs;
|
||||
const auto backoff = _backoffMs;
|
||||
const auto failed = _failedReachable;
|
||||
const auto sleepShare = _sleepShare;
|
||||
const auto sleepSeen = _sleepSeen;
|
||||
|
||||
Reset();
|
||||
|
||||
_downBlockedUntilMs = blockedUntil;
|
||||
_backoffMs = backoff;
|
||||
_failedReachable = failed;
|
||||
_sleepShare = sleepShare;
|
||||
_sleepSeen = sleepSeen;
|
||||
}
|
||||
|
||||
Reason LastReason() const { return _reason; }
|
||||
// The reachable real frame rate the last change was decided on
|
||||
double DecisionReachableFps() const { return _decisionReachable; }
|
||||
|
||||
@@ -47,7 +47,7 @@ XeFG_DynamicMFG::Result XeFG_DynamicMFG::Update(int targetCount, int framesToInt
|
||||
LOG_INFO("Dynamic MFG: the game's window is back in front, starting over at {}X", current + 1);
|
||||
_unfocused = false;
|
||||
_count.Reset();
|
||||
_cap.Reset();
|
||||
_cap.Restart();
|
||||
_capActive = false;
|
||||
}
|
||||
const double waitMs = sleepMs + presentWaitMs;
|
||||
@@ -143,7 +143,7 @@ XeFG_DynamicMFG::Result XeFG_DynamicMFG::Update(int targetCount, int framesToInt
|
||||
void XeFG_DynamicMFG::Restart()
|
||||
{
|
||||
_count.Restart();
|
||||
_cap.Reset();
|
||||
_cap.Restart();
|
||||
}
|
||||
|
||||
int XeFG_DynamicMFG::Focused(HWND window)
|
||||
|
||||
Reference in new issue
Block a user