From 224c2c049ea486e33c191418b6b11faa255a0eb6 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 18 Jun 2024 19:25:12 -0500 Subject: [PATCH] Fix the profiler charts in place and only scroll profiler info. --- Source/Editor/Windows/Profiler/Assets.cs | 28 ++++++++----- Source/Editor/Windows/Profiler/CPU.cs | 31 +++++++++----- Source/Editor/Windows/Profiler/GPU.cs | 45 +++++++++++++-------- Source/Editor/Windows/Profiler/MemoryGPU.cs | 28 ++++++++----- 4 files changed, 84 insertions(+), 48 deletions(-) diff --git a/Source/Editor/Windows/Profiler/Assets.cs b/Source/Editor/Windows/Profiler/Assets.cs index a4c1c02c0..d5b735fa3 100644 --- a/Source/Editor/Windows/Profiler/Assets.cs +++ b/Source/Editor/Windows/Profiler/Assets.cs @@ -38,12 +38,29 @@ namespace FlaxEditor.Windows.Profiler : base("Assets") { // Layout - var panel = new Panel(ScrollBars.Vertical) + var mainPanel = new Panel(ScrollBars.None) { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, Parent = this, }; + + // Chart + _memoryUsageChart = new SingleChart + { + Title = "Assets Memory Usage (CPU)", + AnchorPreset = AnchorPresets.HorizontalStretchTop, + FormatSample = v => Utilities.Utils.FormatBytesCount((int)v), + Parent = mainPanel, + }; + _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; + + var panel = new Panel(ScrollBars.Vertical) + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, _memoryUsageChart.Height + 2, 0), + Parent = mainPanel, + }; var layout = new VerticalPanel { AnchorPreset = AnchorPresets.HorizontalStretchTop, @@ -52,15 +69,6 @@ namespace FlaxEditor.Windows.Profiler Parent = panel, }; - // Chart - _memoryUsageChart = new SingleChart - { - Title = "Assets Memory Usage (CPU)", - FormatSample = v => Utilities.Utils.FormatBytesCount((int)v), - Parent = layout, - }; - _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; - // Table var style = Style.Current; var headerColor = style.LightBackground; diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs index ce62926d9..5246957f6 100644 --- a/Source/Editor/Windows/Profiler/CPU.cs +++ b/Source/Editor/Windows/Profiler/CPU.cs @@ -57,12 +57,30 @@ namespace FlaxEditor.Windows.Profiler : base("CPU") { // Layout - var panel = new Panel(ScrollBars.Vertical) + var mainPanel = new Panel(ScrollBars.None) { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, Parent = this, }; + + // Chart + _mainChart = new SingleChart + { + Title = "Update", + AnchorPreset = AnchorPresets.HorizontalStretchTop, + FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms", + Parent = mainPanel, + }; + _mainChart.SelectedSampleChanged += OnSelectedSampleChanged; + + var panel = new Panel(ScrollBars.Vertical) + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, _mainChart.Height + 2, 0), + Parent = mainPanel, + }; + //panel.Y = _mainChart.Height + 2; var layout = new VerticalPanel { AnchorPreset = AnchorPresets.HorizontalStretchTop, @@ -70,16 +88,7 @@ namespace FlaxEditor.Windows.Profiler IsScrollable = true, Parent = panel, }; - - // Chart - _mainChart = new SingleChart - { - Title = "Update", - FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms", - Parent = layout, - }; - _mainChart.SelectedSampleChanged += OnSelectedSampleChanged; - + // Timeline _timeline = new Timeline { diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs index fcc98c681..dd90f891b 100644 --- a/Source/Editor/Windows/Profiler/GPU.cs +++ b/Source/Editor/Windows/Profiler/GPU.cs @@ -25,12 +25,39 @@ namespace FlaxEditor.Windows.Profiler : base("GPU") { // Layout - var panel = new Panel(ScrollBars.Vertical) + var mainPanel = new Panel(ScrollBars.None) { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, Parent = this, }; + + // Chart + _drawTimeCPU = new SingleChart + { + Title = "Draw (CPU)", + AnchorPreset = AnchorPresets.HorizontalStretchTop, + FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms", + Parent = mainPanel, + }; + _drawTimeCPU.SelectedSampleChanged += OnSelectedSampleChanged; + + _drawTimeGPU = new SingleChart + { + Title = "Draw (GPU)", + AnchorPreset = AnchorPresets.HorizontalStretchTop, + Offsets = new Margin(0, 0, _drawTimeCPU.Height + 2, 0), + FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms", + Parent = mainPanel, + }; + _drawTimeGPU.SelectedSampleChanged += OnSelectedSampleChanged; + + var panel = new Panel(ScrollBars.Vertical) + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, _drawTimeCPU.Height + _drawTimeGPU.Height + 4, 0), + Parent = mainPanel, + }; var layout = new VerticalPanel { AnchorPreset = AnchorPresets.HorizontalStretchTop, @@ -39,22 +66,6 @@ namespace FlaxEditor.Windows.Profiler Parent = panel, }; - // Chart - _drawTimeCPU = new SingleChart - { - Title = "Draw (CPU)", - FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms", - Parent = layout, - }; - _drawTimeCPU.SelectedSampleChanged += OnSelectedSampleChanged; - _drawTimeGPU = new SingleChart - { - Title = "Draw (GPU)", - FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms", - Parent = layout, - }; - _drawTimeGPU.SelectedSampleChanged += OnSelectedSampleChanged; - // Timeline _timeline = new Timeline { diff --git a/Source/Editor/Windows/Profiler/MemoryGPU.cs b/Source/Editor/Windows/Profiler/MemoryGPU.cs index ac91ecd99..00f24821a 100644 --- a/Source/Editor/Windows/Profiler/MemoryGPU.cs +++ b/Source/Editor/Windows/Profiler/MemoryGPU.cs @@ -39,12 +39,29 @@ namespace FlaxEditor.Windows.Profiler : base("GPU Memory") { // Layout - var panel = new Panel(ScrollBars.Vertical) + var mainPanel = new Panel(ScrollBars.None) { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, Parent = this, }; + + // Chart + _memoryUsageChart = new SingleChart + { + Title = "GPU Memory Usage", + AnchorPreset = AnchorPresets.HorizontalStretchTop, + FormatSample = v => Utilities.Utils.FormatBytesCount((int)v), + Parent = mainPanel, + }; + _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; + + var panel = new Panel(ScrollBars.Vertical) + { + AnchorPreset = AnchorPresets.StretchAll, + Offsets = new Margin(0, 0, _memoryUsageChart.Height + 2, 0), + Parent = mainPanel, + }; var layout = new VerticalPanel { AnchorPreset = AnchorPresets.HorizontalStretchTop, @@ -53,15 +70,6 @@ namespace FlaxEditor.Windows.Profiler Parent = panel, }; - // Chart - _memoryUsageChart = new SingleChart - { - Title = "GPU Memory Usage", - FormatSample = v => Utilities.Utils.FormatBytesCount((int)v), - Parent = layout, - }; - _memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged; - // Table var style = Style.Current; var headerColor = style.LightBackground;