From 7f4d2d8db6718f3e4b8a7eb8ff3fe6b2fe46d239 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 5 Jan 2024 12:53:48 +0100 Subject: [PATCH] Fix GPU profiler event percentage calculation and add tint highlight to spot slow entries --- Source/Editor/Windows/Profiler/GPU.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs index d2c34d335..6ddd5e704 100644 --- a/Source/Editor/Windows/Profiler/GPU.cs +++ b/Source/Editor/Windows/Profiler/GPU.cs @@ -321,8 +321,7 @@ namespace FlaxEditor.Windows.Profiler var data = _events.Get(_drawTimeCPU.SelectedSampleIndex); if (data == null || data.Length == 0) return; - - float totalTimeMs = _drawTimeCPU.SelectedSample; + float totalTimeMs = _drawTimeGPU.SelectedSample; // Add rows var rowColor2 = Style.Current.Background * 1.4f; @@ -343,14 +342,19 @@ namespace FlaxEditor.Windows.Profiler row = new Row { Values = new object[6], + BackgroundColors = new Color[6], }; + for (int k = 0; k < row.BackgroundColors.Length; k++) + row.BackgroundColors[k] = Color.Transparent; } { // Event row.Values[0] = name; // Total (%) - row.Values[1] = (int)(e.Time / totalTimeMs * 1000.0f) / 10.0f; + float rowTimePerc = (float)(e.Time / totalTimeMs); + row.Values[1] = (int)(rowTimePerc * 1000.0f) / 10.0f; + row.BackgroundColors[1] = Color.Red.AlphaMultiplied(Mathf.Min(1, rowTimePerc) * 0.5f); // GPU ms row.Values[2] = (e.Time * 10000.0f) / 10000.0f;