mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:07:52 +08:00
Change frame stable catch-up method to allow for much faster sync
This commit is contained in:
parent
e260e75fac
commit
c362a93a36
@ -129,10 +129,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
checkRate(1);
|
||||
}
|
||||
|
||||
private const int max_frames_catchup = 50;
|
||||
|
||||
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()));
|
||||
|
||||
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);
|
||||
|
@ -45,10 +45,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
},
|
||||
gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time)
|
||||
{
|
||||
Child = frameStabilityContainer = new FrameStabilityContainer
|
||||
{
|
||||
MaxCatchUpFrames = 1
|
||||
}
|
||||
Child = frameStabilityContainer = new FrameStabilityContainer()
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -25,9 +25,9 @@ namespace osu.Game.Rulesets.UI
|
||||
public ReplayInputHandler? ReplayInputHandler { get; set; }
|
||||
|
||||
/// <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>
|
||||
public int MaxCatchUpFrames { get; set; } = 5;
|
||||
private const double max_catchup_milliseconds = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable frame-stable playback.
|
||||
@ -61,6 +61,8 @@ namespace osu.Game.Rulesets.UI
|
||||
/// </summary>
|
||||
private readonly FramedClock framedClock;
|
||||
|
||||
private readonly Stopwatch stopwatch = new Stopwatch();
|
||||
|
||||
/// <summary>
|
||||
/// The current direction of playback to be exposed to frame stable children.
|
||||
/// </summary>
|
||||
@ -99,7 +101,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public override bool UpdateSubTree()
|
||||
{
|
||||
int loops = MaxCatchUpFrames;
|
||||
stopwatch.Restart();
|
||||
|
||||
do
|
||||
{
|
||||
@ -112,7 +114,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
base.UpdateSubTree();
|
||||
UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
|
||||
} while (state == PlaybackState.RequiresCatchUp && loops-- > 0);
|
||||
} while (state == PlaybackState.RequiresCatchUp && stopwatch.ElapsedMilliseconds < max_catchup_milliseconds);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user