-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5686 from peppy/move-renderer-info-display
Show renderer information above frame statistics display
- Loading branch information
Showing
4 changed files
with
31 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.Buffers; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Threading; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Platform; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
|
||
namespace osu.Framework.Graphics.Performance | ||
{ | ||
internal partial class PerformanceOverlay : FillFlowContainer<FrameStatisticsDisplay>, IStateful<FrameStatisticsMode> | ||
internal partial class PerformanceOverlay : FillFlowContainer, IStateful<FrameStatisticsMode> | ||
{ | ||
private readonly GameThread[] threads; | ||
[Resolved] | ||
private GameHost host { get; set; } = null!; | ||
|
||
private FrameStatisticsMode state; | ||
|
||
public event Action<FrameStatisticsMode> StateChanged; | ||
public event Action<FrameStatisticsMode>? StateChanged; | ||
|
||
private bool initialised; | ||
|
||
|
@@ -36,6 +38,11 @@ public FrameStatisticsMode State | |
} | ||
} | ||
|
||
public PerformanceOverlay() | ||
{ | ||
Direction = FillDirection.Vertical; | ||
} | ||
|
||
protected override void LoadComplete() | ||
{ | ||
base.LoadComplete(); | ||
|
@@ -58,15 +65,22 @@ private void updateState() | |
|
||
var uploadPool = createUploadPool(); | ||
|
||
foreach (GameThread t in threads) | ||
Add(new SpriteText | ||
{ | ||
Text = $"Renderer: {host.RendererInfo}", | ||
Alpha = 0.75f, | ||
Origin = Anchor.TopRight, | ||
}); | ||
|
||
foreach (GameThread t in host.Threads) | ||
Add(new FrameStatisticsDisplay(t, uploadPool) { State = state }); | ||
} | ||
|
||
this.FadeIn(100); | ||
break; | ||
} | ||
|
||
foreach (FrameStatisticsDisplay d in Children) | ||
foreach (FrameStatisticsDisplay d in Children.OfType<FrameStatisticsDisplay>()) | ||
d.State = state; | ||
|
||
StateChanged?.Invoke(State); | ||
|
@@ -77,16 +91,10 @@ private ArrayPool<Rgba32> createUploadPool() | |
// bucket size should be enough to allow some overhead when running multi-threaded with draw at 60hz. | ||
const int max_expected_thread_update_rate = 2000; | ||
|
||
int bucketSize = threads.Length * (max_expected_thread_update_rate / 60); | ||
int bucketSize = host.Threads.Count() * (max_expected_thread_update_rate / 60); | ||
|
||
return ArrayPool<Rgba32>.Create(FrameStatisticsDisplay.HEIGHT, bucketSize); | ||
} | ||
|
||
public PerformanceOverlay(IEnumerable<GameThread> threads) | ||
{ | ||
this.threads = threads.ToArray(); | ||
Direction = FillDirection.Vertical; | ||
} | ||
} | ||
|
||
public enum FrameStatisticsMode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters