From 5b3ce47b3c08d67849697a8fa955a6fafd98b3d2 Mon Sep 17 00:00:00 2001 From: Justin Jacobs Date: Sun, 6 Oct 2024 13:37:25 -0400 Subject: [PATCH] Remove 1ms "compensation" from frame delay Removing this make the SDL_Delay() call last 1ms longer, and reduces the "rest of the frame" spinlock by 1ms. I don't think this should cause an issue (if anything, it should become less likely that SDL_Delay() is called with a value that the OS can't honor). The lower CPU usage under normal circumstances is more desirable in my opinion. --- src/Version.cpp | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Version.cpp b/src/Version.cpp index 7952a2693..8bd5e0b48 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/ #include -Version VersionInfo::ENGINE(1, 14, 64); +Version VersionInfo::ENGINE(1, 14, 65); Version VersionInfo::MIN(0, 0, 0); Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX); diff --git a/src/main.cpp b/src/main.cpp index 94afaeea3..291e46c48 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -259,7 +259,7 @@ static void mainLoop () { // delay quick frames // thanks to David Gow: https://davidgow.net/handmadepenguin/ch18.html if (getSecondsElapsed(prev_ticks, SDL_GetPerformanceCounter()) < seconds_per_frame) { - int32_t delay_ms = static_cast((seconds_per_frame - getSecondsElapsed(prev_ticks, SDL_GetPerformanceCounter())) * 1000.f) - 1; + int32_t delay_ms = static_cast((seconds_per_frame - getSecondsElapsed(prev_ticks, SDL_GetPerformanceCounter())) * 1000.f); if (delay_ms > 0) { SDL_Delay(delay_ms); }