From 7bfdc56716f02744e1f7d25edc9de4b02220381a Mon Sep 17 00:00:00 2001
From: Matt Borgerson <contact@mborgerson.com>
Date: Mon, 20 Jun 2022 21:57:18 -0700
Subject: [PATCH] ui: Fix axes, add mspf to advanced video graph

---
 ui/xui/debug.cc | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/ui/xui/debug.cc b/ui/xui/debug.cc
index 392b4f35ab..7fcaad8cc5 100644
--- a/ui/xui/debug.cc
+++ b/ui/xui/debug.cc
@@ -290,20 +290,30 @@ void DebugVideoWindow::Draw()
         if (ImGui::TreeNode("Advanced")) {
             ImGui::SetNextWindowBgAlpha(alpha);
             if (ImPlot::BeginPlot("##ScrollingDraws", ImVec2(-1,-1))) {
-                ImPlot::SetupAxes(NULL, NULL, rt_axis, rt_axis | ImPlotAxisFlags_Lock);
-                ImPlot::SetupAxesLimits(x_start, x_end, 0, 1500, ImPlotCond_Always);
+                ImPlot::SetupAxes(NULL, NULL, ImPlotAxisFlags_None, ImPlotAxisFlags_LogScale | ImPlotAxisFlags_AutoFit);
+                ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1500);
+                ImPlot::SetupAxisLimits(ImAxis_X1, 0, NV2A_PROF_NUM_FRAMES);
+
+                ImGui::PushID(0);
+                ImPlot::PushStyleColor(ImPlotCol_Line, ImPlot::GetColormapColor(0));
+                ImPlot::PushStyleColor(ImPlotCol_Fill, ImPlot::GetColormapColor(0));
+                ImPlot::PlotLine("MSPF", &g_nv2a_stats.frame_history[0].mspf, NV2A_PROF_NUM_FRAMES, 1, 0, g_nv2a_stats.frame_ptr, sizeof(g_nv2a_stats.frame_working));
+                ImPlot::PopStyleColor(2);
+                ImGui::PopID();
+
                 for (int i = 0; i < NV2A_PROF__COUNT; i++) {
-                    ImGui::PushID(i);
+                    ImGui::PushID(i+1);
                     char title[64];
                     snprintf(title, sizeof(title), "%s: %d",
                         nv2a_profile_get_counter_name(i),
                         nv2a_profile_get_counter_value(i));
-                    ImPlot::PushStyleColor(ImPlotCol_Line, ImPlot::GetColormapColor(i));
-                    ImPlot::PushStyleColor(ImPlotCol_Fill, ImPlot::GetColormapColor(i));
-                    ImPlot::PlotLine(title, &g_nv2a_stats.frame_history[0].counters[i], NV2A_PROF_NUM_FRAMES, 1, x_start, g_nv2a_stats.frame_ptr, sizeof(g_nv2a_stats.frame_working));
+                    ImPlot::PushStyleColor(ImPlotCol_Line, ImPlot::GetColormapColor(i+1));
+                    ImPlot::PushStyleColor(ImPlotCol_Fill, ImPlot::GetColormapColor(i+1));
+                    ImPlot::PlotLine(title, &g_nv2a_stats.frame_history[0].counters[i], NV2A_PROF_NUM_FRAMES, 1, 0, g_nv2a_stats.frame_ptr, sizeof(g_nv2a_stats.frame_working));
                     ImPlot::PopStyleColor(2);
                     ImGui::PopID();
                 }
+
                 ImPlot::EndPlot();
             }
             ImGui::TreePop();