Skip to content

Commit

Permalink
prevent redundant Restore calls on performance manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Jul 9, 2023
1 parent 6381a57 commit c8022c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
46 changes: 26 additions & 20 deletions HandheldCompanion/Managers/PerformanceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ private void ProfileManager_Applied(Profile profile, ProfileUpdateSource source)
StartTDPWatchdog();
}
else if (cpuWatchdog.Enabled)
{
{
StopTDPWatchdog(true);

// restore default TDP (if not AutoTDP is enabled)
if (!profile.AutoTDPEnabled)
RestoreTDP(true);
StopTDPWatchdog();
}

// apply profile defined AutoTDP
Expand All @@ -157,11 +158,12 @@ private void ProfileManager_Applied(Profile profile, ProfileUpdateSource source)
StartAutoTDPWatchdog();
}
else if (autoWatchdog.Enabled)
{
{
StopAutoTDPWatchdog(true);

// restore default TDP (if not manual TDP is enabled)
if (!profile.TDPOverrideEnabled)
RestoreTDP(true);
StopAutoTDPWatchdog();
}

// apply profile defined GPU
Expand All @@ -172,8 +174,8 @@ private void ProfileManager_Applied(Profile profile, ProfileUpdateSource source)
}
else if (gfxWatchdog.Enabled)
{
StopGPUWatchdog(true);
RestoreGPUClock(true);
StopGPUWatchdog();
}

// apply profile defined EPP
Expand All @@ -188,23 +190,23 @@ private void ProfileManager_Discarded(Profile profile)
// restore default TDP
if (profile.TDPOverrideEnabled)
{
RestoreTDP(true);
StopTDPWatchdog();
StopTDPWatchdog(true);
RestoreTDP(true);
}

// restore default TDP
if (profile.AutoTDPEnabled)
{
RestoreTDP(true);
StopAutoTDPWatchdog();
StopTDPWatchdog();
{
StopAutoTDPWatchdog(true);
StopTDPWatchdog(true);
RestoreTDP(true);
}

// restore default GPU frequency
if (profile.GPUOverrideEnabled)
{
RestoreGPUClock(true);
StopGPUWatchdog();
StopGPUWatchdog(true);
RestoreGPUClock(true);
}

// (un)apply profile defined EPP
Expand Down Expand Up @@ -541,14 +543,11 @@ internal void StartGPUWatchdog()
gfxWatchdog.Start();
}

internal void StopGPUWatchdog()
internal void StopGPUWatchdog(bool immediate = false)
{
gfxWatchdogPendingStop = true;
}

internal void StopTDPWatchdog()
{
cpuWatchdogPendingStop = true;
if (immediate)
gfxWatchdog.Stop();
}

internal void StartTDPWatchdog()
Expand All @@ -558,12 +557,19 @@ internal void StartTDPWatchdog()
cpuWatchdog.Start();
}

internal void StopTDPWatchdog(bool immediate = false)
{
cpuWatchdogPendingStop = true;
if (immediate)
cpuWatchdog.Stop();
}

internal void StartAutoTDPWatchdog()
{
autoWatchdog.Start();
}

internal void StopAutoTDPWatchdog()
internal void StopAutoTDPWatchdog(bool immediate = false)
{
autoWatchdog.Stop();
}
Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
TextWrapping="Wrap" />
<TextBlock
Name="CurrentProfileName"
Margin="6,0,0,0"
Margin="2,0,0,0"
Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="Default"
Expand Down

0 comments on commit c8022c5

Please sign in to comment.