Skip to content

Commit

Permalink
Merge pull request #27562 from EVAST9919/osu-performance
Browse files Browse the repository at this point in the history
Don't update SubTreeMasking in `OsuPlayfield`
  • Loading branch information
peppy committed Mar 12, 2024
2 parents 5b2dd95 + 88ec0cd commit e431c12
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
4 changes: 1 addition & 3 deletions osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
Expand All @@ -25,7 +23,7 @@ public DrawableOsuEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList

private partial class OsuEditorPlayfield : OsuPlayfield
{
protected override GameplayCursorContainer CreateCursor() => null;
protected override GameplayCursorContainer? CreateCursor() => null;

public OsuEditorPlayfield()
{
Expand Down
17 changes: 11 additions & 6 deletions osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
Expand All @@ -35,12 +35,16 @@ public partial class OsuPlayfield : Playfield

private readonly JudgementPooler<DrawableOsuJudgement> judgementPooler;

// For osu! gameplay, everything is always on screen.
// Skipping masking calculations improves performance in intense beatmaps (ie. https://osu.ppy.sh/beatmapsets/150945#osu/372245)
public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false;

public SmokeContainer Smoke { get; }
public FollowPointRenderer FollowPoints { get; }

public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);

protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
protected override GameplayCursorContainer? CreateCursor() => new OsuCursorContainer();

private readonly Container judgementAboveHitObjectLayer;

Expand Down Expand Up @@ -81,6 +85,7 @@ public OsuPlayfield()
public IHitPolicy HitPolicy
{
get => hitPolicy;
[MemberNotNull(nameof(hitPolicy))]
set
{
hitPolicy = value ?? throw new ArgumentNullException(nameof(value));
Expand Down Expand Up @@ -116,12 +121,12 @@ private void onJudgementLoaded(DrawableOsuJudgement judgement)
judgementAboveHitObjectLayer.Add(judgement.ProxiedAboveHitObjectsContent);
}

[BackgroundDependencyLoader(true)]
private void load(OsuRulesetConfigManager config, IBeatmap beatmap)
[BackgroundDependencyLoader]
private void load(OsuRulesetConfigManager? config, IBeatmap? beatmap)
{
config?.BindWith(OsuRulesetSetting.PlayfieldBorderStyle, playfieldBorder.PlayfieldBorderStyle);

var osuBeatmap = (OsuBeatmap)beatmap;
var osuBeatmap = (OsuBeatmap?)beatmap;

RegisterPool<HitCircle, DrawableHitCircle>(20, 100);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public partial class TestSceneGameplaySamplePlayback : PlayerTestScene
{
protected override bool AllowBackwardsSeeks => true;

private bool seek;

[Test]
public void TestAllSamplesStopDuringSeek()
{
Expand All @@ -42,7 +44,7 @@ public void TestAllSamplesStopDuringSeek()
if (!samples.Any(s => s.Playing))
return false;
Player.ChildrenOfType<GameplayClockContainer>().First().Seek(40000);
seek = true;
return true;
});

Expand All @@ -55,10 +57,27 @@ public void TestAllSamplesStopDuringSeek()

AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);

AddStep("stop seeking", () => seek = false);

AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
AddUntilStep("any sample is playing", () => Player.ChildrenOfType<PausableSkinnableSound>().Any(s => s.IsPlaying));
}

protected override void Update()
{
base.Update();

if (seek)
{
// Frame stable playback is too fast to catch up these days.
//
// We want to keep seeking while asserting various test conditions, so
// continue to seek until we unset the flag.
var gameplayClockContainer = Player.ChildrenOfType<GameplayClockContainer>().First();
gameplayClockContainer.Seek(gameplayClockContainer.CurrentTime > 30000 ? 0 : 60000);
}
}

private IEnumerable<PausableSkinnableSound> allSounds => Player.ChildrenOfType<PausableSkinnableSound>();
private IEnumerable<PausableSkinnableSound> allLoopingSounds => allSounds.Where(sound => sound.Looping);

Expand Down

0 comments on commit e431c12

Please sign in to comment.