diff --git a/extern/aurora b/extern/aurora index b59a3a5b3c..e3fd6b1900 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit b59a3a5b3caa53174365109b1abc0ced0ce0c9b7 +Subproject commit e3fd6b19008e40ba3888099e3c4555c9958e1c21 diff --git a/src/dusk/ui/overlay.cpp b/src/dusk/ui/overlay.cpp index 69c262720e..d6f87b9262 100644 --- a/src/dusk/ui/overlay.cpp +++ b/src/dusk/ui/overlay.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -187,43 +188,6 @@ void remove_element(Rml::Element*& elem) noexcept { } // namespace -// https://vplesko.com/posts/how_to_implement_an_fps_counter.html -void Overlay::advance_fps_counter(float& outFps, Uint64 perfFreq) { - if (perfFreq == 0) { - outFps = 0.f; - return; - } - - const Uint64 curr = SDL_GetPerformanceCounter(); - if (!mFpsHavePrevCounter) { - mFpsPrevCounter = curr; - mFpsHavePrevCounter = true; - outFps = 0.f; - return; - } - - const Uint64 processingTicks = curr - mFpsPrevCounter; - mFpsPrevCounter = curr; - - mFpsFrameEvents.push_back({curr, processingTicks}); - mFpsSumTicks += processingTicks; - - while (!mFpsFrameEvents.empty() && mFpsFrameEvents.front().endCounter + perfFreq < curr) { - mFpsSumTicks -= mFpsFrameEvents.front().processingTicks; - mFpsFrameEvents.pop_front(); - } - - const auto n = mFpsFrameEvents.size(); - if (n == 0 || mFpsSumTicks == 0) { - outFps = 0.f; - return; - } - - const double avgSeconds = - static_cast(mFpsSumTicks) / static_cast(n) / static_cast(perfFreq); - outFps = static_cast(1.0 / avgSeconds); -} - static std::string FormatTime(OSTime ticks) { OSCalendarTime t; OSTicksToCalendarTime(ticks, &t); @@ -276,8 +240,7 @@ void Overlay::update() { mFpsCounter->SetAttribute("corner", kFpsCorners[idx]); const Uint64 perfFreq = SDL_GetPerformanceFrequency(); - float fps = 0.f; - advance_fps_counter(fps, perfFreq); + float fps = aurora_get_fps(); const Uint64 now = SDL_GetPerformanceCounter(); // Limit updates to twice per second @@ -290,9 +253,6 @@ void Overlay::update() { } } else { mFpsCounter->RemoveAttribute("open"); - mFpsFrameEvents.clear(); - mFpsSumTicks = 0; - mFpsHavePrevCounter = false; mFpsLastUpdate = 0; } } diff --git a/src/dusk/ui/overlay.hpp b/src/dusk/ui/overlay.hpp index 8a2edd4a26..a8ccde5b9d 100644 --- a/src/dusk/ui/overlay.hpp +++ b/src/dusk/ui/overlay.hpp @@ -3,7 +3,6 @@ #include "document.hpp" #include -#include namespace dusk::ui { @@ -26,19 +25,7 @@ protected: Rml::Element* mSpeedrunIgt = nullptr; clock::time_point mCurrentToastStartTime; clock::time_point mMenuNotificationStartTime; - - struct FpsFrameEvent { - Uint64 endCounter; - Uint64 processingTicks; - }; - - std::deque mFpsFrameEvents; - Uint64 mFpsSumTicks = 0; - bool mFpsHavePrevCounter = false; - Uint64 mFpsPrevCounter = 0; Uint64 mFpsLastUpdate = 0; - - void advance_fps_counter(float& outFps, Uint64 perfFreq); }; } // namespace dusk::ui