1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:02:54 +08:00

Change frame stable catch-up method to allow for much faster sync

This commit is contained in:
Dean Herbert 2024-01-18 02:18:20 +09:00
parent e260e75fac
commit c362a93a36
No known key found for this signature in database
3 changed files with 8 additions and 11 deletions

View File

@ -129,10 +129,8 @@ namespace osu.Game.Tests.Visual.Gameplay
checkRate(1); checkRate(1);
} }
private const int max_frames_catchup = 50;
private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () => private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () =>
mainContainer.Child = new FrameStabilityContainer(gameplayStartTime) { MaxCatchUpFrames = max_frames_catchup } mainContainer.Child = new FrameStabilityContainer(gameplayStartTime)
.WithChild(consumer = new ClockConsumingChild())); .WithChild(consumer = new ClockConsumingChild()));
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time); private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);

View File

@ -45,10 +45,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time) gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time)
{ {
Child = frameStabilityContainer = new FrameStabilityContainer Child = frameStabilityContainer = new FrameStabilityContainer()
{
MaxCatchUpFrames = 1
}
} }
}); });

View File

@ -25,9 +25,9 @@ namespace osu.Game.Rulesets.UI
public ReplayInputHandler? ReplayInputHandler { get; set; } public ReplayInputHandler? ReplayInputHandler { get; set; }
/// <summary> /// <summary>
/// The number of frames (per parent frame) which can be run in an attempt to catch-up to real-time. /// The number of CPU milliseconds to spend at most during seek catch-up.
/// </summary> /// </summary>
public int MaxCatchUpFrames { get; set; } = 5; private const double max_catchup_milliseconds = 10;
/// <summary> /// <summary>
/// Whether to enable frame-stable playback. /// Whether to enable frame-stable playback.
@ -61,6 +61,8 @@ namespace osu.Game.Rulesets.UI
/// </summary> /// </summary>
private readonly FramedClock framedClock; private readonly FramedClock framedClock;
private readonly Stopwatch stopwatch = new Stopwatch();
/// <summary> /// <summary>
/// The current direction of playback to be exposed to frame stable children. /// The current direction of playback to be exposed to frame stable children.
/// </summary> /// </summary>
@ -99,7 +101,7 @@ namespace osu.Game.Rulesets.UI
public override bool UpdateSubTree() public override bool UpdateSubTree()
{ {
int loops = MaxCatchUpFrames; stopwatch.Restart();
do do
{ {
@ -112,7 +114,7 @@ namespace osu.Game.Rulesets.UI
base.UpdateSubTree(); base.UpdateSubTree();
UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat); UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
} while (state == PlaybackState.RequiresCatchUp && loops-- > 0); } while (state == PlaybackState.RequiresCatchUp && stopwatch.ElapsedMilliseconds < max_catchup_milliseconds);
return true; return true;
} }