mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-13 04:36:57 +00:00
Fix: safer FPS/frame time calculation in panels.cpp
This commit is contained in:
parent
0af6018a3f
commit
6dce1f5844
2 changed files with 14 additions and 7 deletions
|
|
@ -83,8 +83,9 @@ endforeach()
|
|||
# Optimizations
|
||||
set_property(TARGET Pound PROPERTY CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
||||
if (WIN32)
|
||||
target_compile_options(Pound PRIVATE $<$<CONFIG:Release>:/Oi>)
|
||||
target_compile_options(Pound PRIVATE $<$<CONFIG:Release>:/Ot>)
|
||||
# Fix: remove MSVC-only flags (/Oi, /Ot) for MinGW/GCC builds
|
||||
target_compile_options(Pound PRIVATE
|
||||
$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<CONFIG:Release>>:/Oi /Ot>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(Pound PRIVATE
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <math.h>
|
||||
#include "kvm/kvm.h"
|
||||
#include "common/passert.h"
|
||||
#include <algorithm>
|
||||
|
||||
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<double>(duration.count());
|
||||
data->fps = static_cast<float>(static_cast<double>(data->frame_count) * 1000.0 / ms);
|
||||
data->frame_time = static_cast<float>(ms / static_cast<double>(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<int>(panel->frame_time_history.size()),
|
||||
0, nullptr, 0.0f, 33.33f, ImVec2(0, 80));
|
||||
|
||||
}
|
||||
|
||||
::ImGui::Separator();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue