From 6dce1f584491d9018e8fd1cb0aa9b7a672a8654e Mon Sep 17 00:00:00 2001 From: ramenrrami Date: Mon, 22 Sep 2025 12:31:32 +0200 Subject: [PATCH] Fix: safer FPS/frame time calculation in panels.cpp --- CMakeLists.txt | 5 +++-- src/frontend/panels.cpp | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5157ca2..e25fa11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,9 @@ endforeach() # Optimizations set_property(TARGET Pound PROPERTY CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) if (WIN32) - target_compile_options(Pound PRIVATE $<$:/Oi>) - target_compile_options(Pound PRIVATE $<$:/Ot>) + # Fix: remove MSVC-only flags (/Oi, /Ot) for MinGW/GCC builds + target_compile_options(Pound PRIVATE + $<$,$>:/Oi /Ot>) endif() target_link_libraries(Pound PRIVATE diff --git a/src/frontend/panels.cpp b/src/frontend/panels.cpp index 4f0d6e5..5897f6e 100644 --- a/src/frontend/panels.cpp +++ b/src/frontend/panels.cpp @@ -3,6 +3,7 @@ #include #include "kvm/kvm.h" #include "common/passert.h" +#include int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* panel, performance_data_t* data, std::chrono::steady_clock::time_point* last_render) @@ -24,9 +25,11 @@ int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* pan ++data->frame_count; if (duration.count() >= 100) { - // Every 100ms - data->fps = (float)data->frame_count * 1000.0f / (float)duration.count(); - data->frame_time = (float)duration.count() / (float)data->frame_count; + //every 100ms + const double ms = static_cast(duration.count()); + data->fps = static_cast(static_cast(data->frame_count) * 1000.0 / ms); + data->frame_time = static_cast(ms / static_cast(data->frame_count)); + panel->fps_history.push_back(data->fps); panel->frame_time_history.push_back(data->frame_time); @@ -60,8 +63,11 @@ int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* pan (void)std::copy(panel->frame_time_history.begin(), panel->frame_time_history.end(), frame_time_array); ::ImGui::Text("Frame Time History (ms):"); - ::ImGui::PlotLines("##FrameTime", frame_time_array, (int)panel->frame_time_history.size(), 0, nullptr, 0.0f, - 33.33f, ImVec2(0, 80)); + ::ImGui::PlotLines("##FrameTime", + frame_time_array, + static_cast(panel->frame_time_history.size()), + 0, nullptr, 0.0f, 33.33f, ImVec2(0, 80)); + } ::ImGui::Separator();