mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 02:32:55 +08:00
Use high performance session during gameplay
This commit is contained in:
parent
3e9425fdf2
commit
bfb5098238
@ -22,6 +22,8 @@ namespace osu.Game.Performance
|
|||||||
{
|
{
|
||||||
originalGCMode = GCSettings.LatencyMode;
|
originalGCMode = GCSettings.LatencyMode;
|
||||||
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
|
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
|
||||||
|
|
||||||
|
// Without doing this, the new GC mode won't kick in until the next GC, which could be at a more noticeable point in time.
|
||||||
GC.Collect(0);
|
GC.Collect(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +31,8 @@ namespace osu.Game.Performance
|
|||||||
{
|
{
|
||||||
if (GCSettings.LatencyMode == GCLatencyMode.LowLatency)
|
if (GCSettings.LatencyMode == GCLatencyMode.LowLatency)
|
||||||
GCSettings.LatencyMode = originalGCMode;
|
GCSettings.LatencyMode = originalGCMode;
|
||||||
|
|
||||||
|
// No GC.Collect() as we were already collecting at a higher frequency in the old mode.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ using osu.Game.Input;
|
|||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
|
using osu.Game.Performance;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -140,6 +141,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private bool quickRestart;
|
private bool quickRestart;
|
||||||
|
|
||||||
|
private IDisposable? highPerformanceSession;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private INotificationOverlay? notificationOverlay { get; set; }
|
private INotificationOverlay? notificationOverlay { get; set; }
|
||||||
|
|
||||||
@ -152,6 +155,9 @@ namespace osu.Game.Screens.Play
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BatteryInfo? batteryInfo { get; set; }
|
private BatteryInfo? batteryInfo { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private HighPerformanceSessionManager? highPerformanceSessionManager { get; set; }
|
||||||
|
|
||||||
public PlayerLoader(Func<Player> createPlayer)
|
public PlayerLoader(Func<Player> createPlayer)
|
||||||
{
|
{
|
||||||
this.createPlayer = createPlayer;
|
this.createPlayer = createPlayer;
|
||||||
@ -264,6 +270,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
Debug.Assert(CurrentPlayer != null);
|
Debug.Assert(CurrentPlayer != null);
|
||||||
|
|
||||||
|
highPerformanceSession?.Dispose();
|
||||||
|
highPerformanceSession = null;
|
||||||
|
|
||||||
// prepare for a retry.
|
// prepare for a retry.
|
||||||
CurrentPlayer = null;
|
CurrentPlayer = null;
|
||||||
playerConsumed = false;
|
playerConsumed = false;
|
||||||
@ -304,6 +313,9 @@ namespace osu.Game.Screens.Play
|
|||||||
BackgroundBrightnessReduction = false;
|
BackgroundBrightnessReduction = false;
|
||||||
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||||
|
|
||||||
|
highPerformanceSession?.Dispose();
|
||||||
|
highPerformanceSession = null;
|
||||||
|
|
||||||
return base.OnExiting(e);
|
return base.OnExiting(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,6 +475,10 @@ namespace osu.Game.Screens.Play
|
|||||||
if (scheduledPushPlayer != null)
|
if (scheduledPushPlayer != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Now that everything's been loaded, we can safely switch to a higher performance session without incurring too much overhead.
|
||||||
|
// Doing this prior to the game being pushed gives us a bit of time to stabilise into the high performance mode before gameplay starts.
|
||||||
|
highPerformanceSession ??= highPerformanceSessionManager?.BeginSession();
|
||||||
|
|
||||||
scheduledPushPlayer = Scheduler.AddDelayed(() =>
|
scheduledPushPlayer = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
// ensure that once we have reached this "point of no return", readyForPush will be false for all future checks (until a new player instance is prepared).
|
// ensure that once we have reached this "point of no return", readyForPush will be false for all future checks (until a new player instance is prepared).
|
||||||
|
Loading…
Reference in New Issue
Block a user