Gondwana Game Engine Development (master) - 2.7.0
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
ProfilerWidget.cs
1using System.Diagnostics;
2using System.Drawing;
3using System.Numerics;
4using System.Text;
13using SkiaSharp;
14
15namespace Gondwana.Widgets.Hud;
16
32
36[Flags]
38{
42 None = 0,
43
47 Scene = 1 << 0,
48
52 View = 1 << 1,
53
57 Backbuffer = 1 << 2,
58
63
67 Msaa = 1 << 4,
68
73}
74
80{
88 TelemetrySnapshot? snapshot,
89 RenderSurfaceHostBase renderSurfaceHost,
90 View view)
91 {
92 Snapshot = snapshot;
93 RenderSurfaceHost = renderSurfaceHost ?? throw new ArgumentNullException(nameof(renderSurfaceHost));
94 View = view ?? throw new ArgumentNullException(nameof(view));
95 }
96
101
106
110 public View View { get; }
111}
112
121public sealed class ProfilerWidget : ContainerWidget
122{
123 private static readonly TimeSpan MinimumRefreshInterval = TimeSpan.FromMilliseconds(10);
124 private static readonly TimeSpan MaximumRefreshInterval = TimeSpan.FromMinutes(1);
125 private const int MetricSelectorHeight = 30;
126 private const int MetricSelectorWidth = 92;
127 private const int MetricSelectorMargin = 4;
128
129 private readonly Dictionary<string, bool> _sourceVisibility = new(StringComparer.OrdinalIgnoreCase);
130 private readonly Dictionary<string, bool> _measurementVisibility = new(StringComparer.Ordinal);
131 private readonly Dictionary<string, bool> _sourceMeasurementVisibility = new(StringComparer.Ordinal);
132 private readonly Dictionary<string, string> _measurementDescriptions = new(StringComparer.Ordinal);
133 private readonly Dictionary<int, string> _renderedMetricLines = [];
134 private readonly TooltipWidget _measurementTooltip;
135 private Size _size;
136 private TimeSpan _refreshInterval = TimeSpan.FromMilliseconds(250);
137 private long _lastRefreshTimestamp;
138 private IDisposable? _collectionRequest;
139 private bool _disposed;
140 private string _headerText = "Gondwana Runtime Profiler";
141 private ProfilerMeasurementVisibilityMode _measurementVisibilityMode = ProfilerMeasurementVisibilityMode.All;
142 private bool _measurementTooltipsEnabled = true;
143 private bool _showMetricSelector = true;
144 private TelemetrySnapshot? _latestSnapshot;
145 private ButtonWidget? _metricSelectorButton;
146 private ListBoxWidget? _metricSelectorList;
147 private readonly List<MetricSelectorRow> _metricSelectorRows = [];
148 private string? _metricSelectorSignature;
149 private bool _metricSelectorOpen;
150 private int _profilerZOrder;
151 private bool _showHeader = true;
152 private bool _showSnapshotMetadata = true;
153 private bool _showSourceHeaders = true;
154 private bool _showUnavailableMeasurements;
155
164 RenderSurfaceHostBase renderSurfaceHost,
165 View view,
166 Rectangle bounds,
167 string? nickname = null)
168 : base(
169 renderSurfaceHost,
171 ValidateBounds(bounds).Location,
172 nickname)
173 {
174 ArgumentNullException.ThrowIfNull(view);
175
176 _size = bounds.Size;
177 Rectangle displayBounds = GetDisplayBounds(bounds, showSelector: true);
178
179 Display = new LabelWidget(
180 renderSurfaceHost,
181 view,
182 displayBounds,
183 nickname: $"{Nickname}.display")
184 {
185 VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
186 VerticalScrollEndPaddingPx = 8f
187 };
188
189 Display
190 .SetFont(SKTypeface.Default, 15f, minSize: 9f)
191 .SetColors(
192 SKColors.White,
193 new SKColor(
194 0,
195 0,
196 0,
197 102))
198 .SetAlignment(SKTextAlign.Left, TextBlock.VerticalAlign.Top)
199 .SetPadding(12f, 10f)
200 .EnableWrapping(false);
201
202 Add(
203 Display,
204 new Vector2(
205 displayBounds.X - bounds.X,
206 displayBounds.Y - bounds.Y));
207
208 _measurementTooltip = new TooltipWidget(
209 renderSurfaceHost,
210 view,
211 new Size(420, 78),
212 $"{Nickname}.tooltip");
213
214 IsInputEnabled = true;
217 CanReceiveFocus = false;
218
219 PointerMove += OnProfilerPointerMove;
220 PointerLeave += OnProfilerPointerLeave;
221 Display.PointerMove += OnProfilerPointerMove;
222 Display.PointerLeave += OnProfilerPointerLeave;
223 Display.MouseWheel += OnProfilerMouseWheel;
224
225 Display.SetText("Gondwana Runtime Profiler\nInactive. Call Show() to collect telemetry.");
226 SetIsVisible(false);
227 }
228
232 public LabelWidget Display { get; }
233
237 public Rectangle Bounds
238 {
239 get
240 {
241 Vector2 position = GetPosition();
242
243 return new Rectangle(
244 (int)MathF.Round(position.X),
245 (int)MathF.Round(position.Y),
246 _size.Width,
247 _size.Height);
248 }
249 }
250
254 public Size Size
255 {
256 get => _size;
257 set
258 {
259 ValidateSize(value);
260 _size = value;
261 ApplyLayout();
262 }
263 }
264
272 public TimeSpan RefreshInterval
273 {
274 get => _refreshInterval;
275 set
276 {
277 if (value < MinimumRefreshInterval || value > MaximumRefreshInterval)
278 {
279 throw new ArgumentOutOfRangeException(
280 nameof(value),
281 value,
282 "Profiler widget refresh interval must be between 10 ms and one minute.");
283 }
284
285 _refreshInterval = value;
286 }
287 }
288
293 {
294 get => _measurementVisibilityMode;
295 set
296 {
297 if (!Enum.IsDefined(value))
298 throw new ArgumentOutOfRangeException(nameof(value));
299
300 if (_measurementVisibilityMode == value)
301 return;
302
303 _measurementVisibilityMode = value;
304 }
305 }
306
310 public string HeaderText
311 {
312 get => _headerText;
313 set
314 {
315 ArgumentException.ThrowIfNullOrWhiteSpace(value);
316 _headerText = value;
317 }
318 }
319
323 public bool ShowHeader
324 {
325 get => _showHeader;
326 set => _showHeader = value;
327 }
328
333 {
334 get => _showSnapshotMetadata;
335 set => _showSnapshotMetadata = value;
336 }
337
342 {
343 get => _showSourceHeaders;
344 set => _showSourceHeaders = value;
345 }
346
352 {
353 get => _showUnavailableMeasurements;
354 set
355 {
356 if (_showUnavailableMeasurements == value)
357 return;
358
359 _showUnavailableMeasurements = value;
360 }
361 }
362
367 {
368 get => _measurementTooltipsEnabled;
369 set
370 {
371 if (_measurementTooltipsEnabled == value)
372 return;
373
374 _measurementTooltipsEnabled = value;
375
376 if (!value)
377 _measurementTooltip.HideTooltip();
378 }
379 }
380
390 {
391 get => _showMetricSelector;
392 set
393 {
394 if (_showMetricSelector == value)
395 return;
396
397 _showMetricSelector = value;
398 _metricSelectorSignature = null;
399
400 if (!value)
401 DisposeMetricSelector();
402
403 ApplyLayout();
404
405 if (value && _latestSnapshot is not null)
406 EnsureMetricSelector(_latestSnapshot);
407 }
408 }
409
413 public TooltipWidget MeasurementTooltip => _measurementTooltip;
414
423
432 public Func<ProfilerWidgetExtensionContext, IEnumerable<string>?>? AdditionalLinesProvider { get; set; }
433
437 public bool IsCollectionActive => _collectionRequest is not null;
438
445 public ProfilerWidget SetSourceVisible(string sourceName, bool visible)
446 {
447 ArgumentException.ThrowIfNullOrWhiteSpace(sourceName);
448 _sourceVisibility[sourceName] = visible;
449 return this;
450 }
451
458 public ProfilerWidget SetMeasurementVisible(string metricKey, bool visible)
459 {
460 ValidateMetricKey(metricKey);
461 _measurementVisibility[metricKey] = visible;
462 return this;
463 }
464
473 string sourceName,
474 string metricKey,
475 bool visible)
476 {
477 ArgumentException.ThrowIfNullOrWhiteSpace(sourceName);
478 ValidateMetricKey(metricKey);
479 _sourceMeasurementVisibility[CreateSourceMetricKey(sourceName, metricKey)] = visible;
480 return this;
481 }
482
488 {
489 _sourceVisibility.Clear();
490 _measurementVisibility.Clear();
491 _sourceMeasurementVisibility.Clear();
492 return this;
493 }
494
501 public ProfilerWidget SetMeasurementDescription(string metricKey, string? description)
502 {
503 ValidateMetricKey(metricKey);
504
505 if (string.IsNullOrWhiteSpace(description))
506 _measurementDescriptions.Remove(metricKey);
507 else
508 _measurementDescriptions[metricKey] = description.Trim();
509
510 return this;
511 }
512
519 public bool IsMeasurementVisible(string sourceName, string metricKey)
520 {
521 ArgumentException.ThrowIfNullOrWhiteSpace(sourceName);
522 ValidateMetricKey(metricKey);
523 return ResolveMeasurementVisibility(sourceName, metricKey, TelemetryAvailability.Available);
524 }
525
532 public ProfilerWidget SetColors(SKColor foreground, SKColor background)
533 {
534 Display.SetColors(foreground, background);
535 return this;
536 }
537
545 public ProfilerWidget SetFont(SKTypeface typeface, float size, float? minSize = null)
546 {
547 Display.SetFont(typeface, size, minSize);
548 return this;
549 }
550
557 {
558 _profilerZOrder = zOrder;
559 Display.SetLabelZOrder(zOrder);
560 _metricSelectorButton?.SetButtonZOrder(zOrder + 100);
561 _metricSelectorList?.SetListBoxZOrder(zOrder + 200);
562 _measurementTooltip.SetTooltipZOrder(zOrder + 1000);
563 return this;
564 }
565
571 {
572 if (_disposed)
573 return this;
574
576 _latestSnapshot = snapshot;
577
578 string text = FormatSnapshot(snapshot);
579 CaptureRenderedMetricLines(text);
580 Display.SetText(text);
581
582 if (snapshot is not null)
583 EnsureMetricSelector(snapshot);
584
585 return this;
586 }
587
589 protected override void ProcessShown()
590 {
591 base.ProcessShown();
592
593 if (!_metricSelectorOpen)
594 _metricSelectorList?.Hide();
595
596 if (_collectionRequest is not null)
597 return;
598
599 _collectionRequest = Engine.Instance.Profiler.Start();
600 _lastRefreshTimestamp = 0;
601 Engine.Instance.AfterBackgroundTasksExecute += OnAfterBackgroundTasksExecute;
602 Refresh();
603 }
604
606 protected override void ProcessHidden()
607 {
608 _measurementTooltip.HideTooltip();
609 _metricSelectorOpen = false;
610 _metricSelectorList?.Hide();
611 StopCollection();
612 base.ProcessHidden();
613 }
614
616 public override void Dispose()
617 {
618 if (_disposed)
619 return;
620
621 _disposed = true;
622
623 PointerMove -= OnProfilerPointerMove;
624 PointerLeave -= OnProfilerPointerLeave;
625 Display.PointerMove -= OnProfilerPointerMove;
626 Display.PointerLeave -= OnProfilerPointerLeave;
627 Display.MouseWheel -= OnProfilerMouseWheel;
628
629 _measurementTooltip.HideTooltip();
630 _measurementTooltip.Dispose();
631 DisposeMetricSelector();
632 StopCollection();
633 base.Dispose();
634 }
635
636 private void OnAfterBackgroundTasksExecute()
637 {
638 if (_collectionRequest is null)
639 return;
640
641 long now = Stopwatch.GetTimestamp();
642
643 if (_lastRefreshTimestamp != 0 &&
644 Stopwatch.GetElapsedTime(_lastRefreshTimestamp, now) < RefreshInterval)
645 {
646 return;
647 }
648
649 _lastRefreshTimestamp = now;
650 Refresh();
651 }
652
653 private void StopCollection()
654 {
655 Engine.Instance.AfterBackgroundTasksExecute -= OnAfterBackgroundTasksExecute;
656 _collectionRequest?.Dispose();
657 _collectionRequest = null;
658 _lastRefreshTimestamp = 0;
659 }
660
661 private string FormatSnapshot(TelemetrySnapshot? snapshot)
662 {
663 var text = new StringBuilder();
664
665 if (ShowHeader)
666 text.AppendLine(HeaderText);
667
668 View? view = View;
669
670 if (view is not null)
671 {
672 var extensionContext = new ProfilerWidgetExtensionContext(
673 snapshot,
675 view);
676
677 AppendAdditionalLines(text, extensionContext);
678 AppendRuntimeContext(text, extensionContext);
679 }
680
681 if (snapshot is null)
682 {
683 text.Append("Waiting for first completed telemetry window...");
684 return text.ToString().TrimEnd();
685 }
686
688 {
689 text.Append("Generation ")
690 .Append(snapshot.Generation)
691 .Append(" | window ")
692 .Append((snapshot.ElapsedSeconds * 1000d).ToString("0.0"))
693 .Append(" ms");
694
695 if (snapshot.Truncated)
696 text.Append(" | detail truncated");
697
698 text.AppendLine();
699 }
700
701 bool wroteSource = false;
702
703 foreach (TelemetrySourceSnapshot source in snapshot.Sources)
704 {
705 if (!IsSourceVisible(source.Name))
706 continue;
707
708 var metrics = source.Metrics
709 .Where(pair => ResolveMeasurementVisibility(
710 source.Name,
711 pair.Key,
712 pair.Value.Availability))
713 .OrderBy(pair => pair.Key, StringComparer.Ordinal)
714 .ToArray();
715
716 if (metrics.Length == 0)
717 continue;
718
719 if (wroteSource)
720 text.AppendLine();
721
723 {
724 text.Append(source.Name)
725 .Append(" [")
726 .Append(source.Backend)
727 .AppendLine("]");
728 }
729
730 foreach (KeyValuePair<string, TelemetrySummary> pair in metrics)
731 {
732 text.Append(" ")
733 .Append(pair.Key)
734 .Append(": ")
735 .AppendLine(FormatSummary(pair.Value, snapshot.ElapsedSeconds));
736 }
737
738 wroteSource = true;
739 }
740
741 if (!wroteSource)
742 text.Append("No measurements selected.");
743
744 return text.ToString().TrimEnd();
745 }
746
747 private void AppendAdditionalLines(
748 StringBuilder text,
749 ProfilerWidgetExtensionContext context)
750 {
751 IEnumerable<string>? lines = AdditionalLinesProvider?.Invoke(context);
752
753 if (lines is null)
754 return;
755
756 foreach (string line in lines)
757 text.AppendLine(line ?? string.Empty);
758 }
759
760 private void AppendRuntimeContext(
761 StringBuilder text,
762 ProfilerWidgetExtensionContext context)
763 {
764 if ((ContextInfo & ProfilerContextInfo.Scene) != 0)
765 {
766 var scene = context.RenderSurfaceHost.Scene;
767 long gridCells = scene.SceneLayers.Sum(static layer => (long)layer.GridColumnCount * layer.GridRowCount);
768
769 text.Append("Animating tiles: ")
770 .AppendLine(Tile.TilesAnimating.Count.ToString("N0"));
771
772 text.Append("Layers / grid cells: ")
773 .Append(scene.SceneLayers.Count)
774 .Append(" / ")
775 .AppendLine(gridCells.ToString("N0"));
776 }
777
778 Rectangle viewport = context.View.Viewport.TargetRectPx;
779
780 if ((ContextInfo & ProfilerContextInfo.View) != 0)
781 {
782 PointF camera = context.View.Camera.PositionPx;
783
784 text.Append("Camera: ")
785 .Append(camera.X.ToString("0.0"))
786 .Append(", ")
787 .Append(camera.Y.ToString("0.0"))
788 .Append(" px; zoom: ")
789 .Append(context.View.Viewport.Zoom.ToString("0.000"))
790 .AppendLine("x");
791 }
792
793 bool includeViewport = (ContextInfo & ProfilerContextInfo.View) != 0;
794 bool includeBackbuffer = (ContextInfo & ProfilerContextInfo.Backbuffer) != 0;
795
796 if (includeViewport && includeBackbuffer)
797 {
798 var backbuffer = context.RenderSurfaceHost.Backbuffer;
799
800 text.Append("Viewport / backbuffer: ")
801 .Append(viewport.Width)
802 .Append('x')
803 .Append(viewport.Height)
804 .Append(" / ")
805 .Append(backbuffer.Width)
806 .Append('x')
807 .AppendLine(backbuffer.Height.ToString());
808 }
809 else if (includeViewport)
810 {
811 text.Append("Viewport: ")
812 .Append(viewport.Width)
813 .Append('x')
814 .AppendLine(viewport.Height.ToString());
815 }
816 else if (includeBackbuffer)
817 {
818 var backbuffer = context.RenderSurfaceHost.Backbuffer;
819
820 text.Append("Backbuffer: ")
821 .Append(backbuffer.Width)
822 .Append('x')
823 .AppendLine(backbuffer.Height.ToString());
824 }
825
826 if ((ContextInfo & ProfilerContextInfo.EngineConfiguration) != 0)
827 {
828 text.Append("Target FPS / VSync: ")
829 .Append(Engine.Instance.Configuration.TargetFPS)
830 .Append(" / ")
831 .AppendLine(Engine.Instance.Configuration.VSync.ToString());
832 }
833
834 if ((ContextInfo & ProfilerContextInfo.Msaa) != 0 &&
835 context.RenderSurfaceHost.Backbuffer is GpuBackbuffer gpu)
836 {
837 text.Append("MSAA requested / actual / max: ")
838 .Append(gpu.MsaaSampleCount)
839 .Append(" / ")
840 .Append(gpu.ActualMsaaSampleCount)
841 .Append(" / ")
842 .AppendLine(gpu.MaxSupportedMsaaSampleCount.ToString());
843 }
844 }
845
846 private void ApplyLayout()
847 {
848 Rectangle bounds = Bounds;
849 Rectangle displayBounds = GetDisplayBounds(bounds, ShowMetricSelector);
850
852 Display,
853 new Vector2(
854 displayBounds.X - bounds.X,
855 displayBounds.Y - bounds.Y));
856
857 Display.Size = displayBounds.Size;
858
859 if (_metricSelectorButton is not null || _metricSelectorList is not null)
860 {
861 DisposeMetricSelector();
862 _metricSelectorSignature = null;
863
864 if (ShowMetricSelector && _latestSnapshot is not null)
865 EnsureMetricSelector(_latestSnapshot);
866 }
867 }
868
869 private static Rectangle GetDisplayBounds(Rectangle bounds, bool showSelector)
870 {
871 int toolbarHeight = showSelector
872 ? Math.Min(MetricSelectorHeight, Math.Max(0, bounds.Height - 1))
873 : 0;
874
875 return new Rectangle(
876 bounds.Left,
877 bounds.Top + toolbarHeight,
878 bounds.Width,
879 Math.Max(1, bounds.Height - toolbarHeight));
880 }
881
882 private static Rectangle GetMetricSelectorButtonBounds(Rectangle bounds)
883 {
884 int width = Math.Max(
885 1,
886 Math.Min(
887 MetricSelectorWidth,
888 Math.Max(1, bounds.Width - MetricSelectorMargin * 2)));
889
890 int height = Math.Max(
891 1,
892 Math.Min(
893 MetricSelectorHeight - MetricSelectorMargin * 2,
894 Math.Max(1, bounds.Height)));
895
896 return new Rectangle(
897 bounds.Left + MetricSelectorMargin,
898 bounds.Top + MetricSelectorMargin,
899 width,
900 height);
901 }
902
903 private static Rectangle GetMetricSelectorListBounds(Rectangle bounds)
904 {
905 int width = Math.Max(24, Math.Min(460, Math.Max(24, bounds.Width - MetricSelectorMargin * 2)));
906
907 int availableHeight = Math.Max(
908 28,
909 bounds.Height - MetricSelectorHeight - MetricSelectorMargin);
910
911 int height = Math.Max(28, Math.Min(420, availableHeight));
912
913 return new Rectangle(
914 bounds.Left + MetricSelectorMargin,
915 bounds.Top + MetricSelectorHeight,
916 width,
917 height);
918 }
919
920 private void EnsureMetricSelector(TelemetrySnapshot snapshot)
921 {
922 View? view = View;
923
924 if (!ShowMetricSelector || view is null)
925 return;
926
927 string signature = BuildMetricSelectorSignature(snapshot);
928
929 if (_metricSelectorButton is null ||
930 _metricSelectorList is null ||
931 !string.Equals(_metricSelectorSignature, signature, StringComparison.Ordinal))
932 {
933 bool wasOpen = _metricSelectorOpen;
934 DisposeMetricSelector();
935 _metricSelectorOpen = wasOpen;
936
937 Rectangle bounds = Bounds;
938 Rectangle buttonBounds = GetMetricSelectorButtonBounds(bounds);
939 Rectangle listBounds = GetMetricSelectorListBounds(bounds);
940
941 _metricSelectorButton = new ButtonWidget(
943 view,
944 buttonBounds,
945 "Metrics...",
946 $"{Nickname}.metric-selector.button")
947 .SetButtonZOrder(_profilerZOrder + 100);
948
949 _metricSelectorButton.Clicked += ToggleMetricSelector;
950
951 _metricSelectorList = new ListBoxWidget(
953 view,
954 listBounds,
955 nickname: $"{Nickname}.metric-selector.list")
956 {
957 ItemHeight = 22,
958 VerticalScrollBarVisibility = ScrollBarVisibility.Auto
959 };
960
961 _metricSelectorList
962 .SetListBoxZOrder(_profilerZOrder + 200)
963 .SetSelectionColor(
964 Color.FromArgb(
965 255,
966 70,
967 70,
968 84));
969
970 _metricSelectorList.SelectionCommitted += OnMetricSelectorSelectionCommitted;
971
972 Add(
973 _metricSelectorButton,
974 new Vector2(
975 buttonBounds.X - bounds.X,
976 buttonBounds.Y - bounds.Y));
977
978 Add(
979 _metricSelectorList,
980 new Vector2(
981 listBounds.X - bounds.X,
982 listBounds.Y - bounds.Y));
983
984 _metricSelectorSignature = signature;
985
986 if (!_metricSelectorOpen)
987 _metricSelectorList.Hide();
988 }
989
990 RefreshMetricSelectorRows(snapshot);
991 }
992
993 private string BuildMetricSelectorSignature(TelemetrySnapshot snapshot)
994 {
995 var signature = new StringBuilder()
996 .Append(Bounds.Width)
997 .Append('x')
998 .Append(Bounds.Height);
999
1000 foreach (var sourceGroup in snapshot.Sources
1001 .GroupBy(source => source.Name, StringComparer.OrdinalIgnoreCase)
1002 .OrderBy(group => group.Key, StringComparer.OrdinalIgnoreCase))
1003 {
1004 signature.Append('|').Append(sourceGroup.Key);
1005
1006 foreach (string backend in sourceGroup
1007 .Select(source => source.Backend)
1008 .Distinct(StringComparer.Ordinal)
1009 .OrderBy(value => value, StringComparer.Ordinal))
1010 {
1011 signature.Append('[').Append(backend).Append(']');
1012 }
1013
1014 foreach (string metricKey in sourceGroup
1015 .SelectMany(source => source.Metrics.Keys)
1016 .Distinct(StringComparer.Ordinal)
1017 .OrderBy(value => value, StringComparer.Ordinal))
1018 {
1019 signature.Append(';').Append(metricKey);
1020 }
1021 }
1022
1023 return signature.ToString();
1024 }
1025
1026 private void RefreshMetricSelectorRows(TelemetrySnapshot snapshot)
1027 {
1028 if (_metricSelectorList is null)
1029 return;
1030
1031 _metricSelectorRows.Clear();
1032
1033 AddSelectorRow(
1035 "Hover definitions",
1037
1038 AddSelectorRow(
1040 "Show unavailable",
1042
1043 _metricSelectorRows.Add(
1044 new MetricSelectorRow(
1045 "Show all measurements",
1046 () =>
1047 {
1050 }));
1051
1052 _metricSelectorRows.Add(
1053 new MetricSelectorRow(
1054 "Hide all measurements",
1055 () =>
1056 {
1059 }));
1060
1061 _metricSelectorRows.Add(new MetricSelectorRow("------------------------------", null));
1062
1063 foreach (var sourceGroup in snapshot.Sources
1064 .GroupBy(source => source.Name, StringComparer.OrdinalIgnoreCase)
1065 .OrderBy(group => group.Key, StringComparer.OrdinalIgnoreCase))
1066 {
1067 string sourceName = sourceGroup.Key;
1068
1069 string backend = string.Join(
1070 "/",
1071 sourceGroup
1072 .Select(source => source.Backend)
1073 .Distinct(StringComparer.Ordinal)
1074 .OrderBy(value => value, StringComparer.Ordinal));
1075
1076 bool sourceVisible = IsSourceVisible(sourceName);
1077
1078 AddSelectorRow(
1079 sourceVisible,
1080 $"{sourceName} [{backend}]",
1081 () => SetSourceVisible(sourceName, !IsSourceVisible(sourceName)));
1082
1083 foreach (string metricKey in sourceGroup
1084 .SelectMany(source => source.Metrics.Keys)
1085 .Distinct(StringComparer.Ordinal)
1086 .OrderBy(value => value, StringComparer.Ordinal))
1087 {
1088 TelemetryAvailability availability = sourceGroup
1089 .Where(source => source.Metrics.ContainsKey(metricKey))
1090 .Select(source => source.Metrics[metricKey].Availability)
1091 .DefaultIfEmpty(TelemetryAvailability.Unsupported)
1092 .Max();
1093
1094 bool metricVisible = ResolveMeasurementVisibility(
1095 sourceName,
1096 metricKey,
1097 availability);
1098
1099 string capturedMetricKey = metricKey;
1100 string capturedSourceName = sourceName;
1101 TelemetryAvailability capturedAvailability = availability;
1102
1103 string availabilitySuffix = availability == TelemetryAvailability.Available
1104 ? string.Empty
1105 : $" [{FormatAvailability(availability)}]";
1106
1107 AddSelectorRow(
1108 metricVisible,
1109 $" {metricKey}{availabilitySuffix}",
1111 capturedSourceName,
1112 capturedMetricKey,
1113 !ResolveMeasurementVisibility(
1114 capturedSourceName,
1115 capturedMetricKey,
1116 capturedAvailability)));
1117 }
1118 }
1119
1120 int topIndex = _metricSelectorList.TopIndex;
1121 _metricSelectorList.SetItems(_metricSelectorRows.Select(row => row.Text));
1122
1123 int maximumTopIndex = Math.Max(
1124 0,
1125 _metricSelectorRows.Count - _metricSelectorList.VisibleItemCount);
1126
1127 _metricSelectorList.TopIndex = Math.Min(topIndex, maximumTopIndex);
1128 }
1129
1130 private void AddSelectorRow(bool isChecked, string text, Action action)
1131 {
1132 _metricSelectorRows.Add(
1133 new MetricSelectorRow(
1134 $"[{(isChecked ? 'x' : ' ')}] {text}",
1135 action));
1136 }
1137
1138 private void ToggleMetricSelector()
1139 {
1140 if (_metricSelectorList is null)
1141 return;
1142
1143 _metricSelectorOpen = !_metricSelectorOpen;
1144
1145 if (_metricSelectorOpen)
1146 {
1147 _metricSelectorList.Show();
1148 _metricSelectorList.Activate();
1149 }
1150 else
1151 {
1152 _metricSelectorList.Hide();
1153 }
1154 }
1155
1156 private void OnMetricSelectorSelectionCommitted(int index)
1157 {
1158 if (index < 0 || index >= _metricSelectorRows.Count)
1159 return;
1160
1161 MetricSelectorRow row = _metricSelectorRows[index];
1162
1163 if (row.Action is null)
1164 return;
1165
1166 row.Action();
1167 Refresh();
1168 }
1169
1170 private void DisposeMetricSelector()
1171 {
1172 if (_metricSelectorButton is not null)
1173 {
1174 _metricSelectorButton.Clicked -= ToggleMetricSelector;
1175 RemoveChild(_metricSelectorButton, dispose: true);
1176 _metricSelectorButton = null;
1177 }
1178
1179 if (_metricSelectorList is not null)
1180 {
1181 _metricSelectorList.SelectionCommitted -= OnMetricSelectorSelectionCommitted;
1182 RemoveChild(_metricSelectorList, dispose: true);
1183 _metricSelectorList = null;
1184 }
1185
1186 _metricSelectorRows.Clear();
1187 _metricSelectorSignature = null;
1188 }
1189
1190 private void CaptureRenderedMetricLines(string text)
1191 {
1192 _renderedMetricLines.Clear();
1193
1194 string[] lines = text
1195 .Replace("\r\n", "\n", StringComparison.Ordinal)
1196 .Split('\n');
1197
1198 for (int index = 0; index < lines.Length; index++)
1199 {
1200 string line = lines[index];
1201
1202 if (!line.StartsWith(" ", StringComparison.Ordinal))
1203 continue;
1204
1205 int colon = line.IndexOf(':', 2);
1206
1207 if (colon <= 2)
1208 continue;
1209
1210 string metricKey = line[2..colon].Trim();
1211
1212 if (!string.IsNullOrWhiteSpace(metricKey))
1213 _renderedMetricLines[index] = metricKey;
1214 }
1215 }
1216
1217 private void OnProfilerPointerMove(WidgetPointerEventArgs args)
1218 {
1220 {
1221 _measurementTooltip.HideTooltip();
1222 return;
1223 }
1224
1225 Rectangle displayBounds = Display.Bounds;
1226 Point pointer = Point.Round(args.ScreenPositionPx);
1227
1228 if (!displayBounds.Contains(pointer))
1229 {
1230 _measurementTooltip.HideTooltip();
1231 return;
1232 }
1233
1234 float lineHeight = Display.TextBlock.LineHeight;
1235
1236 if (lineHeight <= 0f)
1237 {
1238 _measurementTooltip.HideTooltip();
1239 return;
1240 }
1241
1242 float localY =
1243 args.ScreenPositionPx.Y -
1244 displayBounds.Top -
1245 Display.TextBlock.VerticalPadding +
1246 Display.VerticalScrollOffsetPx;
1247
1248 if (localY < 0f)
1249 {
1250 _measurementTooltip.HideTooltip();
1251 return;
1252 }
1253
1254 int lineIndex = (int)MathF.Floor(localY / lineHeight);
1255
1256 if (!_renderedMetricLines.TryGetValue(lineIndex, out string? metricKey))
1257 {
1258 _measurementTooltip.HideTooltip();
1259 return;
1260 }
1261
1262 string? description = GetMeasurementDescription(metricKey);
1263
1264 if (string.IsNullOrWhiteSpace(description))
1265 {
1266 _measurementTooltip.HideTooltip();
1267 return;
1268 }
1269
1270 _measurementTooltip.ShowTooltip(
1271 $"{metricKey}\n{description}",
1272 pointer);
1273 }
1274
1275 private void OnProfilerPointerLeave(WidgetPointerEventArgs args)
1276 {
1277 _ = args;
1278 _measurementTooltip.HideTooltip();
1279 }
1280
1281 private void OnProfilerMouseWheel(WidgetMouseWheelEventArgs args)
1282 {
1283 _ = args;
1284 _measurementTooltip.HideTooltip();
1285 }
1286
1287 private string? GetMeasurementDescription(string metricKey)
1288 {
1289 if (_measurementDescriptions.TryGetValue(metricKey, out string? overrideDescription))
1290 return overrideDescription;
1291
1292 string normalizedKey = NormalizeLayerMetricKey(metricKey);
1293
1294 string? description = normalizedKey switch
1295 {
1296 "cycle.cpu.ms" =>
1297 "CPU time for one complete Engine cycle. The sample rate is the Engine cycle rate (CPS).",
1298 "background.cpu.ms" =>
1299 "CPU time spent in background/simulation work for one Engine cycle.",
1300 "foreground.cpu.ms" =>
1301 "CPU time spent in foreground/render-preparation work. The sample rate is foreground frame production.",
1302 "build.cpu.ms" =>
1303 "Engine-thread time spent building the render frame or render snapshot.",
1304 "query.cpu.ms" =>
1305 "Time spent querying and culling visible drawables. Sorting is reported separately.",
1306 "sort.cpu.ms" =>
1307 "Time spent sorting queried drawables into render order.",
1308 "record.cpu.ms" =>
1309 "Time spent recording render commands after query/sort.",
1310 "overlay.cpu.ms" =>
1311 "Time spent recording view/direct-drawing overlay work.",
1312 "visible.drawables" =>
1313 "Visible drawable instances observed during a render build, including repeated instances across views.",
1314 "visible.tiles" =>
1315 "Visible tile draw instances observed during a render build.",
1316 "atlas.batches" =>
1317 "Atlas-backed tile batches generated for a render build.",
1318 "atlas.tiles" =>
1319 "Tiles emitted through atlas-backed batches for a render build.",
1320 "replay.cpu.ms" =>
1321 "GPU presentation-thread time spent replaying a completed render snapshot.",
1322 "picture.cpu.ms" =>
1323 "Time spent replaying the recorded Skia picture into the GPU backbuffer.",
1324 "backbuffer.flush.cpu.ms" =>
1325 "Time spent flushing GPU backbuffer drawing after replay.",
1326 "snapshot.cpu.ms" =>
1327 "Time spent snapshotting the current GPU backbuffer for presentation/inspection.",
1328 "snapshot.age.ms" =>
1329 "Age of the consumed render snapshot when GPU replay begins. Higher values indicate producer/consumer lag.",
1330 "mailbox.published.lifetime" =>
1331 "Lifetime count of render snapshots published to the producer/consumer mailbox.",
1332 "mailbox.dropped.lifetime" =>
1333 "Lifetime count of published snapshots superseded before they could be consumed.",
1334 "mailbox.slots" =>
1335 "Current occupied snapshot-mailbox slots.",
1336 "snapshot.commands.approximate" =>
1337 "Approximate command count retained by the latest render snapshot.",
1338 "gate.wait.cpu.ms" =>
1339 "Time spent waiting to enter the shared live render-state gate. Current desktop snapshot replay does not enter this broad gate, so the desktop GPU source reports NotApplicable.",
1340 "gate.held.cpu.ms" =>
1341 "Time spent while holding the shared live render-state gate. Current desktop snapshot replay does not enter this broad gate, so the desktop GPU source reports NotApplicable.",
1342 "presentation.count" =>
1343 "Completed presentation callbacks. Its sample rate is the actual GPU presentation FPS for this render surface.",
1344 "presentation.cpu.ms" =>
1345 "Total CPU duration of one GPU presentation callback.",
1346 "render.snapshot.cpu.ms" =>
1347 "Combined render/snapshot CPU work measured by the GPU presentation path.",
1348 "blit.cpu.ms" =>
1349 "Platform presentation time spent blitting the completed image.",
1350 "flush.cpu.ms" =>
1351 "Platform presentation time spent performing the final graphics flush.",
1352 "layers.omitted" =>
1353 "Number of SceneLayers omitted from detailed per-layer telemetry because the retained layer-detail limit was reached.",
1354 "layer.query.cpu.ms" =>
1355 "Per-layer time spent querying/culling visible content; sorting is excluded.",
1356 "layer.record.cpu.ms" =>
1357 "Per-layer time spent recording render commands.",
1358 "layer.drawables" =>
1359 "Visible drawable instances contributed by this SceneLayer across views.",
1360 "layer.tiles" =>
1361 "Visible tile draw instances contributed by this SceneLayer.",
1362 "layer.transformed.tiles" =>
1363 "Current count of this layer's visible tiles requiring transform work.",
1364 "layer.tile.width.px" =>
1365 "Current native tile width for this SceneLayer.",
1366 "layer.tile.height.px" =>
1367 "Current native tile height for this SceneLayer.",
1368 "layer.z" =>
1369 "Current SceneLayer Z-order.",
1370 _ => null
1371 };
1372
1373 if (description is null)
1374 return null;
1375
1376 if (_latestSnapshot is null)
1377 return description;
1378
1379 TelemetrySummary? summary = _latestSnapshot.Sources
1380 .SelectMany(source => source.Metrics)
1381 .Where(pair => string.Equals(
1382 NormalizeLayerMetricKey(pair.Key),
1383 normalizedKey,
1384 StringComparison.Ordinal))
1385 .Select(pair => pair.Value)
1386 .FirstOrDefault();
1387
1388 return summary?.Kind == TelemetryMetricKind.Sample
1389 ? description +
1390 "\n\navg/min/max are values observed during the current telemetry window. " +
1391 "samples is how many times this metric was recorded; samples/s is that count " +
1392 "divided by the window duration, not the metric value per second."
1393 : description;
1394 }
1395
1396 private static string NormalizeLayerMetricKey(string metricKey)
1397 {
1398 if (!metricKey.StartsWith("layer.", StringComparison.Ordinal))
1399 return metricKey;
1400
1401 int firstSeparator = metricKey.IndexOf('.', "layer.".Length);
1402
1403 if (firstSeparator < 0 || firstSeparator + 1 >= metricKey.Length)
1404 return metricKey;
1405
1406 return "layer." + metricKey[(firstSeparator + 1)..];
1407 }
1408
1409 private sealed record MetricSelectorRow(string Text, Action? Action);
1410
1411 private bool IsSourceVisible(string sourceName)
1412 {
1413 return !_sourceVisibility.TryGetValue(sourceName, out bool visible) || visible;
1414 }
1415
1416 private bool ResolveMeasurementVisibility(
1417 string sourceName,
1418 string metricKey,
1419 TelemetryAvailability availability)
1420 {
1421 if (!IsSourceVisible(sourceName))
1422 return false;
1423
1424 bool explicitlySelected = false;
1425 bool selected;
1426
1427 if (_sourceMeasurementVisibility.TryGetValue(
1428 CreateSourceMetricKey(sourceName, metricKey),
1429 out bool sourceMetricVisible))
1430 {
1431 selected = sourceMetricVisible;
1432 explicitlySelected = sourceMetricVisible;
1433 }
1434 else if (_measurementVisibility.TryGetValue(metricKey, out bool metricVisible))
1435 {
1436 selected = metricVisible;
1437 explicitlySelected = metricVisible;
1438 }
1439 else
1440 {
1442 }
1443
1444 if (!selected)
1445 return false;
1446
1447 return availability == TelemetryAvailability.Available ||
1449 explicitlySelected;
1450 }
1451
1452 private static string FormatSummary(TelemetrySummary summary, double elapsedSeconds)
1453 {
1454 if (summary.Availability != TelemetryAvailability.Available)
1455 return summary.Availability.ToString();
1456
1457 return summary.Kind switch
1458 {
1459 TelemetryMetricKind.Gauge =>
1460 $"last {FormatNumber(summary.Last)}",
1461 TelemetryMetricKind.LifetimeCounter =>
1462 summary.WindowDelta is { } delta
1463 ? $"last {FormatNumber(summary.Last)}, delta {FormatNumber(delta)}"
1464 : $"last {FormatNumber(summary.Last)}, delta n/a",
1465 _ =>
1466 $"avg {FormatNumber(summary.Mean)}, min {FormatNumber(summary.Minimum)}, " +
1467 $"max {FormatNumber(summary.Maximum)}, samples {summary.Count:N0} " +
1468 $"({FormatRate(summary.Count, elapsedSeconds)} samples/s)"
1469 };
1470 }
1471
1472 private static string FormatRate(long count, double elapsedSeconds)
1473 {
1474 return elapsedSeconds > 0d
1475 ? (count / elapsedSeconds).ToString("0.0")
1476 : "n/a";
1477 }
1478
1479 private static string FormatNumber(double? value)
1480 {
1481 return value?.ToString("0.###") ?? "n/a";
1482 }
1483
1484 private static string FormatAvailability(TelemetryAvailability availability)
1485 {
1486 return availability switch
1487 {
1488 TelemetryAvailability.Unsupported => "unsupported",
1489 TelemetryAvailability.NotApplicable => "not applicable",
1490 TelemetryAvailability.NotYetSampled => "not yet sampled",
1491 _ => "available"
1492 };
1493 }
1494
1495 private static string CreateSourceMetricKey(string sourceName, string metricKey)
1496 {
1497 return $"{sourceName.ToUpperInvariant()}\u001f{metricKey}";
1498 }
1499
1500 private static void ValidateMetricKey(string metricKey)
1501 {
1502 ArgumentException.ThrowIfNullOrWhiteSpace(metricKey);
1503 }
1504
1505 private static Rectangle ValidateBounds(Rectangle bounds)
1506 {
1507 ValidateSize(bounds.Size);
1508 return bounds;
1509 }
1510
1511 private static void ValidateSize(Size size)
1512 {
1513 if (size.Width <= 0 || size.Height <= 0)
1514 throw new ArgumentOutOfRangeException(nameof(size), size, "Profiler widget size must be positive.");
1515 }
1516}
TelemetrySnapshot? GetLatestSnapshot()
Returns the latest completed bucket, or null before one completes.
IDisposable Start()
Starts or joins collection. Disposing the last request stops collection.
bool Visible
Gets or sets the visibility of all descendants.
RenderSurfaceHostBase RenderSurfaceHost
Gets the render surface host shared by the composite and its children.
DirectComposite SetLocalOffset(IDirectCompositeChild child, Vector2 newLocalOffsetPx)
Changes one child's local offset and reapplies its position.
DirectComposite SetIsVisible(bool visible)
Applies one visibility value to every descendant.
virtual DirectComposite Clear()
Removes every child without disposing them.
View? View
Gets the view shared by all children in view mode.
Vector2 GetPosition()
Gets the current composite anchor.
A retained-mode text drawable with wrapping, multi-line ( ) support, horizontal/vertical alignment,...
Definition TextBlock.cs:44
VerticalAlign
Vertical alignment options for multi-line text within the control's bounds.
Definition TextBlock.cs:49
Represents the core game engine singleton responsible for managing the main update loop,...
Definition Engine.cs:36
static Engine Instance
Gets the singleton instance of the Engine.
Definition Engine.cs:49
Diagnostics.RuntimeProfiler Profiler
Opt-in runtime CPU measurements and bounded history, independent of CPS notifications.
Definition Engine.cs:241
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Definition View.cs:14
override DirectComposite Clear()
Removes every child without disposing them.The current composite.
bool RemoveChild(WidgetBase widget, bool dispose=false)
Removes a child widget from the container.
override DirectComposite Add(IDirectCompositeChild child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
Adds a composite-compatible direct drawable as a child.The current composite.
ContainerWidget(RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
Initializes a new instance of the ContainerWidget class.
Represents a basic text button composed from a rectangle and text block.
Displays retained-mode text as a reusable Gondwana widget.
Provides a selectable, vertically scrolling list of text items.
ProfilerWidgetExtensionContext(TelemetrySnapshot? snapshot, RenderSurfaceHostBase renderSurfaceHost, View view)
Initializes a new profiler-widget extension context.
RenderSurfaceHostBase RenderSurfaceHost
Gets the render surface host displayed by the widget.
TelemetrySnapshot? Snapshot
Gets the latest detached telemetry snapshot, or null before the first window completes.
View View
Gets the view displayed by the widget.
ProfilerWidget(RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle bounds, string? nickname=null)
Creates a view-level runtime-profiler widget.
ProfilerWidget SetProfilerZOrder(int zOrder)
Sets the base Z-order used by the profiler label and scrollbar.
bool MeasurementTooltipsEnabled
Gets or sets whether hovering a rendered measurement shows its definition.
bool IsCollectionActive
Gets whether this widget currently owns an active profiler collection request.
bool IsMeasurementVisible(string sourceName, string metricKey)
Returns whether a metric would be displayed under the current source/metric visibility rules.
ProfilerMeasurementVisibilityMode MeasurementVisibilityMode
Gets or sets the default measurement visibility policy.
Rectangle Bounds
Gets the current widget bounds in view pixels.
bool ShowSourceHeaders
Gets or sets whether source name/backend headings are displayed.
Func< ProfilerWidgetExtensionContext, IEnumerable< string >?>? AdditionalLinesProvider
Gets or sets an optional callback that supplies application-specific diagnostic lines.
bool ShowSnapshotMetadata
Gets or sets whether generation, elapsed-window, and truncation information is displayed.
bool ShowMetricSelector
Gets or sets whether the built-in Metrics selector control is displayed.
override void Dispose()
Disposes the composite and every child it owns.
LabelWidget Display
Gets the label used to render profiler text and optional scrolling.
bool ShowHeader
Gets or sets whether HeaderText is displayed.
TooltipWidget MeasurementTooltip
Gets the tooltip used for measurement definitions.
ProfilerWidget SetFont(SKTypeface typeface, float size, float? minSize=null)
Sets the profiler typeface and text size.
TimeSpan RefreshInterval
Gets or sets how frequently the widget reads and formats the latest completed snapshot.
ProfilerContextInfo ContextInfo
Gets or sets the supplemental runtime context rendered before profiler measurements.
ProfilerWidget SetColors(SKColor foreground, SKColor background)
Sets profiler text and background colors.
ProfilerWidget SetMeasurementDescription(string metricKey, string? description)
Defines or replaces hover help for a measurement key.
override void ProcessShown()
Performs processing when the widget is shown before notification callbacks are invoked.
override void ProcessHidden()
Performs processing when the widget is hidden before notification callbacks are invoked.
string HeaderText
Gets or sets the heading displayed when ShowHeader is enabled.
bool ShowUnavailableMeasurements
Gets or sets whether unsupported, not-applicable, and not-yet-sampled measurements are shown when the...
ProfilerWidget SetMeasurementVisible(string metricKey, bool visible)
Sets a visibility override for a metric key across all profiler sources.
ProfilerWidget ClearVisibilityOverrides()
Removes all explicit source and measurement visibility overrides.
Size Size
Gets or sets the widget size while preserving its current position.
ProfilerWidget SetMeasurementVisible(string sourceName, string metricKey, bool visible)
Sets a visibility override for one metric on one named profiler source.
ProfilerWidget SetSourceVisible(string sourceName, bool visible)
Sets whether all measurements from a named profiler source are displayed.
ProfilerWidget Refresh()
Immediately reads and formats the latest completed profiler snapshot.
Displays a lightweight view-level text tooltip near a screen position.
bool CanReceiveFocus
Gets or sets a value indicating whether the widget can receive keyboard focus.
bool IsPointerInputEnabled
Gets or sets a value indicating whether the widget can receive pointer input.
Action< WidgetPointerEventArgs >? PointerMove
Occurs when a pointer moves while routed to the widget.
Definition WidgetBase.cs:56
Action< WidgetPointerEventArgs >? PointerLeave
Occurs when a pointer leaves the widget bounds.
Definition WidgetBase.cs:46
bool IsKeyboardInputEnabled
Gets or sets a value indicating whether the widget can receive keyboard input.
bool IsInputEnabled
Gets or sets a value indicating whether the widget can participate in input routing.
PointF ScreenPositionPx
Gets the pointer position in screen pixels.
record TelemetrySummary(TelemetryAvailability Availability, long Count, double Sum, double? Minimum, double? Maximum, double? Last)
Detached statistics for observations in one window; durations use milliseconds.
record TelemetrySourceSnapshot(long Id, string Name, string Backend, IReadOnlyDictionary< string, TelemetrySummary > Metrics)
Detached source identity, backend label, and measurements. No runtime objects are retained.
TelemetryAvailability
Whether an observation is meaningful for its source and window.
record TelemetrySnapshot(long Generation, double StartedSeconds, double EndedSeconds, IReadOnlyList< TelemetrySourceSnapshot > Sources, bool Truncated)
Detached completed window. Sources can be observed asynchronously within its interval.
@ Rectangle
Particles are spawned uniformly within a rectangular area. This is the default distribution.
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.
ScrollBarVisibility
Specifies when a scrollable widget displays its vertical scrollbar.
ProfilerMeasurementVisibilityMode
Controls the default visibility policy for runtime-profiler measurements.
@ Selected
Hides measurements unless they are explicitly shown.
@ All
Shows every measurement unless it is explicitly hidden.
ProfilerContextInfo
Selects optional non-profiler runtime context rendered alongside telemetry measurements.
@ Msaa
Displays requested, actual, and maximum MSAA values when the backbuffer is GPU-backed.
@ EngineConfiguration
Displays target FPS and VSync configuration.
@ View
Displays camera position, viewport zoom, and viewport dimensions.
@ None
Displays no supplemental runtime context.
@ Scene
Displays scene layer, grid-cell, and active tile-animation counts.
@ Backbuffer
Displays logical backbuffer dimensions.